create a stochastic variable

12 visualizaciones (últimos 30 días)
peter
peter el 19 de Dic. de 2011
i would like to create the stochastic variable I which are part of the equation dx/dt=-x+I(t)
I(t)=0.075,t=t1
I(t)=-0.072,t=t2
which t1,t2 follow poisson distribution.
i follow the next M-file but there is a mistake!
h=0.0001;
t1=0;
k=0;
while t1<0.3
k=k+1;
t1=t1-0.015*log(rand(1));t1s(k)=t1;
end
t2=0;
c=0;
while t2<0.3
c=c+1;
t2=t2-0.015*log(rand(1)); t2s(c)=t2
end
t=0;
z=0;
while t<0.3
z=z+1;
t=t+h;
ts(z)=t;
end
I=0;
for l=1:z
for j=1:c
for i=1:k
if abs(ts(l)-t1s(i))<1e-5
I=I+0.075*h;
elseif abs(ts(l)-t2s(j))<1e-5
I=I-0.072*h;
end
end
end
end
  1 comentario
Walter Roberson
Walter Roberson el 19 de Dic. de 2011
What "mistake" do you observe? Is there an error message?

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Probability Distributions and Hypothesis Tests en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by