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]:
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])
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]:
In [ ]: