フィルターのクリア

how to calculate the probability of an event with monte carlo simulation

5 ビュー (過去 30 日間)
马里奥 马里奥
马里奥 马里奥 2020 年 12 月 11 日
回答済み: Sibi 2020 年 12 月 11 日
I am trying to calculate the probability that the wind speed exp (Yt) will be below 15 kmh for more than 10 days in a 100 day period but when I run the code it tells me this "Unable to perform assignment because the left and right sides have a different number of elements", Can anyone help me to solve this problem? Thanks in advance.
function mycode()
n=1000;
x=zeros(n);
y=zeros(100);
y(1)=1.5 ;
y(2)=1.5 ;
for i= 1:n
for t= 3:100
y(t)=0.6*y(t-1)+0.4*y(t-2)+normrnd(0,0.1,[1,1]);
end
x(i)=sum(y<1.427); %1.427 is the wind speed
mean(x>10)
return
end
  1 件のコメント
Rik
Rik 2020 年 12 月 11 日
This time I edited your question for you. Next time, please use the tools explained on this page (and apply the standard indentation) to make your question more readable.

サインインしてコメントする。

採用された回答

Sibi
Sibi 2020 年 12 月 11 日
mycode()
function mycode()
n=1000;
x=zeros(n,1);
y(1)=1.5 ;
y(2)=1.5 ;
for i= 1:n
for t= 3:100
y(t)=0.6*y(t-1)+0.4*y(t-2)+normrnd(0,0.1,[1,1]);
end
x(i)=sum(y<1.427);
end
mean(x>10)
return
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMonte-Carlo についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by