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.
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.
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
Brute force :
p = 0.0001 # starting point
while (abs(pbinom(18,25,p) - 0.05) > 0.001) p <- p + 0.001
This code evaluates the pdf for different values of p until you are "close enough" to 0.05. Here "close enough" means at the 0.001 range.
> p [1] 0.8601 > pbinom(18,25,0.8601) [1] 0.05070763