hakaru-CS4ZP6 / hakaru

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

Gamma in PDFs #37

Open sohraa3 opened 6 years ago

sohraa3 commented 6 years ago

http://www.math.wm.edu/~leemis/chart/UDR/UDR.html

Some of the distributions have the gamma function Γ() in their PDFs which seems like its computation involves infinite product. Is there a primitive built in function for it in hakaru? Examples:Error, Generalized gamma, Noncentral F

JacquesCarette commented 6 years ago

Yes. I think it's called gammaFunction. Search the prelude.

JacquesCarette commented 6 years ago

I am going to close this, as I believe the above comment should solve the problem. If not, then reopen and post something more concrete (as per what I just posted in #35)

sohraa3 commented 6 years ago

I looked in the prelude and the function is called gammaFunc . However, I get this error when I try to run the hakaru command on the following .hk program: return gammaFunc(5)

1.0 hakaru: TODO: evaluatePrimOp{GammaFunc} CallStack (from HasCallStack): error, called at haskell/Language/Hakaru/Sample.hs:382:5 in hakaru-0.6.0 AbnzUW5EnqjBuQmLn3LJbU:Language.Hakaru.Sample

sohraa3 commented 6 years ago

Should gammaFunc only be used for symbolic manipulation and not evaluating/sampling ?

JacquesCarette commented 6 years ago

I'm surprised that gammaFunc isn't implemented in the Sampler. It wouldn't be hard to do!

But it should definitely work for symbolic manipulation.

sohraa3 commented 6 years ago

I have put all the sampler functions that are for symbolic representations (not able to generate samples) in a file called symbolic.hk in stdlib. These are the ones that include infinite operations. I was wondering if I should put the ones that include gamma function in the same file since they can't be used for generating samples?

Later when gammaFunc gets implemented, they can be moved to their corresponding files.

JacquesCarette commented 6 years ago

Sure, sounds like a plan.