# Using likelihood function to createa probability distribution of a binomial probability?

## Context

Let $$X\hookrightarrow B(N,p)$$

Say we observed a single value $$X = n$$, and we know $$N$$.

## Goal

I am interested in a posterior distribution of $$p$$ given $$X = n$$ (and an uninformative prior), i.e. a probability distribution on $$[0,1]$$ of the value of $$p$$ given our single observation.

From here, I would like to be able to later to randomly draw a value of $$p$$ from this probability distribution, and not only use $$\hat{p} = n/N$$. It is because I would like to reuse values of $$p$$ in simulations where $$p$$ can vary, but only in a likely manner given our data (a single observation of $$X = n$$ successed after $$N$$ trials). I expect the mode of this distribution to be at $$n/N$$, and more or less skewed when approaching $$0$$ and $$1$$.

## Question

How do I obtain such probability distribution $$P(\ p \; \lvert X = n)$$?

## What I considered

At first I was trying to rely on binomial confidence intervals to see, across $$\alpha$$, what values of $$\hat{p}$$ where likely (with them being containted in more $$CI_\alpha$$ across all $$\alpha$$), but then figured out that I probably need Bayes theorem.

Intuitively, I would guess that my prior would be uniformly distributed across $$[0,1]$$ ($$U(0,1)$$), and that I need the likelihood of the binomial distribution. From what I came across, I understand that I will end up using a Beta distribution in some way, but I am still far from being fluent in Bayesian statistics, so please forgive all my imprecisions and lack of a deeper understanding.

• Not sure what you are trying to achieve. If I am right, $\dfrac nN$ is an unbiaised estimator of $p$ and it is most probably optimal. Or are you willing to generate a binomially distributed variable ?
– user65203
Commented Apr 8, 2021 at 12:51
• I would ultimately like to generate a new binomially distributed variable $Y = \sum_{i=0}^N y_i$, that would be the sum of Bernouilli trials $y_i\hookrightarrow B(1,p_{2i})$, but considering that for each $y_i$, an independent probability $p_{2i}$ is drawn from the distribution I am interested in. I would ultimately further use both the $y_i$ and their sum $Y$, to simulate weighted networks. Sorry for the lack of clarity, I know it is from my lack of a better understanding of the situation. Commented Apr 8, 2021 at 13:45
• Still completely opaque. :-(
– user65203
Commented Apr 8, 2021 at 13:50
• Given a single value of $X=n$, $n/N$ is the best estimator of $p_1$. Thus $Y~B(N,n/N)$, is our best attempt at having a variable behaving similarly to $X$. However, $n/N$ is only a "positional" information of $p_1$: ${p_1 hat}=0.2$ could have varied more around $n/N$ with $n/N = 2/10$ than for $n/N = 200/1000$. If now I want to create $y_i~B(1,p_2=n/N)$ behaving as closely to $B(1,p_1)$, the notion that $n/N$ could have varied more around $n/N$ for $N = 10$ or $1000$ is lost. I want to keep track of that when drawing $y_i$ by allowing $p_2$ to vary among a "distribution" of ${p_1 hat}$. Commented Apr 8, 2021 at 15:47
• Are you asking about the standard deviation of $\hat p$ (which is $\sqrt{\frac{p(1-p)}N}$) ? Or maybe the distribution of $\hat p$ ?
– user65203
Commented Apr 8, 2021 at 16:01

The beta distribution is commonly used to model prior and posterior distribution of a proportion/probablity in a Bayesian framework, as its two parameters can be used to represent our knowledge of $$X$$, i.e. with a prior: $$P(p) \hookrightarrow Beta(\alpha,\beta)$$ where $$\dfrac{\alpha}{\alpha+\beta}$$ roughly represent what we know/expect would be the proportion of successes and $$\dfrac{\beta}{\alpha+\beta}$$ the failures, with some nuances and debates regarding what uninformative prior is best, which after observing $$X=n$$ after $$N$$ trials leads to the posterior: $$P(p|X = n) \hookrightarrow Beta(\alpha+n,\beta+N-n)$$ which can in turn be updated and so on.