Re: Efficient Sampling of a PDF
- From: "Greg Heath" <heath@xxxxxxxxxxxxxxxx>
- Date: 13 Jun 2006 07:24:59 -0700
JRP wrote:
If I have a probability density function (PDF) and want to pick 'N'
random samples that will be distributed according to the distribution
described by my PDF, what is an efficient way to do this?
My PDFs are not simple gaussians or uniform distributions. They can
be very complex.
Right now what I do is just generate a bunch of data points, far more
than 'N', randomly mix them up in a vector, then randomly select 'N'
of them. For example, if my PDF has a value PDF(x0) = 0.1 and PDF(x1)
= 0.04, I would generate 100 x0 values and 4 x1 values to put into my
'sampling vector'. In general, if I have PDF(xi) = yi, where yi is of
precision to the hundredth decimel place, then I create 100*yi values
of xi to go into my 'sampling vector'. Later I randomly mix up the
components of this vector and randomly choose 'N' value from it.
However, this seems rather inefficient!!! Especially if I want higher
precision and want to represent values such as PDF(xi) = 0.0002...
Anyone have a more intelligent way of sampling an arbitrary PDF?
Integrate to obtain the CDF. Randomly choose CDF values in (0,1).
Obtain the corresponding values of x via the inverse CDF.
Hope this helps.
Greg
.
- Follow-Ups:
- Re: Efficient Sampling of a PDF
- From: Peter Boettcher
- Re: Efficient Sampling of a PDF
- References:
- Efficient Sampling of a PDF
- From: JRP
- Efficient Sampling of a PDF
- Prev by Date: Re: update struct handles in a GUI
- Next by Date: Re: cell array concatenation
- Previous by thread: Efficient Sampling of a PDF
- Next by thread: Re: Efficient Sampling of a PDF
- Index(es):
Relevant Pages
|