11-21-2010 06:10 PM
I need to simulate a random number generator which can generate numbers X with the probability distribution of
f (X) = ( 8X^2 + 1)*Exp ( -X^2 ).
This distribution is not a common distribution.
I have searched a lot, but I still do not know how to realize it.
Thanks a lot!
Solved! Go to Solution.
11-21-2010 06:33 PM
The distribution (or histogram) is shown in this figure
The random number what I expect is like this
How to simulate this random number?
11-21-2010 06:52 PM
The whole picture
11-22-2010 02:51 AM
Genererate a random number and insert it into your formula. 🙂
f (Random(X)) = ( 8X^2 + 1)*Exp ( -X^2 ).
The calculation and randomization can be found under Numeric menu.
/Y
11-22-2010 03:06 AM - edited 11-22-2010 03:11 AM
If you have a given distribution function, you can simulate matching random data by thesholding into the normalized integral of the function with a plain random number 0...1
See this example for more detail. (also look at the links)
In your case you need to decide on a useful range (e.g. -10...10), because your function goes to infinity on both sides. (Since you have negative values, you would also need to shift everything in the positive range (e.g. add 10) and then correct for the shift later.)
However, since your particular function is symmetric around 0, you can simply simulate the positive half (0..10), then switch sign with a probability of 0.5. Should not be too hard.
See how far you get. Good luck! 🙂
11-22-2010 08:53 AM
To Yamaeda,
Thanks a lot for your advice!
I tried but this simple program ran very slow. And the result seemed not to be what I expected.
11-22-2010 09:07 AM
To altenbach,
Thank you very much for your beautiful program!
I tried your method, but not succeed.
My difficulty now is how to change distribution based on X axis to Y axis.
Would you please help me?
My results is here
11-22-2010 10:30 AM - edited 11-22-2010 10:31 AM
Don't forget to index back into the original X array for correctly scaled data. Here's a simple example (LV 8.0):
Seems to work just fine. 😄
11-23-2010 02:33 AM
11-23-2010 03:10 AM