Re: Uniform to Exponential distributions?
"Hendrik Boom [email protected] [ocaml_beginners]" <[email protected]> Tue, 12 Apr 2016 21:55:39 +0000 (UTC)
| Newsgroups | gmane.comp.lang.ocaml.beginners |
|---|---|
| Message-ID | <[email protected]> |
On Thu, 07 Apr 2016 17:01:59 -0500, Douglas Lewit [email protected] [ocaml_beginners] wrote: > *let rec uniform_distribution ?upper_bound:(upprbnd = 1.0) size = if > size = > 0 then [ ] else ( Random.float upprbnd ) :: * > *( uniform_distribution ~upper_bound:upprbnd ( size - 1 ) ) ;;* > > The above is my implementation of the uniform probability distribution > defined on the interval, [0, 1]. ( The upper bound could be changed to > whatever you like of course, but if that optional argument is omitted > then by default it's going to have a value of 1... or technically, 1.0. > ) > > But what about other probability distributions in Ocaml? If I remember > correctly, there is some way to mathematically convert the uniform > distribution to any other distribution you want, but I don't remember > the details. Does anyone know about? ( I am specifically thinking of > the exponential distribution. ) > > > > Best, > > Douglas. > If x is uniform from 0 to 1, - log x follows an exponential distribution. The base of the logarithm determines how fast the exponential decays. -- hendrik