フィルターのクリア

Draw random number from Normal distribution past a threshold value

2 ビュー (過去 30 日間)
Imner Renmi
Imner Renmi 2016 年 6 月 22 日
コメント済み: Roger Stafford 2016 年 6 月 23 日
Hi,
I want to draw values that are larger than 1.96 from a normal distribution. Anyone know how I can do this in matlab. Is there a built-in function to do this?
Note, of course I could use rejection sampling, but I want to draw a vector of 10000 values larger than 1.96 and I want to do this 5000 times. Using rejection sampling could be extremely time-consuming and I want to avoid that.
Thank you very much for your help.

採用された回答

Roger Stafford
Roger Stafford 2016 年 6 月 22 日
編集済み: Roger Stafford 2016 年 6 月 22 日
If your normal distribution without the truncation would have been mean = mu and standard deviation = sig, then do this:
r0 = normcdf(1.96,mu,sig); % The probability that sample is below 1.96
x = norminv((1-r0)*rand(1,n)+r0,mu,sig);
The value n is the number of desired samples. There is no rejection in this method. You should realize that this is no longer a normal distribution and its mean and standard deviation are different from 'mu' and 'sig'.
  2 件のコメント
Imner Renmi
Imner Renmi 2016 年 6 月 23 日
Thanks. One question, why do you have the "+r0" in the second line?
Roger Stafford
Roger Stafford 2016 年 6 月 23 日
This is to provide a statistically uniform distribution between r0 and 1 as input to the 'norminv' function so that it will generate only values starting at 1.96 and on higher in accordance with that end of the normal distribution. Try it and see.

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 6 月 22 日
The method of operation is not documented; it might use a rejection method internally.

Community Treasure Hunt

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

Start Hunting!

Translated by