Generate Fake Trace

Import random library


In [1]:
import random

Seed the random number generator.


In [2]:
random.seed()

Generate list of exponentially distributed numbers, which will comprise the distribution of dwell durations.


In [3]:
dwell = []
meanDur = 24
numDwells = 100

dwell = []
for d in range(numDwells):
    dwell.append(int(round(random.expovariate(1.0/meanDur))))

dwell[0:5]


Out[3]:
[17, 48, 33, 7, 1]

Generate a fake trace using the distribution of dwells. We will decrease the noise after every step $\mu=0$ and $\sigma=1$.


In [15]:
start = 5
sigma = 2
stepSize = 2

trace = []
fit = []
for d in range(len(dwell)): # iterate through all dwells
    for p in range(dwell[d]): # iterate through each point in current dwell
        trace.append(random.gauss(start,sigma))
        fit.append(start)
    sigma -= 0.02
    start += 2
print(trace[0:5])


[1.1871301231130493, 3.243193866734834, 3.8125820551793397, 4.061838724985016, 7.427897484184329]

In [16]:
plot(trace);
xlabel("data point");
ylabel("random number");


Histogram dwell durations, confirm single exponential behavior


In [17]:
hist(dwell,bins=10, histtype='step');
title("histogram of dwell durations")
xlabel('dwell duration');
ylabel('counts');


Export the data


In [18]:
data=[]
data=[[i,trace[i]/30,trace[i]] for i in range(len(trace))]
np.savetxt('./passive_1.txt', data, delimiter = ' ')

data=[]
data=[[i,fit[i]] for i in range(len(trace))]
np.savetxt('./passive_fit_1.txt', data, delimiter = ' ')

In [19]:
plot(trace)
plot(fit)
xlim(0,200); ylim(0,25)


Out[19]:
(0, 25)

In [ ]: