hakaru-CS4ZP6 / hakaru

A probabilistic programming language
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

prob2nat #53

Closed sohraa3 closed 6 years ago

sohraa3 commented 6 years ago

http://www.math.wm.edu/~leemis/chart/UDR/PDFs/Error.pdf

Is there a way to check if a prob is representable as a nat? For example nat(2.0) = 2. I need this for implementing a sampler for the error distribution(linked above). The 3rd parameter c is a prob but is used as an exponent for a real in the pdf. The way I was thinking to solve this was to check if c is a natural number. If yes, then convert it to nat and use it as an exponent for a real (using (^)). If no, then the base of the exponent has to be non-negative(prob).

All of this takes place in the exponent of e in the numerator of the pdf.

JacquesCarette commented 6 years ago

The normalization given at https://en.wikipedia.org/wiki/Generalized_normal_distribution is much easier to deal with. You won't run into the above problems. Of course, that will also change the exact relations, but in ways that aren't so hard to figure out... it's all a straightforward change of variables.

sohraa3 commented 6 years ago

I am not sure what is meant by normalization. The wikipedia link, talks about two distributions; Generalized Normal (version 1) and (version2). I am guessing that version 1 is the one given in the leemis document, even though their pdfs looks different.

JacquesCarette commented 6 years ago

I meant version 1. And by normalization, I mean that the one on wikipedia uses beta, which I think corresponds to 2/c in the Leemis version. So it's a different presentation of the same thing, but with variables arranged differently.