Re: [問卦] 13顆骰子要骰幾次才可以累積到13000點

作者: grapherd (GrD)   2017-12-26 00:41:22
※ 引述《p2p8ppp (給我錢)》之銘言:
: https://imgur.com/7cLC5iT
: 初學者來ㄌ
: 我模擬1000次就跑好久
: 是因為我用13顆骰子慢慢骰嗎?
: 接下來要弄次數分配怎麼寫啊= =
from collections import defaultdict
dd = defaultdict(int)
# 每次 result 直接放入 dd
dd[result] += 1
print(dd) # 次數分配結果
然後,已經 2017 年了,快改用 python 3 好嗎,別再用 2 了。
: 不奢望畫圖了= =
pyplot 或是 matplotlib 都能夠做到,加油,好嗎?
: ※ 引述《abc2090614 (casperxdd)》之銘言:
: : 根據模擬10,000次的結果
: : 眾數是286次,大多落在280~290次之間
: : https://i.imgur.com/lEydnTk.png
: : 大家算對了嗎
: :
: : # R
: : library(ggplot2)
: : rolls <- integer(10000)
: : for(trial in 1:10000){
: : i <- 0
: : points <- 0
: : while(points < 13000) {
: : points <- sum(sample(6, 13, replace=TRUE)) + points
: : i <- i + 1
: : }
: : rolls[trial] <- i
: : }
: : df <- data.frame(num_rolls = rolls)
: : p <- ggplot(df, aes(x=num_rolls)) + geom_histogram(binwidth=1) + theme_bw()
: : p
: :
作者: hh800315 (lonetime)   2017-12-26 00:42:00
講白話文 謝謝
作者: dawsoman (裝死)   2017-12-26 00:44:00
————-開放樓下驗算—————

Links booklink

Contact Us: admin [ a t ] ucptt.com