Re: Sampling from arbitrary probability distribution
- From: Jerzy Karczmarczuk <karczma@xxxxxxxxxxxxxxx>
- Date: Thu, 07 Jul 2005 09:48:40 +0200
Just d' FAQs wrote:
Shaobo Hou wrote:
I need to sample lots of points from an arbitrary probability distribution but I would like to sample more points from area of high probability, like using monte carlo method for sampling illuminations for rendering purpose.
I can compute the probability (or something similar to the true probabiility) at any point in the space but I am not sure what sort algorithm I should use.
If we can write down an expression for the distribution, and if that expression is, invertible, then we can create that distribution by functional transformation of a uniform distribution. With empirical distributions, which seem more likely here, it's more difficult.
Well, actually you must have the INTEGRATED (cumulative) probability distribution, then its functional inversion gives you the transformation from a uniform distribution to any.
But if your prob. distr. is lousy, don't despair. You can do it numerically, choose your precision/number of sampling bins, then sample the distribution, then compute its integral by incremental summing, and then "invert" the function by scanning your array. (Details if you wish, privately). This is not so superb algorithm, since its complexity - for ONE generated number - is proportional to the number of sampling bins, but it is precise, and simple to implement. Even if you don't have any mathematical function, but just an experimental distribution (obviously already discretized).
Another trick, *very* often used if your distribution is finite within a finite interval: use the rejection method. Map the distribution (not integrated) into a unit square; it will be a functional profile inside. Choose uniformly a random point on the x axis, and then choose another point between 0 and 1, also uniformly. If the point falls under the prob. distr. curve, then accept it, otherwise reject.
If the distribution varies wildly, the efficiency of the method becomes bad, but there are ways, such as antithetic variables, etc., which permit to optimize it.
Jerzy Karczmarczuk .
- Follow-Ups:
- Re: Sampling from arbitrary probability distribution
- From: Matt Pharr
- Re: Sampling from arbitrary probability distribution
- From: Shaobo Hou
- Re: Sampling from arbitrary probability distribution
- References:
- Sampling from arbitrary probability distribution
- From: Shaobo Hou
- Re: Sampling from arbitrary probability distribution
- From: Just d' FAQs
- Sampling from arbitrary probability distribution
- Prev by Date: Closest point on 2D triangle from 2D point
- Next by Date: Searching an algorithm to detect if a point is within a polygonal
- Previous by thread: Re: Sampling from arbitrary probability distribution
- Next by thread: Re: Sampling from arbitrary probability distribution
- Index(es):
Relevant Pages
|