0

im struggling with a potential easy to solve Problem. I have a dataset with 100k series of coin throws with varying k (throws). For each series I want to compute the the probability for each discrete n-state of getting head (sic!). E.g. 4 throws with the probabilities of c(.25,.5,.25,.75) to throw head. No I would like to calculate of how probable it is to get 0,1,2,3,4 -times head. I assume it is a different variant of a classical multinominal distribution. Is there a easy R command that I could apply or a formula ?

Greetings and Thanks! David

So far I just tried to create a function that hard calculates each case, like 3 throws with

prob = c(0.3,0.2,.5)

#only 1 no_sites = (1-.3)(1-.2)(1-.5)

#3 one_site = ((.3)(1-.2)(1-.5)) + ((1-.3)(.2)(1-.5)) + ((1-.3)(1-.2)(.5))

#3 two_sites = ((.3)(.2)(1-.5)) + ((1-.3)(.2)(.5)) + ((.3)(1-.2)(.5))

#1 three_sites = (.3)(.2)(.5)

sum(no_sites, one_site, two_sites, three_sites) = 1

Yet there should be a formula that is able to do so, without annoying hardcoded calculations.

  • What are the ranges of $k$ in your dataset? One would employ different algorithms depending on the magnitudes of the $k$ as well as on the associated probabilities. Two different solutions are provided at https://stats.stackexchange.com/questions/41247, for instance. – whuber Dec 13 '22 at 16:29
  • Thanks for the fast response. The size of the dataset is varying but I would just need the way of how to calculate this for a single row (meaning a single case). The size of k is varying and also the probabilities. So one case could be 10 throws with each throw having a specific probability for head (e.g. p1=.5, P2= .2,...., p10=0.5) and then i would like to calculate for each outcome (meaning 0 times head, 1, 2, ...,10 head) the probability. Which i assume is a multinominal problem. If i know of how to perform this for an individual case i will implement it for all cases. – David D Dec 13 '22 at 18:12
  • The function would be in the best case be something like function(n=#head,k=#throws,probabilities= vector of 10 probabilities for head){ return(Pn)}. – David D Dec 13 '22 at 18:14
  • The link I gave provides two algorithms for that. – whuber Dec 13 '22 at 20:19

0 Answers0