Random generator for given distribution function
I need to write a random generator, not for normal distribution only but for any distribution function.
That function can be a black-box distribution function, or that can be a table [ x | f(x) ].
For those not familiar with this term, distribution function is f(x) that returns the posibility of that the radmon number is lesser than x. f(-inf) = 0, f(+inf) = 1, x > y => f(x) >= f(y).
[417 byte] By [
@miryaa] at [2007-9-30 1:12:33]

I don't have my stats text books with me, but Google is your friend! :-)
This looks like what we coverd in stats class:
http://www.mathworks.com/access/helpdesk/help/toolbox/stats/prob_di7.shtml
[quote]
Inversion
The inversion method works due to a fundamental theorem that relates the uniform distribution to other continuous distributions.
If F is a continuous distribution with inverse F^-1, and U is a uniform random number, then F^-1(U) has distribution F.
So, you can generate a random number from a distribution by applying the inverse function for that distribution to a uniform random number. Unfortunately, this approach is usually not the most efficient.
[/quote]
How do you get a random number from a uniform distribution? Easy: with java.util.Random, or some other java math package (I like http://hoschek.home.cern.ch/hoschek/colt/index.htm).
The first link details some other methods, as will most stats text books.
You can use the 'rejection' method.
1) Create the cumulative pdf by integrating the pdf.
2) Select a value at random between your min and max 'x' value (call it v).
3) Select a uniform value between 0 and 1. If this is greater than the cumulative pdf evaluated at 'v' then start again from step 2 else accept v as your random value.
For more complete info. see 'Numerical recipes in C' . This is available on line - search using Google.