From: Paul Sanchez Date: 2004-08-15T08:11:08+09:00 Subject: Re: Random variable library? Gavin Sinclair wrote: > On Friday, August 13, 2004, 5:41:22 PM, Mauricio wrote: > > >>On Fri, Aug 13, 2004 at 11:26:22AM +0900, Gavin Sinclair wrote: >> >>>The work I'm doing now doesn't strictly require, but would benefit from a >>>random number generator that: >>> - obeyed the distribution you want, with the parameters you want > > >>You can do that easily by taking a uniform random variable and feeding >>it into the distribution function you want. Actually that's the inverse of the distribution function. > Thanks for the tip. How do you write a distribution function? Every probability, statistics, and simulation text out there has descriptions and formulas for various distributions. However, not all distribution functions can be written in closed form or are invertible. >>> - spat out numbers between a given minimum and maximum > > >>like min + rand(max-min+1) ? > > > Yes, but what about: "give me a normal distribution between 0 and 10"? > That probably doesn't make sense without some extra parameters, but > they can be defaults/derived. Don't take this personally, but this is where I start getting nervous. A normal distribution is characterized _entirely_ by its mean and variance, and has an infinite range. If what you want falls between 0 and 10, then it ain't normal. > Then I'd like to be able to bias it as well, if that makes sense. So > you can have a "normal" distribution between 0 and 10, biased so that > the center is on 3 instead of 5. > > IF that makes sense... :/ Sorry, but no it doesn't. The normal distribution is symmetric about its mean. If you want an assymetric distribution (the term is "skewed", not "biased"), then once again it ain't normal. If you're going to do probability modeling, you need to understand the models or you're going to get in trouble. Somebody already suggested Ross's book, I'll put in my 2-cents for taking a look at "Simulation Modeling and Analysis" by Law & Kelton. It has a good review of prob & stats and a very comprehensive discussion of the theory and algorithms for random variate generation. I know that usenet posts can come across as harsh, and that's not my intention. Please accept this response as a strong caution rather than as a put-down. --paul