Statistics/Chi-squared distribution: Difference between revisions
Content added Content deleted
(julia example) |
m (add total differences) |
||
Line 126: | Line 126: | ||
airportdata = [ 77 23 ; |
airportdata = [ 77 23 ; |
||
88 12; |
|||
79 21; |
|||
81 19 ] |
|||
expected_data = [ 81.25 18.75 ; |
expected_data = [ 81.25 18.75 ; |
||
81.25 18.75 ; |
|||
81.25 18.75 ; |
|||
81.25 18.75 ; ] |
|||
dtotal = sum((airportdata[i] - expected_data[i])^2/ expected_data[i] for i in 1:length(airportdata)) |
dtotal = sum((airportdata[i] - expected_data[i])^2/ expected_data[i] for i in 1:length(airportdata)) |
||
println("\nFor the airport data, χ2 is ", χ2(dtotal, 3), ", p value ", cdf_χ2(dtotal, 3)) |
println("\nFor the airport data, diff total is $dtotal, χ2 is ", χ2(dtotal, 3), ", p value ", cdf_χ2(dtotal, 3)) |
||
</syntaxhighlight>{{out}} |
</syntaxhighlight>{{out}} |
||
<pre> |
<pre> |
||
Line 163: | Line 163: | ||
32 5.233466447984725e-7 |
32 5.233466447984725e-7 |
||
For the airport data, χ2 is 0.08875392598443503, p value 0.7888504263193064 |
For the airport data, diff total is 4.512820512820512, χ2 is 0.08875392598443503, p value 0.7888504263193064 |
||
</pre> |
</pre> |
||
=={{header|Phix}}== |
=={{header|Phix}}== |