create a stochastic variable
Mostrar comentarios más antiguos
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
el 19 de Dic. de 2011
What "mistake" do you observe? Is there an error message?
Respuestas (0)
Categorías
Más información sobre Probability Distributions and Hypothesis Tests en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!