FSharp.Stats icon indicating copy to clipboard operation
FSharp.Stats copied to clipboard

[Discussion] `Distributions.Continuous.ChiSquared.PDFLn`: unclear function

Open omaus opened this issue 2 years ago • 2 comments

Describe what you wanna discuss about The function (role) of the function Distributions.Continuous.ChiSquared.PDFLn is unclear. It is certainly not the ln result of ChiSquared.PDF since

Distributions.Continuous.ChiSquared.PDFLn 2. 4.7
// val it: float = -9.497437491

but

Distributions.Continuous.ChiSquared.PDF 2. 4.7 |> log
// val it: float = -3.043147181
// `log` is `System.Math.Log` which is a function/method to calculate ln of a given value

Triple-slash documentation states that it Computes the logarithm of probability density function. which should be the same as the last code block but it is not. So, what actually DOES this function?

omaus avatar Jun 22 '22 19:06 omaus

One possible approximation of the PDF is via the gamma function (p. 410). As defined in 26.4.19 it is: PDF = incomplete gamma / gamma while v=2a and x²=2x. That would be PDFLn = incGammaLn - gammaLn, definetly worth a shot :+1:

abramowitz_and_stegun p 410 and p 470

bvenn avatar Jun 27 '22 18:06 bvenn

One possible approximation of the PDF is via the gamma function (p. 410). As defined in 26.4.19 it is: PDF = incomplete gamma / gamma while v=2a and x²=2x. That would be PDFLn = incGammaLn - gammaLn, definetly worth a shot 👍

Will give it a try.

omaus avatar Jun 27 '22 19:06 omaus