create a stochastic variable
11 views (last 30 days)
Show older comments
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 Comment
Answers (0)
See Also
Categories
Find more on Probability Distributions and Hypothesis Tests in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!