Uniform to Exponential distributions?
"Douglas Lewit [email protected] [ocaml_beginners]" <[email protected]> Thu, 7 Apr 2016 17:01:59 -0500
| Newsgroups | gmane.comp.lang.ocaml.beginners |
|---|---|
| Message-ID | <CAM0XMJS29SHexwpHKG6CDeZhFu+mZPYqokSvwRDABfA7rE32Qw@mail.gmail.com> |
*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. ) Does Ocaml have builtin support for various probability distributions? Or is it left up to the Ocaml programmer to figure those out on his own? Thanks for the information. Best, Douglas.