Raydiant: custom probability distribution

November 7, 2009 at 11:11 am | Posted in Computer path | 1 Comment
Tags: , , , , , ,

It was very useful to be able to transform a constant normalized random distribution (same probability for every number between 0 and 1) into another one with personalized density distribution. This has been used to create materials choosing photon bouncing directions. Also used on objective depth of field effects of different types. This is the way I did it (and really enjoyed deducing this one):

  • Lets suppose we have a random generator with a density probability distribution : D(x)=1 for all 0<=x<1, and lets call ‘r’ the random numbers generated by this distribution.
  • We want to get another density probability distribution called E(x), of course definite integral of E(x) between x=0 and x=1 must be exactly 1.
  • Lets call ‘t’ to the random numbers generated by E(x) distribution.
  • I found the relationship between r and t is: r = definite integral of E(x) between x=0 and x=t. This is to say the area defined between E(x) and the horizontals axis between x=0 and x=t must be exactly r.
  • So just substitute your E(x) and solve the equation for t.
  • Applied example 1: find a random distribution that applied to a radius and given uniform random angles gives a homogeneous surface distribution at the plane inside a radius 1 circle:
    • Solution: t = sqrt(r/pi)
  • Applied example 2: find a random distribution that applied to a radius and given uniform random angles gives a homogeneous surface distribution at the plane inside a washer of radius r0 and r1 with r0<r1:
    • Solution: t = (-b+sqrt(b^2+2ar))/a with a = (2(r1-r0))/(r0+r1) and b = 1-(r1-r0)/(r0+r1)
  • As exercise: can you calculate ‘t’ for a random distribution which is completely lineal between x=0 and x=1?

These are some screen shoots of custom random distributions made by my wife María with the same Raydiant engine:

1 Comment »

RSS feed for comments on this post. TrackBack URI

  1. […] generator (= a normal one like for example the standard C function rand()). Just in case it is here. That’s all good but it uses integrals. So now and then, depending on the custom probability […]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.
Entries and comments feeds.

%d bloggers like this: