For example, I have a p.d.f f(x) = 1/25 – x/1250 (from x = 0 to 50);
My question is that how to generate a set of values that satisfy the given p.d.f.
Please give an idea about how to implement in c++ or java.
Thanks so much.
For example, I have a p.d.f f(x) = 1/25 – x/1250 (from x =
Share
I don’t know about directly from a pdf, but you can convert a pdf to a cdf (by integrating) and then use inverse transform sampling. This assumes that you have a technique to generate a random number
uin[0, 1](e.g.Math.random()in Java).Once you have generated such a
u, find anxsuch thatcdf(x) = u. Thatxis the value that you want.