Talk:Statistics/Chi-squared distribution: Difference between revisions

m
(Cumulative pdf fomula.)
 
 
(11 intermediate revisions by 3 users not shown)
Line 4:
According to Wikipedia, for the case k = 2, this formula reduces to F(x; 2) = 1 - exp(-x/2). But for values of x from 0 to 10, the only way I can get this simple formula to agree with the one in the task description is if I halve 'x' first before applying the latter. Here's the Wren code I have so far in case I'm missing something or have done something silly:
 
<syntaxhighlight lang="ecmascriptwren">import "./math" for Math
import "./fmt" for Fmt
 
Line 96:
</pre>
As there's some heavy math here, a Julia or Python example to check against would be useful. --[[User:PureFox|PureFox]] ([[User talk:PureFox|talk]]) 09:46, 2 October 2022 (UTC)
 
: I haven't looked closely at this one, yet. But it's also worth asking whether the wikipedia entry is using notation in the way we expect
 
: That said, there's a small j wiki [[j:Essays/Chi_Squared_CDF|entry]] on this subject which claims to include an example which matches "calculated results against values from the [[WikiPedia:Handbook_of_Mathematical_Functions|Handbook of Mathematical Functions]] by Abramowitz and Stegun, Table 26.8." --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 09:59, 2 October 2022 (UTC)
 
Well, the Wikipedia formula looks correct to me. If we substitute k = 2 in their formula for the pdf (which agrees with the task description so there's no notational difference here) we get (since gamma(1) = 1):
 
:: f(x; 2) = exp(-x/2) / 2
 
and if we integrate that we get:
 
:: F(x; 2) = 1 - exp(-x/2)
 
[[User:PureFox|PureFox]] ([[User talk:PureFox|talk]]) 10:48, 2 October 2022 (UTC)
::: This tells us that that notation in the task description matches that notation in the wikipedia entry. --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 11:11, 2 October 2022 (UTC)
 
:: I am right now also having trouble with the cdf formula at the level of the incomplete Gamma I am using. I think I may have to calculate it in 2 or 3 different ways depending on x and k. --[[User:Wherrera|Wherrera]] ([[User talk:Wherrera|talk]]) 18:33, 2 October 2022 (UTC)
 
:: Well, I gave up getting incomplete gamma to work accurately with just two methods, and am just going to call the one in the BigFloat MPFR library, which I think uses six or more methods for incomplete gamma based on the a and x values. --[[User:Wherrera|Wherrera]] ([[User talk:Wherrera|talk]]) 19:43, 2 October 2022 (UTC)
 
:: I did find that the two formulas I had to calculate the last summation used 2 different meanings for x which had things overly complicated and incorrect. Fixed. --[[User:Wherrera|Wherrera]] ([[User talk:Wherrera|talk]]) 01:22, 3 October 2022 (UTC)
 
Thanks for correcting the cumulative pdf formula. I'm pleased we didn't have to resort to the ''mpfr_gamma_inc'' function as it's not one I've wrapped in Wren-GMP. --[[User:PureFox|PureFox]] ([[User talk:PureFox|talk]]) 09:48, 3 October 2022 (UTC)
9,492

edits