フィルターのクリア

Generate random variables with specified 2nd moment ?

1 回表示 (過去 30 日間)
Furqan Haider
Furqan Haider 2014 年 6 月 11 日
編集済み: Roger Wohlwend 2014 年 6 月 11 日
Hellow all,
I am using randn() to generate random variables. I know how to generate normal random variables with specific mean and variance. I am facing problem in generating these random variables with specific 2nd moment.
If random variables are:
x = randn(1,1000);
then 2nd moment is
momemt_2 = mean(x.^2);
Kindly help.

回答 (1 件)

Roger Wohlwend
Roger Wohlwend 2014 年 6 月 11 日
The second moment is the same as the variance of the random numbers!
>> x = randn(1,1000);
>> var(x)
ans =
0.9193
>> mean(x.^2)
ans =
0.9190
Your formula for the second moment assumes, however, that the mean of the time series x is zero.
  2 件のコメント
Furqan Haider
Furqan Haider 2014 年 6 月 11 日
I am sorry to accept your answer because its only applicable for random numbers with mean 'zero'. formula for variance is
variance = mean(x.^2) - (mean(x))^2;
whereas,
moment_2 = mean(x.^2);
Let me explain, in my case the mean is not zero.
Kindly help.
Roger Wohlwend
Roger Wohlwend 2014 年 6 月 11 日
編集済み: Roger Wohlwend 2014 年 6 月 11 日
You use the wrong formula for the second moment. Consult the internet. The second moment is the variance. Your formula just implies a mean of zero. If the mean is not zero you have to adjust the formula.
moment_2 = mean((x - mean(x)).^2)

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

カテゴリ

Help Center および File ExchangeTime Series についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by