Re: [問卦] 13顆骰子要骰幾次才可以累積到13000點消失
: : 初學者來ㄌ
: : 我模擬1000次就跑好久
: : 是因為我用13顆骰子慢慢骰嗎?
: : 接下來要弄次數分配怎麼寫啊= =
: from collections import defaultdict
: dd = defaultdict(int)
: # 每次 result 直接放入 dd
: dd[result] += 1
: print(dd) # 次數分配結果
: 然後,已經 2017 年了,快改用 python 3 好嗎,別再用 2 了。
: : 不奢望畫圖了= =
: pyplot 或是 matplotlib 都能夠做到,加油,好嗎?
Python 模擬一萬次出來也是一樣歐
https://i.imgur.com/2HjGhzA.png
不過這個有掉到280次以下的
# python3
import numpy as np
import seaborn as sns
def roll_die():
points_total = 0
cutoff = 0
while points_total < 13000:
points_total += np.sum(np.random.randint(1, 7, 13))
cutoff += 1
return cutoff
results = np.array([roll_die() for i in range(10000)])
sns.distplot(results, kde=False)
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 68.71.180.136
※ 文章網址: https://www.ptt.cc/bbs/Gossiping/M.1514221939.A.D84.html
→
12/26 01:12, , 1F
12/26 01:12, 1F
推
12/26 01:12, , 2F
12/26 01:12, 2F
推
12/26 01:13, , 3F
12/26 01:13, 3F
推
12/26 01:13, , 4F
12/26 01:13, 4F
推
12/26 01:14, , 5F
12/26 01:14, 5F
噓
12/26 01:31, , 6F
12/26 01:31, 6F
推
12/26 01:37, , 7F
12/26 01:37, 7F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 10 之 10 篇):