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 [6]:
dwell = []
meanDur = 24
numDwells = 50
dwell = []
for d in range(numDwells):
dwell.append(int(round(random.expovariate(1.0/meanDur))))
dwell[0:5]
Out[6]:
Generate a fake trace using the distribution of dwells. We will decrease the noise after every step $\mu=0$ and $\sigma=1$.
In [13]:
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.035
start += 2
print(trace[0:5])
In [14]:
plot(trace);
xlabel("data point");
ylabel("random number");
Histogram dwell durations, confirm single exponential behavior
In [15]:
hist(dwell,bins=10, histtype='step');
title("histogram of dwell durations")
xlabel('dwell duration');
ylabel('counts');
Export the data
In [16]:
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 [21]:
plot(trace)
plot(fit)
Out[21]:
In [ ]: