Search code examples
rprobabilityequationbinomial-cdf

Is there a way to find the probability p with R for pbinom


I think this is a rather common problem, but I could not find a solution.

I want to solve the following equation: pbinom(18,25,p)=0.05.

Is there a way to find the unknown p with the program R?

Every help is appreciated.


Solution

  • Root finding:

    print(
      res <- uniroot(function(p) pbinom(18,25,p) - 0.05, c(0, 1), 
              tol = .Machine$double.eps)
    )
    
    pbinom(18,25,res$root)
    #[1] 0.05