POV-Ray : Newsgroups : povray.off-topic : A small statistics question : Re: A small statistics question Server Time
14 Nov 2024 23:06:30 EST (-0500)
  Re: A small statistics question  
From: Tim Attwood
Date: 27 Nov 2007 05:50:07
Message: <474bf65f$1@news.povray.org>
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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.