R/rpbc.R

Defines functions rpbc

# compute the probability that a series of independent Bernoulli trials
# yields x or more successes.

rpbc=function(x,  # x: scalar number of Bernoulli successes observed
              p)  # p: vector of Bernoulli success probabilities

{
  n=length(p)
  if (x>n) return(0)
  if (x==n) return(exp(sum(log(p))))
  if (x<=0) return(1)
  res=pbc(p,x)
  return(res[x+1])
}

Try the GRIN2 package in your browser

Any scripts or data that you put into this service are public.

GRIN2 documentation built on June 17, 2025, 9:11 a.m.