create a stochastic variable

12 ビュー (過去 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 Center および File ExchangeProbability 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