Last active
January 3, 2023 12:33
-
-
Save yoggy/425fea3fa99b5cfad1acde923687077a to your computer and use it in GitHub Desktop.
サイコロお年玉の検証コード。こちら参照 https://twitter.com/oskdgkmgkkk/status/1609832118913503234
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# see also... https://twitter.com/oskdgkmgkkk/status/1609832118913503234 | |
import random | |
import statistics | |
import math | |
count = 100000 | |
otoshidama_list = [] | |
for i in range(count): | |
otoshidama = 1 | |
for n in range(3): | |
saikoro = random.randint(1,6) # サイコロを3回振って掛け合わせた値 | |
otoshidama *= saikoro | |
otoshidama *= 100 # 100倍した値がお年玉の金額 | |
otoshidama_list.append(otoshidama) | |
print(f"otoshidama statistics.mean = {statistics.mean(otoshidama_list)}") # 平均 | |
print(f"otoshidama statistics.stdev = {statistics.stdev(otoshidama_list)}") # 標準偏差 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ python .\saikoro-otoshidama.py | |
otoshidama statistics.mean = 4286.459 | |
otoshidama statistics.stdev = 4068.370516276213 | |
$ python .\saikoro-otoshidama.py | |
otoshidama statistics.mean = 4303.84 | |
otoshidama statistics.stdev = 4061.944983424872 | |
$ python .\saikoro-otoshidama.py | |
otoshidama statistics.mean = 4278.415 | |
otoshidama statistics.stdev = 4059.84635316401 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment