I need ziggurat matlab code to draw

Hello, i need a ziggurat matlab code to generate somehing like this
i'm working with (gauss) random number generator ziggurat rejection method

 採用された回答

Chunru
Chunru 2022 年 5 月 17 日
編集済み: Chunru 2022 年 5 月 17 日

0 投票

where is a normalizing constant that we can ignore.
x = [0:.1:2]
x = 1×21
0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 1.0000 1.1000 1.2000 1.3000 1.4000 1.5000 1.6000 1.7000 1.8000 1.9000 2.0000
y = 1/(2*pi)*exp(-x.^2/2);
stairs(x, y, 'b');
hold on
xl = xlim;
plot([xl(1)*ones(1, length(x)-1); x(2:end)], [y(2:end); y(2:end)], 'b')
% longer tais
x = [0:.1:4]
x = 1×41
0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 1.0000 1.1000 1.2000 1.3000 1.4000 1.5000 1.6000 1.7000 1.8000 1.9000 2.0000 2.1000 2.2000 2.3000 2.4000 2.5000 2.6000 2.7000 2.8000 2.9000
y = 1/(2*pi)*exp(-x.^2/2);
plot(x, y, 'r')

8 件のコメント

Mar One
Mar One 2022 年 5 月 17 日
編集済み: Mar One 2022 年 5 月 17 日
do you have a code with the tail ? basically the tail when i=0
i'm working with (gauss) random number generator ziggurat rejection method
Chunru
Chunru 2022 年 5 月 17 日
I don't have the equation for the so called ziggurat method. I am only helping the plotting part here. Do you have further info on the ziggurat rejection method?
Mar One
Mar One 2022 年 5 月 17 日
編集済み: Mar One 2022 年 5 月 17 日
Yes this is a simple resume of what ziggurat method is: https://blogs.mathworks.com/cleve/2015/05/18/the-ziggurat-random-normal-generator/
Chunru
Chunru 2022 年 5 月 17 日
See the update above.
Mar One
Mar One 2022 年 5 月 17 日
I need a Matlab code from this principal
Chunru
Chunru 2022 年 5 月 17 日
The matlab code is given above. What else do you need?
Mar One
Mar One 2022 年 5 月 17 日
Mar One
Mar One 2022 年 5 月 17 日
from this above

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLinear Algebra についてさらに検索

製品

リリース

R2022a

質問済み:

2022 年 5 月 17 日

コメント済み:

2022 年 5 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by