问题
I know the maths, but how to calculate the expected number of zeros under Poisson and Negative Binomial distributions in R? Is there any function to do so?
回答1:
You say you know the mathematics, in which case you already know you're calculating n p(0), right?
You already know n.
So isn't your question "How do I evaluate p(0) = P(X=0) for a Poisson or negative binomial in R?"
Try
?Poisson
and
?NegBinomial
And you will see there's a dpois
function for the Poisson, and a similar one for the negative binomial.
So n*dpois(0,lambda)
(with whatever value you need in place of lambda
) would give the expected number of zeros from a given Poisson distribution. The negative binomial calculation works similarly.
来源:https://stackoverflow.com/questions/22288824/calculating-the-expected-number-of-zeros-under-poisson-and-negative-binomial-dis