The functional form given in the post written by Ssuhanchen captures my eyes. It is the cumulative distribution function of Poisson when the number of counts is less than or equal to 2 with unknown parameter mu=x/2. Since it is a nonlinear function, there may be multiple solutions but the solution should be greater than 0 (if I am in the right track). I am assuming this functional form is originated from the Poisson. Under this assumption, one solution is found as below:

> rt <- uniroot(function(x) ppois(2, lambda=x)-0.05, interval=c(0.5,1), extendInt="yes")
Warning messages:
1: In ppois(2, lambda = x) : NaNs produced
2: In ppois(2, lambda = x) : NaNs produced
3: In ppois(2, lambda = x) : NaNs produced
> ppois(2, lambda=rt$root)
[1] 0.0500001
> rt$root
[1] 6.295791

Thus, the solution x would be rt$root*2 (Note that I did not try to find other solutions). I hope this helps.

Chel Hee Lee

On 2/10/2015 2:29 AM, Rolf Turner wrote:
On 10/02/15 14:04, Ssuhanchen wrote:
Hi!

I want to use R to calculate the variable x which is in a complex equation
in below:

  2
  Σ[exp(-x/2)*(x^k)/(2^k*k!)]=0.05
k=0

how to solve this equation to get the exact x in R?

Is this homework? Sure looks like it. Talk to your prof. Or do a bit of work on learning how to use R --- which is presumably the point of the exercise.

cheers,

Rolf Turner


______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to