Skip to content

Instantly share code, notes, and snippets.

@Peranikov
Created April 19, 2016 03:42
Show Gist options
  • Save Peranikov/e0cb15ac46e59d0511a30a692f1d1787 to your computer and use it in GitHub Desktop.
Save Peranikov/e0cb15ac46e59d0511a30a692f1d1787 to your computer and use it in GitHub Desktop.
カイ二乗検定
h = {}
120.times {
r = rand(6)
h[r] = h[r].nil? ? 0 : h[r] += 1
}
p h
a = []
e = 20
h.each { |k, v|
a << ((v.to_f - e) ** 2) / e
}
p a
p sum = a.reduce(:+)
p sum <= 11.07 # 自由度5の有意水準5%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment