Skip to content

Commit

Permalink
Merge 2f121b9 into edcfacb
Browse files Browse the repository at this point in the history
  • Loading branch information
ochaochaocha3 committed Jul 21, 2019
2 parents edcfacb + 2f121b9 commit f6c1d6e
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions spec/rgrb/plugin/dice_roll/generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,11 @@
end
end

# 100000d101 の出目に偏りがないことを
# 100000d100 の出目に偏りがないことを
# カイ二乗検定で確かめる
#
# 面数が 101 なのは、自由度が面数 - 1 で、カイ二乗分布表には
# 切りの良い 100 しか載っていないから
it '出目に偏りがない' do
rolls = 100_000
sides = 101
sides = 100
freq = Array.new(sides, 0)
values = generator.dice_roll(rolls, sides).values

Expand All @@ -109,9 +106,9 @@
expected_count = rolls.to_f / sides
chi2 = freq.
map { |count| (count - expected_count)**2 / expected_count }.
reduce(0, :+)
reduce(0, &:+)

expect(chi2).to be <= 140.169 # 自由度 100、有意水準 0.5%
expect(chi2).to be <= 170.798 # 自由度 99、有意水準 0.001%
end
end

Expand Down

0 comments on commit f6c1d6e

Please sign in to comment.