Reputation: 33
Say I have n balls, x blue and (n-x) red. If I draw the balls randomly one at a time, what is the probability of having a series of k blue balls drawn in a row?
Context, I am simulating golf rounds. I am curious what the probability is of having a streak of k+ birdies+ in a row. I am using a multinomial simulator to sim at the round level rather than hole by hole. So I am wanting to use the fact that I had x birdies+ out of 18, figure out the probability of a k+ streak existing, then just stick that probability into a binomial to record success/failure of achieving streak. Right now I am just using the following function in R and it is not very fast (x is a vector of x+ birdies, one element for each player being simulated)
golf_streak <- function(x,k){
test <- lapply(x, function(i) {sample(c(rep(1, i), rep(0, 18 - i))) })
t <- lapply(test, rle)
as.numeric(sapply(t, function(rl) any(rl$lengths[rl$values == 1] >= k)))
}
x-posted here https://math.stackexchange.com/questions/4719474/probability-of-sequence-with-binary-data
I still haven't found an exact solution, but I found a very efficient computation solution. For each value of k, I run my above code n times and store the number of successes for a very large n. This provides a fairly good estimate for the probability of a streak. I save these values in a csv to be uploaded as a data.frame and then join that table to get the probabilities of a streak. So I no longer need to compute on the fly. Would still be nice to get an exact answer though.
Upvotes: 0
Views: 143