高校数学の質問スレ(医者・東大卒専用) Part438 (899レス)
上
下
前
次
1-
新
44
: 2024/08/15(木)10:18
ID:5ggTekS4(1/2)
AA×
>>1
[240|
320
|
480
|
600
|
100%
|
JPG
|
べ
|
レス栞
|
レス消
]
44: [sage] 2024/08/15(木) 10:18:26.54 ID:5ggTekS4 bWin <- function(x){# 1 beats 3, 3 beats 2, 2 beats 1 if(length(unique(x))!=2 ) return(0) # no winner u=sort(unique(x)) if(all(u==c(1,2))) return(sum(x==2)) # how many winners who won by 2 if(all(u==c(2,3))) return(sum(x==3)) # how many winners who won by 3 if(all(u==c(1,3))) return(sum(x==1)) # how many winners who won by 1 } janken.till.winner.sim <- function(n){ # janken till someone wins if(n<2) return(NA) x=sample(1:3,n,replace = TRUE) # janken by n people count=1 # counter of janken game while(bWin(x)==0){ # if draw try again x=sample(1:3,n,replace = TRUE) # janken again till someone win count=count+1 } c(bWin(x),count) # return how many winners and counter } janken.till.chamipion.sim <- \(n){ re=janken.till.winner.sim(n) count=re[2] winner=re[1] while(winner>1){ re=janken.till.winner.sim(n) count=count+re[2] winner=re[1] } count } res=replicate(1e5,janken.till.chamipion.sim(9)) summary(res) hist(res,col=2,breaks='scott',freq=FALSE,xlab='count',main='') BEST::plotPost(res,showMode = TRUE,breaks='scott') http://rio2016.5ch.net/test/read.cgi/math/1723152147/44
上
下
前
次
1-
新
書
関
写
板
覧
索
設
栞
歴
あと 855 レスあります
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
AAサムネイル
ぬこの手
ぬこTOP
0.029s