Estimating an underlying pdf from binomial trials I'm afraid I'm not an expert in statistics, but I have a particular problem I'm interested in solving. I'm pretty sure this area already has a lot of literature, but I'm having difficulty finding something directly applicable to what I'm doing, so it would be great if somebody could nudge me in the right direction.
I'll give an example to illustrate the problem: Say I have a machine which produces biased coins. It has some underlying continuous probability density function which it is using to pick a number 0 < p < 1, then creates a coin which will come up heads with probability p.
My task is to estimate the function which the machine uses to generate these coins. I'm allowed to flip the coins, and I have access to a very large number of coins, but each one after a certain, random, amount of flips is taken away from me. The number of flips is not necessarily large.
How would I go about doing this? My initial thought was to just sum each resulting binomial distribution and divide by the total number of coins tested. But I'm pretty sure this doesn't give a good result.
I'm faintly aware of kernal density estimation, but I don't have enough expertise to know if/how it can be used for this kind of task, or what I should know in terms of tailoring it to this task.
 A: This is just a simple idea and is not something I have seen in the literature.  I will take away the randomness of the flips by conditioning on the observed number for each coin.  Take the usual estimate for pi (i.e. number of heads divided by the number of flips) for the ith randomly selected coin.  This set of estimates forms a histogram and one can then use a kernel density method to approximate the continuous curve.  The difficulty with this approach is that it ignores the uncertainty in the estimate of p  which depends on the number of flips and the true p.  If ni is the number of flips for the ith coin and is large for each i, ignoring this uncertainty will not matter.  I think it complicates things a little that each coin has a different variance associated with its estimate of p.  Maybe this can be taken into account by using a variable width kernel.
A: Your problem can be generalized as follows:


*

*The parameter $p$ is generated according to an unknown probability density.

*You can measure $p$ only with a measurement error $\sigma$, which yields an estimator $\hat{p}$ for $p$ that has a known distribution (binomial distribution).


A simple approach is suggested by Glen_b in 
this answer to a similar question: estimate a global bandwidth $h$ first as if the measurements $\hat{p}_1,\ldots,\hat{p}_N$ were exact, and then increase the bandwidth to $\sqrt{h^2+\sigma^2}$. In your case $\sigma_i^2=\hat{p}_i(1-\hat{p}_i)/n_i$. For more sophisticated methods, see

Achilleos, Delaigle: Local bandwidth selectors for deconvolution kernel density estimation. Statistics and Computing 22,2 pp. 563–577, 2012

