# Dirichlet Distribution with constraints

This is a follow up to an earlier question that I asked here:

How should I measure my confidence in this estimate of this finite distribution

In that question I asked how I could estimate a finite distribution of probabilities for a six sided die, and update them as I learned the outcome of rolls. I was directed towards Dirichlet distribution and it is ideal for this. My prior distribution is Dir(1,1,1,1,1,1), then after each roll outcome I update by adding 1 to the relevant parameter. This is ideal since I can calculate credible intervals, the expected value of various functions over the whole simplex, etc.

However I have realised that the real situation is somewhat more complicated.

Suppose that each outcome is not the roll of the die, but a roll of a modified die (modified in a known way). For instance, on certain rolls a 1 could be prohibited (In other words a copy of the die is rolled which has p1 set to 0, the other probabilities scaled to add up to 1). On certain other rolls the probability of 3 is doubled (relative to the other probabilities). To avoid problems let's suppose all probabilities of the original die are strictly between 0 and 1.

For example, say that on the first roll the die is modified so that an odd roll is not permitted. If the actual die has probabilities p1,p2,p3,p4,p5,p6 then this modified die will only have non-zero probabilities for landing on 2, 4 or 6, and these will be p2/(p2+p4+p6), p4/(p2+p4+p6), p6/(p2+p4+p6).

Is there still a way to update my Dirichlet Distribution with the outcomes of these 'modified rolls'? What is the most feasible approach?

• How you model your dynamics with the constraint die will very much depend on the question you want to answer. Do you want to consider all modifications of your die separately? – Till Hoffmann Oct 30 '15 at 12:37
• I'm not quite sure what you mean by that. The modifications to the die may be different on each roll and they will be known to me. The question I want to answer is what is the posterior distribution. Let me try to illustrate what I am after with an example: I start with a die, based on my beliefs I assign the prior distribution Dir(1,1,1,1,1,1) to its probabilities. The die is rolled once, but only even rolls are allowed; if an odd roll is produced it is discarded and rerolled, and I can't see the discarded information. This even-only roll produces a 4. Now what is the posterior distribution? – EBartrum Oct 30 '15 at 12:43

The outcome of each roll is a categorical distribution over six different states. Let $x_i\in\{1,2,3,4,5,6\}$ be the outcome of the $i^\mathrm{th}$ roll of your die and let $\rho_x$ be the (unknown) probability that the outcome of a roll is $x$.

# Review of the simpler problem without constraints

If you roll your die $n$ times and assume that the rolls are independent conditional on $\rho$, the likelihood is \begin{align} P(x|\rho)&=\prod_{i=1}^n \rho_{x_i}\\ &=\prod_{x=1}^6\rho_x^{n_x}, \end{align} where $n_x$ is the number of times you observed $x$.

Assuming a Dirichlet prior with concentration parameter $\alpha$ for $\rho$ and using Bayes' theorem yields the posterior $$P(\rho|x)=\mathrm{Dirichlet}(\rho, \alpha+\mathbf{n}),$$ where $\mathbf{n}=(n_1,\ldots,n_6)$ is the vector of frequencies.

# The extension

In your extension, the observations are censored, i.e. whether or not you can observe the die depends on the value of the die. Let's start with some definitions: Let $R_i$ be the rule applied on the $i^\mathrm{th}$ roll. If the rule does not censor the observation, we are in business and can proceed as in the previous section. If the observation was censored, we need to consider all possible states the die could have been in given that it was censored. Let $C$ be the set of observations that was censored and $O$ the set of observed rolls. Let $\hat{x}_i\in\{0,1,2,3,4,5,6\}$ be the $i^\mathrm{th}$ observation with $\hat{x}_i=0$ if it was censored. Your likelihood is thus \begin{align} P(\hat{x}|\rho R)&=\prod_{i\in O}P(\hat{x}_i|\rho R) \times \prod_{i\in C}P(\hat{x}_i|\rho R). \end{align}

Now sum over all latent states of the die $x_i$ \begin{align} P(\hat{x}|\rho R)&=\prod_{i\in O}\sum_{x_i}P(\hat{x}_i|x_iR)P(x_i|\rho) \times \prod_{i\in C}\sum_{x_i}P(\hat{x}_i=0|x_iR)P(x_i|\rho). \end{align}

In the first term, $P(\hat{x}_i|x_iR)=\delta_{\hat{x}_ix_i}$ such that the sum is trivial. In the second term, $P(\hat{x}_i=0|x_iR)$ depends on the specific rule. We find \begin{align} P(\hat{x}|\rho R)&=\prod_{i\in O}P(\hat{x}_i|\rho) \times \prod_{i\in C}\sum_{x_i}P(\hat{x}_i=0|x_iR)P(x_i|\rho)\\\\ &=\prod_{x=1}^6\rho_x^{\hat{n}_x} \times \prod_{i\in C}\sum_{x_i}P(\hat{x}_i=0|x_iR)\rho_{x_i}. \end{align}

# Example

In your example, you observed one roll of $\hat x_2=4$ such that $\hat n_2=1$ and $\hat n_x=0$ for all other $x$. Furthermore, you did not observe the first roll with the rule censoring even numbers. Then $$\prod_{i\in C}\sum_{x_i}P(\hat{x}_i=0|x_iR)\rho_{x_i}=\rho_1 + \rho_3 + \rho_5.$$ and the marginal likelihood is $$\rho_4(\rho_1 + \rho_3 + \rho_5).$$ The Dirichlet distribution is unfortunately no longer the conjugate prior but you can interpret the posterior as a mixture of three Dirichlet distributions all having observed one roll of four and each having observed one roll of 1, 3 or 5.

• Many thanks for that thorough answer, unfortunately I think it answers a slightly different question to what I have asked. In the example I have in mind, I am not told whether/how many censored rolls have taken place. On the first roll only even numbers are permitted. If an odd number is rolled the die is rerolled and I am not told the result of the censored roll and I am not told that the censored roll took place. I am told that the result of the first roll is 4 (there may have been 0, 1, 2, 3, ... censored rolls before this). What should the posterior be? – EBartrum Nov 2 '15 at 13:35
• It seems to me that the likelihood is p4/(p2+p4+p6) but what posterior this produces is beyond me – EBartrum Nov 3 '15 at 10:09
• I didn't realise that you didn't get any information about the fact that a roll occurred. I'll have another think. Could you update the question with your working to get the likelihood? – Till Hoffmann Nov 3 '15 at 10:59