All problems
Chi Square Goodness of Fit Statistic
Problem
The chi-square goodness-of-fit statistic is sum_i (observed_i - expected_i)^2 / expected_i.
Given the observed and expected counts, return the statistic.
Hint
Each squared deviation is scaled by the expected count.
Test cases
case 1
in: [[10,20],[15,15]]
expected: 3.3333333333333335
case 2
in: [[10,10,10],[10,10,10]]
expected: 0
case 3
in: [[30,10],[20,20]]
expected: 10
Starter codePython
def chi_square_goodness_of_fit_statistic(observed, expected):
# Your code here
pass3 test cases · run your code against them in the editor