- 847 名前: ID:A3SYTEMe.net mailto: >>777
占い師の数を増やした問題 占い師が9人いて当たる確率はそれぞれ 0.55,0.60,0.65,0.70,0.75,0.80,0.85,0.90,0.95である。 コインの裏表を占ってみたところ 順に表,裏,表,裏,表,裏,表,裏,表 と答えた。 【表】が出る確率は? 数値を変えても計算できるように関数化。 calc <- function( p=1/2, # probability of head for coin toss cft=c(0.70,0.55), # credibility of fortune tellers > 0.5 ann=c(1,1) # announcement of fortune tellers 1:head, 0:tail ){ ncft=1-cft # negation of credibility # P[announcement|coin head] p1=prod(c(cft[ann==1],ncft[ann==0])) # P[announcement|coin tail] p2=prod(c(cft[ann==0],ncft[ann==1])) # P[coin head|announcement] p1*p/(p1*p + p2*(1-p)) } > calc(0.5,c(0.55,0.60,0.65,0.70,0.75,0.80,0.85,0.90,0.95),c(1,0,1,0,1,0,1,0,1)) [1] 0.8533449 >773の 0.70, 0.55 で表表のときは > calc(0.5,c(0.7,0.55),c(1,1)) [1] 0.7403846 [] - [ここ壊れてます]
|

|