Example 2. The random variable $\xi$ has a negative binomial distribution $\mathrm{P}(\xi=k)=C_{m+k-1}^{k} p^{m} q^{k}$. Here $m>1$ and $p \in(0,1)$ are parameters, $q=1-p$. From the sample $x_{1}, \ldots, x_{n}$ of values of $\xi$, the empirical moments $M_{1}=\bar{x}=1.21$ and $M_{2}=\overline{x^{2}}=3.54$ are determined. Using these moments, find the parameters $m$ and $p$.
Solution.

1. We calculate the theoretical moments $M \xi^{k}$ for $k=1,2$, expressing them through the unknown parameters $m$ and $p$. We have

$$
\begin{gathered}
M \xi=\sum_{k=1}^{\infty} k \mathrm{P}(\xi=k)=\sum_{k=1}^{\infty} k C_{m+k-1}^{k} p^{m} q^{k} \\
M \xi^{2}=\sum_{k=1}^{\infty} k^{2} \mathrm{P}(\xi=k)=\sum_{k=1}^{\infty} k^{2} C_{m+k-1}^{k} p^{m} q^{k}
\end{gathered}
$$

Transforming the series in (3) to the form

$$
\begin{aligned}
& \frac{p^{m}}{(m-1)!} \sum_{k=1}^{\infty} k \frac{(m+k-1)!}{k!} q^{k}= \\
& \quad=\frac{p^{m}}{(m-1)!} \sum_{k=1}^{\infty}(k+m-1)(k+m-2) \ldots(k+1) k q^{k}
\end{aligned}
$$

we compute the sum of the series by term-by-term differentiation (see problem 10.12 in the textbook "Higher Mathematics"). We obtain

$$
M \xi=m \frac{q}{p}=m \frac{1-p}{p}
$$

Similarly, we obtain

$$
M \xi^{2}=m \frac{q}{p^{2}}=m \frac{1-p}{p^{2}}
$$

2. Equating the found theoretical moments $M \xi, M \xi^{2}$ to the given empirical moments $M_{1}^{*}=\bar{x}=1.21$ and $M_{2}^{*}=\overline{x^{2}}=3.54$, we get a system of 2 equations

$$
\left\{\begin{array}{l}
m \frac{1-p}{p}=1.93 \\
m \frac{1-p}{p^{2}}=3.54
\end{array}\right.
$$

3. We solve the system of equations (5).

Dividing the first equation by the second, we get $p=0.3418$. Substituting this value into the first equation, we solve this equation for $m$ and get $m=1.0023$.

Answer. $m=1.0023, \quad p=0.3418$.

Conditions of the Problems. Using the method of moments, find the parameters of the distribution given the known empirical moments.

1. Binomial distribution $p(k ; n, p)=C_{n}^{k} p^{k} q^{n-k}, \quad n=10$, $M_{1}^{*}=6.8$.
2. Poisson distribution $p(k ; a)=\frac{e^{-a} a^{k}}{k!}, M_{1}^{*}=3.24$.
3. Geometric distribution $p(k ; q)=(1-q) q^{k}, M_{1}^{*}=2.1$.
4. Hypergeometric distribution $p\left(k ; n_{A}, n_{B}, m\right)=\frac{C_{n_{a}}^{k} C_{n_{b}}^{m-k}}{C_{n_{a}+n_{b}}^{m}}$, $m=10, M_{1}^{*}=5.4, M_{2}^{*}=31.2$.
5. Distribution of stellar multiplicity $p(k ; q)=(1-q)^{2} k q^{k-1}, M_{1}^{*}=1.6$.
6. Uniform distribution $p(x ; a, b)=\frac{1}{b-a}$ for $ab, M_{1}^{*}=0.78, M_{2}^{*}=1.46$.
7. Exponential distribution $p(x ; \lambda)=\lambda e^{-\lambda x}$ for $x>0$, $p(x ; \lambda)=0$ for $x0, p(x ; t)=0$ for $xa$, $p(x ; a, \alpha)=0$ for $x<a, M_{1}^{*}=1.54, M_{2}^{*}=2.44$.

Answers. 1. $p=0.68$. 2. $a=3.24$. 3. $q=0.68$. 4. $n_{a}=18, n_{b}=26$. 5. $q=0.23$. 6. $a=-0.82, b=2.38$. 7. $\lambda=1.45$. 8. $t=1.72$. 9. $\lambda=3.35$. 10. $a=1.32, \alpha=7$.

### 7.12. Determining the Parameters of a Distribution Using the Method of Maximum Likelihood

Problem Statement. The distribution function of a random variable $\xi$ is $F\left(x ; a_{1}, \ldots, a_{j}\right)$, where $a_{1}, \ldots, a_{j}$ are some unknown parameters. Using a sample $x_{1}, \ldots, x_{n}$ of values of $\xi$, determine the values of $a_{1}, \ldots, a_{j}$ using the method of maximum likelihood.

## PLAN OF SOLUTION.

1. Find the probabilities $p\left(k ; a_{1}, \ldots, a_{j}\right)$ of the values of $\xi$ if $\xi$ is a discrete random variable, or the probability density $p\left(x ; a_{1}, \ldots, a_{j}\right)$ of the values of $\xi$ if $\xi$ is a continuous random variable. Often, $p\left(k ; a_{1}, \ldots, a_{j}\right)$ or $p\left(x ; a_{1}, \ldots, a_{j}\right)$ are given initially.
2. Define the likelihood function

$$
L\left(a_{1}, \ldots, a_{j}\right)=p\left(x_{1} ; a_{1}, \ldots, a_{j}\right) \cdot \ldots \cdot p\left(x_{n} ; a_{1}, \ldots, a_{j}\right)
$$

where $x_{1}, \ldots, x_{n}$ is the sample of values of the random variable $\xi$.

3. Find the unknown parameters $a_{1}, \ldots, a_{j}$ from the condition

$$
L\left(a_{1}, \ldots, a_{j}\right) \longrightarrow \max
$$

i.e., as the coordinates of the point where the likelihood function $L\left(a_{1}, \ldots, a_{j}\right)$ takes its maximum value.

## Remarks.

1. If $\xi$ is a discrete random variable, then the likelihood function (1) is the probability that the sample of $\xi$ of size $n$ is $x_{1}, \ldots, x_{n}$. Therefore, $0 \leqslant L\left(a_{1}, \ldots, a_{j}\right) \leqslant 1$.
2. It is sometimes more convenient to use the function $\ln L\left(a_{1}, \ldots, a_{j}\right)$ instead of $L\left(a_{1}, \ldots, a_{j}\right)$. It takes its maximum value at the same $a_{1}, \ldots, a_{j}$ as $L\left(a_{1}, \ldots, a_{j}\right)$.
3. If the likelihood function $L\left(a_{1}, \ldots, a_{j}\right)$ is differentiable with respect to $a_{1}, \ldots, a_{j}$, then the point where it takes its maximum value can be found as explained in problems 5.2 and 6.7 of the textbook "Higher Mathematics", or using numerical methods, such as the gradient descent method.
4. If the likelihood function $L\left(a_{1}, \ldots, a_{j}\right)$ is not differentiable with respect to some $a_{k}$, for example, if these parameters $a_{k}$ can only take discrete values, then the values of the parameters $a_{1}, \ldots, a_{j}$ where the function $L\left(a_{1}, \ldots, a_{j}\right)$ takes its maximum value are found by enumeration.