Statistics/Chi-squared distribution: Difference between revisions

m
add total differences
(julia example)
m (add total differences)
Line 126:
 
airportdata = [ 77 23 ;
88 12;
79 21;
81 19 ]
 
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))
 
println("\nFor the airport data, diff total is $dtotal, χ2 is ", χ2(dtotal, 3), ", p value ", cdf_χ2(dtotal, 3))
</syntaxhighlight>{{out}}
<pre>
Line 163:
32 5.233466447984725e-7
 
For the airport data, diff total is 4.512820512820512, χ2 is 0.08875392598443503, p value 0.7888504263193064
</pre>
 
 
 
 
=={{header|Phix}}==
4,107

edits