I am implementing a stochastic version of logistic equation in MATLAB. Keeping track of distribution of time it takes to for the population to reach 500 I experiment with various number of realisations to see how it affects the AVERAGE and the SPREAD of my distribution. Arbitrarily I chose to use 40 bins when plotting the histogram of distribution of time.
My question is: should the average time taken to reach 500 change if I increase the number of realisations? Why or why not? I suck at statistical analysis... It seems to me my average value is growing, but maybe it is nothing but some numerical error. Also my distribution seems to be skewed to the right (if compared to normal distribution), why is that? And should the spread of the distribution change if I increase realisations? It seems (maybe naively) that if you increase realisations you increase possibilities so the distribution should spread? But it seems wrong as, say, if you check the gender of a baby 1 or 1 000 000 times there is still 50% chance to find it is a girl.
Thanks, Aina.
Here is my code:
dt = 0.01; K = 1000; mu = 0.01; stepNumber = 1000; % Total number of steps M = 1000; % number of realisations: trie 10, 100, 1000 and 10000 t = linspace(0,stepNumber*dt,stepNumber); x(:,1) = ones(M,1)*10; % initial condition x(M,stepNumber) = 0; % define the size of the matrix % exactSolution = 1000*exp(10*t)./(99+exp(10*t)); Time taken to reach K/2 is around 0.46 timeTaken(M) = 0; for m = 1:M for step = 1:stepNumber-1 dW = randn*dt^(1/2); dx = (mu*K*x(m,step)-mu*x(m,step)^2)*dt + sqrt(mu*x(m,step)*(K+x(m,step)))*dW; % E-M method for logistic equation x(m,step+1) = x(m,step) + dx; if or(x(m,step+1)<0,x(m,step)+1>K/2) % finish when population reached K/2 break end end timeTaken(m) = step*dt; end figure hist(timeTaken,40)