From: Hugh Sasse Date: 2007-06-13T18:11:47+09:00 Subject: Re: comments needed for Random class On Wed, 13 Jun 2007, gga wrote: > Different distributions like random, uniform, etc. are excellent ideas > too. This is a standard naming conventions used in math (and pretty > common, for example, in the 3d industry, when you create a renderer). Problem with this is that gaussian distributions need the centre and variance specified. How about a method that given a block uses that block as a cumulative probability distribution funtion, so performing a 1:1 mapping from uniform input to non-uniform output? The existence of such a function would act as documentation on how to get nonuniform distributions. Then a collection of mapping functions could be provided to support this, Rayleigh, Poisson, Gaussian. A method to create a cumulative frequency table may be useful in Monte Carlo methods, and save people having to rewrite one each time. It would be very difficult to get this wrong if there were inject_with_index(initial_accumulator=nil) {|accumulator, value, index| ... } Then it would be (untested) f.inject_with_index(0){|a,v,i| cf[i] = a + v } Hugh