[simulations] added uniform distribution

This commit is contained in:
2020-12-28 20:36:59 +01:00
parent a50cc4ff7b
commit d50b0be404
5 changed files with 92 additions and 37 deletions

View File

@@ -1,8 +1,8 @@
n = 10000;
lambda = 50.0; % event rate
t = exprnd(1.0/lambda, n, 1); % exponentially distributed random numbers
m = mean(t); % mean time interval
s = std(t); % corresponding standard deviation
fprintf('Generated n=%d exponentially distributed random time intervals\n', n);
fprintf(' with rate=%.0fHz (-> mean=%.3fs, std=%.3fs)\n', lambda, 1.0/lambda, 1.0/lambda);
fprintf('Measured mean=%.3fs, std=%.3fs\n', m, s);
n = 200; % number of time intervals
rate = 50.0; % event rate
t = exprnd(1.0/rate, n, 1); % exponentially distributed intervals
m = mean(t); % mean time interval
s = std(t); % corresponding standard deviation
fprintf('Generated n=%d random time intervals with rate=%.0fHz:\n', n, rate);
fprintf(' Expected mean interval=%.3fs, std=%.3fs\n', 1.0/rate, 1.0/rate);
fprintf(' Measured mean interval=%.3fs, std=%.3fs\n', m, s);

View File

@@ -1,3 +1,3 @@
Generated n=10000 exponentially distributed random time intervals
with rate=50Hz (-> mean=0.020s, std=0.020s)
Measured mean=0.020s, std=0.020s
Generated n=200 random time intervals with rate=50Hz:
Expected mean interval=0.020s, std=0.020s
Measured mean interval=0.020s, std=0.019s

View File

@@ -0,0 +1,16 @@
n = 10000; % number of action potentials
T = 100.0; % total time interval
spikes = sort(T*rand(n, 1)); % sorted times of action potentials
isis = diff(spikes); % interspike intervals
rate = n/T; % firing rate
misi = mean(isis); % mean interspike interval
sisi = std(isis); % and standard deviation
fprintf('firing rate = %.1fHz\n', rate);
fprintf(' mean ISI = %.1fms\n', 1000.0*misi); % inverse of rate
fprintf(' std ISI = %.1fms\n', 1000.0*sisi); % same as mean
hist(1000.0*isis, 50); % exponential distribution
xlabel('ISI [ms]');
ylabel('count');

View File

@@ -0,0 +1,3 @@
firing rate = 100.0Hz
mean ISI = 10.0ms
std ISI = 10.0ms