Stochastic differential equation Gompertz plotting a graph

3 ビュー (過去 30 日間)
George Hendry
George Hendry 2022 年 2 月 26 日
コメント済み: Torsten 2022 年 2 月 26 日
I have come stuck when entering the model which has a log(x(t) into my code and when looking at the Weiner process deciding what my value of dt would need to be. Because at the moment when producing the graph using this code it is blank and I don't understand why that is happening when I introduce the log(x(t)) as I get a graph when it isn't intrdocued.I have coded
th = 0.1;
mu = 0.3;
sig = 0.1;
dt = 1e-1 ;
t = 0:dt:50; % Time vector
x = zeros(1,length(t)); % Allocate output vector, set initial condition
rng(1); % Set random seed
for i = 1:length(t)-1
x(i+1) = x(i)+th*x(i)*dt-mu*x(i)*dt-mu*log(x(i))*dt+sig*sqrt(dt)*randn;
end
figure;
plot(t,x);

採用された回答

Alan Stevens
Alan Stevens 2022 年 2 月 26 日
You have x(1) = 0, so log(x(1)) is -Inf, which means that subsequent values of x will be NaNs.
  2 件のコメント
George Hendry
George Hendry 2022 年 2 月 26 日
Thanks I'm not sure what the value of the dt is this model as I have seen various differing values of dt due to the weiner process do you have any views on what it should be?
Torsten
Torsten 2022 年 2 月 26 日
It's the "Wiener Process", not the "Weiner Process".

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by