Re: Efficient Sampling of a PDF




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

.



Relevant Pages

  • Efficient Sampling of a PDF
    ... If I have a probability density function (PDF) and want to pick 'N' ... random samples that will be distributed according to the distribution ... precision to the hundredth decimel place, ... of xi to go into my 'sampling vector'. ...
    (comp.soft-sys.matlab)
  • Re: Efficient Sampling of a PDF
    ... random samples that will be distributed according to the distribution ... of xi to go into my 'sampling vector'. ... Anyone have a more intelligent way of sampling an arbitrary PDF? ... Randomly choose CDF values in. ...
    (comp.soft-sys.matlab)
  • Re: Help with multivariate distribution
    ... distribution which you work on. ... The KS test only looks at the empirical cdf of the distribution. ... beta, X has to be between 0 and 1, and of those, how do you ... I can fit a beta pdf to a histogram of the data using optimisation ...
    (sci.stat.math)
  • Re: What is a quick way to sample from a triangle
    ... My default method for sampling any distribution fis to use the ... cumulative distribution function F(i.e. the integral of the PDF, ... The CDF maps the domain of your PDF onto the interval. ...
    (comp.soft-sys.matlab)
  • MLE with custom distribution
    ... skew-normal distribution. ... I created the pdf and the cdf of this ...
    (comp.soft-sys.matlab)