# Calculating parameters of a binomial distribution [closed]

Say I have a set of data which I know comes from a Binomial distribution (generated using the rbinom function in R).

Is there any way to use the data to work backwards and work out the p and n parameters of the Binomial distribution from which it came?

EDIT: I realise that there are infinite combinations: n = 100 and p = 0.1 will produce approximately the same distribution as n = 10000 and p = 0.0001. What I'm looking for is an approximation - any combination will do.

-
You're right @Henry - rushed edit. –  James Highbright Mar 31 '12 at 16:54
James, you are asking a very general question. A full answer would require the resources of a small textbook, because there are dozens of ways to go about estimating $p$ and $n$. To narrow it appropriately, could you state how much data you have (or contemplate obtaining), why you need to estimate these parameters, and how accurate you need the estimates to be? –  whuber Apr 1 '12 at 19:14
Some replies (now deleted) were offered that suggested using the method of moments to estimate $p$ and $n$ from the sample mean and variance. This is a worthy attack, but a stumbling block is the unfortunate fact that when the variance exceeds the mean (which easily can happen in practice), the formulas give negative values for both parameters. In some circumstances that might not be a problem and in others it indicates $n$ will be difficult to estimate. This is why it's necessary to say more about the nature of the data, such as expected ranges of $n$ and $p$ that will occur. –  whuber Apr 2 '12 at 15:29