フィルターのクリア

Generating random number from a pdf

4 ビュー (過去 30 日間)
Symeon Mattes
Symeon Mattes 2014 年 5 月 8 日
編集済み: Symeon Mattes 2014 年 5 月 12 日
Hi all,
I have bivariate probability density function f(x,y), which it doesn't follow any pdf from the known pdfs, and I would like to generate x, y random numbers that follow this pdf. Is there any way to do that in matlab?
Thanks in advance

回答 (1 件)

SK
SK 2014 年 5 月 8 日
編集済み: SK 2014 年 5 月 8 日
For simplicity, assume that the distribution has bounded support, i.e:
There is some Mx and My such that f(x,y) is zero for abs(x) > Mx and abs(y) > My.
One could probably do without this condition but it would a little more involved and in practice (unless you have a heavy-tailed distribution) it wont make much difference.
With this assumption, a general way to do it for any f(x,y) is as follows:
Let Mz = max(f(x,y)) over all x and y.
Now use rand to choose 3 numbers uniformly in the Box (-Mx < x < Mx) x (-My < y < My) x (z < Mz):
x = 2*Mx*(rand-0.5);
y = 2*My*(rand-0.5);
z = Mz*rand;
if z > f(x,y), reject x and y
otherwise add (x,y) to your set of generated points.
Best Regards,
Sandeep
  1 件のコメント
Symeon Mattes
Symeon Mattes 2014 年 5 月 11 日
編集済み: Symeon Mattes 2014 年 5 月 12 日
Thanks SK for your reply. This seem to work but because I have a huge amount of data and the grid is very dense is there any analytical method such as in 1D case, e.g. Using a sample PDF to generate random numbers ?

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

カテゴリ

Help Center および File ExchangeRandom Number Generation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by