fslaborg / FSharp.Stats

statistical testing, linear algebra, machine learning, fitting and signal processing in F#
https://fslab.org/FSharp.Stats/
Other
205 stars 54 forks source link

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

Closed omaus closed 11 months ago

omaus commented 2 years ago

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?

bvenn commented 2 years ago

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

omaus commented 2 years ago

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.