How to create a unit wiener process

조회 수: 5 (최근 30일)
vaggelis papasot
vaggelis papasot 2017년 8월 21일
편집: A G 2019년 1월 19일
I want to create a wiener process with mean = 0, and variance 1. I wrote the following script and get mean values close to zero but the variance is much smaller than 1. What can i do?
T = 1; N = 500;
dt = T/N;
dW = zeros(1,N); % preallocate arrays ...
W = zeros(1,N); % for efficiency
dW(1) = sqrt(dt)*randn; % first approximation outside the loop ...
W(1) = dW(1); % since W(0) = 0 is not allowed
for j = 2:N
dW(j) = sqrt(dt)*randn; % general increment
W(j) = W(j-1) + dW(j);
end
  댓글 수: 1
Torsten
Torsten 2017년 8월 21일
How do you calculate "variance" from the piece of code from above ?
Best wishes
Torsten.

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

답변 (1개)

A G
A G 2019년 1월 19일
편집: A G 2019년 1월 19일
That may be because You have to few points (only 500). Try with 1e6 for ex.
clearvars;
x(1)=0;
for i=1:1e6
dx(i)=2*randn()+0.1;
x(i+1)=x(i)+dx(i);
end
%%
plot(x)
mean(x)
var(x)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by