|
|
Depends on how efficient or accurate it needs to be.
A simple but inefficient way is to create a curve
function that represents the desired distribution,
generate two random numbers representing an
X,Y vector on the chart, then reject the points
above the curve, and use the X value of accepted
points as the random value.
An efficient but more complicated method is
to create a bar graph approximation of the
distribution curve, then "stack" the rectangles.
Then you can create an X,Y vector guaranteed
to be inside the stack of rectangles, then figure
the X offset of the rectangle based on Y and
use X + X offset @ Y as your random value.
Post a reply to this message
|
|