Suppose that random numbers x are generated on the computer using the following procedure:

  1. Generate two numbers $x_1$, $x_2$ from a uniform distribution $\mathcal{U}$([0,1])
  2. If $x_1$ > f, take x = $x_2$, otherwise x = m $x_2$,

where f and m are two real constants between 0 and 1.

The value of f=0.2 is known, while m is unknown and we want to infer its value from a list of N outputs using the Maximum Likelihood Estimator.

I somehow managed to write the pdf $p_X(x)$ for a single observation:


where $\mathcal{I}(a<x<b)$ is the indicator function.

The likelihood is defined as $\mathcal{L}=\prod_i p(x_i)$, and in order to find the MLE i have to solve the known equation $\frac{d}{dm}\log\mathcal{L}=0$.

I find some issues in writing the likelihood, because i find myself with

$\mathcal{L(m|x_1,...,x_N)}=\prod_i p(x_i)=\frac{1}{(m(1+f)+f)^a}+\frac{(1-f)^{N-a}}{(m(1+f)+f)^{N-a}}$, where $a$ is the number of observations $x_i$ for which $x_i<m$. But i added a further unknown parameter to my problem.

I think I am having some issues multiplying the indicator functions, or maybe I have determined the wrong pdf for my problem.

Many thanks in advance.

  • 1
    $\begingroup$ What does "$a$" represent and how do you manage to convert a product of $N$ quantities into a sum of just two quantities?? $\endgroup$
    – whuber
    Commented Sep 3, 2023 at 15:45

1 Answer 1


As $x_1$ and $x_2$ are independent, the PDF can be written as a mixture of two uniform distributions, one with probability $(1-f)$ and support $(0,1)$, and the other with probability $f$ and support $(0,m)$:

$$p(x) = {f \over m}1(x \leq m) + 1 - f$$

As a check, we show this integrates to one:

$$\int_0^1\left({f \over m}1(x \leq m) + 1 - f\right)dx = {f \over m}\int_0^mdx+(1-f)\int_0^1dx = f+(1-f) = 1$$

The multivariate version is:

$$\begin{eqnarray} p(x) &=& \Pi_{i=1}^n\left({f \over m}1(x_i \leq m) + 1 - f\right)\\ &=&\Pi_{i:x_i\leq m}\left({f \over m}+1-f\right)\Pi_{i:x_i>m}(1-f)\\ &\propto&\left({f \over m}+1-f\right)^{n(x \leq m)}(1-f)^{n - n(x \leq m)} \\ &\propto& \left(1+{f \over (1-f)m}\right)^{n(x \leq m)} \end{eqnarray}$$

where $n(x \leq m)$ is the number of observations for which $x \leq m$. The $\propto$ in the last two lines is because we have moved from evaluating the probability based on each $x_i$ to evaluating the probability based on $n(x \leq m)$; we need to find the constant of integration, which is straightforward:

$$p(x) = {\left(1+{f \over (1-f)m}\right)^{n(x \leq m)} \over \sum_{i=0}^n\left(1+{f \over (1-f)m}\right)^i}$$

Given that $m$ appears in the term $n(x \leq m)$ in the exponent as well as in the $(1 + f/((1-f)m))$ terms in both numerator and denominator and that $n(x \leq m)$ is a piecewise horizontal function with $n$ jumps, I suspect finding $\hat{m}$ by numerical methods is probably the way to go.

  • $\begingroup$ Many thanks for the answer! I thought it would look something like this. But i am pretty sure that there is an analytical solution to the MLE of m. $\endgroup$
    – zed378
    Commented Sep 4, 2023 at 7:19
  • 1
    $\begingroup$ The problem is the jumps in $n(x \leq m)$ as you increase $m$; calculus won't help you with that. $\endgroup$
    – jbowman
    Commented Sep 4, 2023 at 14:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.