Probability of getting $n$ heads from multiple coins each tried several times Assume we have 10 coins, and each has its own probability of getting a head. We toss each coin a different number of times, say 10 times for the first coin, 15 times for the second coin, and so on. What is the probability of getting a head at least once in at least 5 different coins?
My thinking is that the probability for getting at least one head from a coin tossed $k$ times with a head probability of $p$ can be computed from the binomial distribution. Example R code:
sum(dbinom(1:k, k, p))

But I don't know how to generalize it to multiple coins mathematically or computationally.
 A: Let the number of coins be $K$ and the probability to toss head with $i$-th coin be $p_i$, so that the corresponding probability to toss $N_i$ tails is $(1-p_i)^{N_i}\equiv Q_i$.
Then assuming that $Q_i\ne0\ (\iff p_i\ne1)$ the probability that at least $k$ coins at least once showed up head is:
$$
1-\prod_i Q_i\sum_{S\in\mathbb P({\cal K})}^{|S|<k}\prod_{s\in S}\frac{1-Q_{s}}{Q_{s}},
$$
where the sum runs over all subsets $S=(s_1,s_2,\dots s_{|S|})$ of the set ${\cal K}=\{1,2\dots K\}$ with cardinality $|S|$ being less than $k$, and the inner product runs over all elements of the given subset.
A: The answers in this post can be generalized to the case I am proposing here. The post discusses calculating probability of success in trials when the probabilities for each trial is different. In my case, the probability of trial is from binomial distribution instead of bernoulli.
In the following solution, I use the R implementation provided by @Zen. It was discussed in the post that when the number of coins is high, the solution will not be computationally efficient, but this is ok in my case.
library(purrr) 

number_coins <- 10 # number of coins
number_tosses <- c(10, 12, 12, 14, 15, 16, 20, 30, 25, 7) # tosses for each coin
number_heads <-  rep(1, number_coins) # the number of heads we need to get at least in each coin
prob_head <- seq(0.02, 0.1, length.out = number_coins) # coins are unfair. probability of getting a head for each coin
number_coins_with_head <- 6 # we need to find the probability of getting at least number_heads in at least number_coins_with_head

## function corresponding to @Zen solution
## p is a vector of probabilities
## k number of successes
binomial_different_prob <- function(p, k){
  n <- length(p)
  S <- seq(1, n)
  A <- combn(S, k)
  pr <- 0
  for (i in 1:choose(n, k)) {
    pr <- pr + exp(sum(log(p[A[,i]])) + sum(log(1 - p[setdiff(S, A[,i])])))
  }
  return(pr)
}

## first we caluclate the probability of getting at least number_heads in each coin
coins_probs <- pmap_dbl(list(prob_head, number_tosses, number_heads), function(x, y, z)sum(dbinom(z:y, y, x )))

## the probability of getting number_coins_with_head
p_number_coins_with_head <- binomial_different_prob(coins_probs, number_coins_with_head)

## the probability of getting at least number_coins_with_heads
p_at_least_number_coins_with_head <- sum(map_dbl(number_coins_with_head:number_coins, ~ binomial_different_prob(coins_probs, .x)))
p_at_least_number_coins_with_head
# 0.5616511

And here is the computationally efficient solution, taken from @whuber in this post
library(purrr) 

number_coins <- 100 # number of coins
number_tosses <- rep(c(10, 12, 12, 14, 15, 16, 20, 30, 25, 7),10) # tosses for each coin
number_heads <-  rep(1, number_coins) # the number of heads we need to get at least in each coin
prob_head <- seq(0.02, 0.1, length.out = number_coins) # coins are unfair. probability of getting a head for each coin
number_coins_with_head <- 60 # we need to find the probability of getting at least number_heads in at least number_coins_with_head


## function from @whuber
convolve.binomial <- function(p) {
  # p is a vector of probabilities of Bernoulli distributions.
  # The convolution of these distributions is returned as a vector
  # `z` where z[i] is the probability of i-1, i=1, 2, ..., length(p)+1.
  n <- length(p) + 1
  z <- c(1, rep(0, n-1))
  for (p in p) z <- (1-p)*z + p*c(0, z[-n])
  return(z)
}



## first we caluclate the probability of getting at least number_heads in each coin
coins_probs <- pmap_dbl(list(prob_head, number_tosses, number_heads), function(x, y, z)sum(dbinom(z:y, y, x )))

## the probability of getting number_coins_with_head
p_number_coins_with_head <- convolve.binomial(coins_probs)[number_coins_with_head+1]

## the probability of getting at least number_coins_with_heads
p_at_least_number_coins_with_head <- sum(convolve.binomial(coins_probs)[(number_coins_with_head+1):(number_coins+1)])


