create a stochastic variable

조회 수: 11 (최근 30일)
peter
peter 2011년 12월 19일
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
Walter Roberson
Walter Roberson 2011년 12월 19일
What "mistake" do you observe? Is there an error message?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Probability Distributions and Hypothesis Tests에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by