Just 4 Fun - Wahrscheinlichkeiten

From StatWiki
Jump to: navigation, search

Some R code trying to figure out probabilities in Just 4 Fun

m=matrix(c(28,22,15,6,33,1,7,10,32,27,11,14,23,18,5,31,9,30,4,36,29,20,16,24,13,25,17,3,35,19,34,2,26,12,21,8), byrow=T, nrow=6)


cards=sort(c(rep(1:12,4),13:19))

ac=list(ac4=combn(cards, 4), ac3=combn(cards, 3), ac2=combn(cards, 2), ac1=matrix(1:19, nrow=1))

p = function(card, hand) { tcards[hand] = tcards[hand] - 1; tcards[card]/sum(tcards) }

ph = function(hand) { prob = tcards[hand[1]]/sum(tcards); if(length(hand) >= 2) { for(i in 2:length(hand)) prob = prob * p(hand[i], hand[1:i]) } ; prob }

sumAndProb = lapply(ac, function(comb) { apply(comb, 2, function(hand) c(sum(hand), ph(hand))) })


X = Summe von Karten.

P(X = 1..34)