‎09-23-2010 02:27 PM
I would like to know if there is a VI that generate a set of random numbers according to any probability density function, probability mass function or histogram graph (this without knowing explicitly the function).
Thanks.
Solved! Go to Solution.
‎09-23-2010 03:49 PM
Not directly, but have a look at the VIs in the Mathematics>>Probability and Statistics>>Probability palette. There are a bunch of VIs that generate random numbers from known distributions by numerically computing the inverse CDF, and sampling from that using a uniform random number. You may be able to modify this code by providing your own "function" in place of the PDF in the CDF-inversion routine.
Alternatively, sampling from a histogram is pretty straightforward. Simply compute the cumulative histogram and then sample from that with a random number. Your friend here is the array function "Threshold 1D array".
‎09-23-2010 04:28 PM - edited ‎09-23-2010 04:34 PM
@Acoustics wrote:
I would like to know if there is a VI that generate a set of random numbers according to any probability density function, probability mass function or histogram graph (this without knowing explicitly the function).
If you have a given arbitrary distribution, you can simulate matching random data by thesholding into the normalized integral of the function with a plain random number 0...1.
This old post of mine should show you the general procedure and more details. (There is even an old example). Of course make sure that the desired function is all positive, of course. 😉
‎09-27-2010 07:04 AM
Thank you very much altenbach and GregS!