RUЧто меняется для непрерывных наблюдений
В дне 15 мы строили правдоподобие из вероятностей отдельных значений. У непрерывной случайной величины вероятность любой одной точки равна нулю. Поэтому закон задаётся плотностью, а вероятность интервала — интегралом этой плотности.
$$P(a<X<b)=\int_a^b f(x;\theta)dx.$$Плотность неотрицательна, а её интеграл по всей прямой равен $1$. Высота может быть больше $1$: у плотности $2x$ на $(0,1)$ высота при $x=0.75$ равна $1.5$, но площадь всего треугольника равна $1$. Не путайте высоту и площадь.
Рабочее семейство дня: $f(x;\theta)=(\theta+1)x^\theta$ при $0<x<1$, ноль вне интервала, $\theta>-1$. Семейство означает, что каждому разрешённому параметру соответствует свой закон. Носитель у всех этих законов один.
Проверим, что это плотность. Коэффициент $\theta+1$ положителен; при $\theta>-1$ интеграл степенной функции у нуля сходится.
$$\int_0^1(\theta+1)x^\theta dx=[x^{\theta+1}]_0^1=1.$$Отрицательная допустимая $\theta$ не означает отрицательную плотность. Например, при $\theta=-1/2$ плотность растёт у нуля, но её площадь остаётся конечной. Это знакомый по дню 8 несобственный интеграл.
Теоретический и выборочный моменты
Первый момент — математическое ожидание. Его теоретическое значение вычисляется по модели: $m_1(\theta)=\E_\theta X$. Выборочный первый момент — среднее наблюдений $\bar x$. Это разные объекты: первый зависит от неизвестного параметра, второй уже известен по данным.
Для непрерывной величины среднее вычисляем как взвешенную площадь: значения $x$ умножаются на плотность.
$$m_1(\theta)=\int_0^1 x(\theta+1)x^\theta dx=\frac{\theta+1}{\theta+2}.$$Метод моментов приравнивает теоретический момент к выборочному. Это не равенство для каждой выборки по закону природы, а правило выбора параметра: подбираем модель, воспроизводящую наблюдённый момент.
$$\frac{\theta+1}{\theta+2}=\bar x\quad\Longrightarrow\quad\hat\theta_{\rm MM}=\frac{2\bar x-1}{1-\bar x}.$$Например, при $\bar x=2/3$ уравнение даёт $\hat\theta=1$. Проверьте обратно: среднее плотности $2x$ равно $2/3$. Такой возврат к исходному уравнению проверяет и алгебру, и выбор момента.
Поскольку все наблюдения строго между $0$ и $1$, их среднее тоже внутри этого интервала. Тогда $\hat\theta+1=\bar x/(1-\bar x)>0$, то есть оценка допустима. Ровно $0$ или $1$ в данных противоречили бы указанному носителю, а не требовали бы механической подстановки в формулу.
Если дан другой момент
Момент порядка $r$ — это $\E X^r$, а выборочный момент — $\frac1n\sum_i x_i^r$. Для положительного целого $r$ тот же расчёт даёт
$$\E X^r=\int_0^1 x^r(\theta+1)x^\theta dx=\frac{\theta+1}{\theta+r+1}.$$Например, если дано среднее квадратов $m_2$, решаем $(\theta+1)/(\theta+3)=m_2$. Не подставляем $m_2$ в формулу для среднего и не заменяем среднее квадратов квадратом среднего. У чисел $0.2,0.8$ среднее квадратов $0.34$, а квадрат среднего $0.25$.
Метод остаётся прежним для незнакомой степени: вычислить нужный теоретический момент, приравнять данному выборочному, решить и проверить область. Заучивать отдельную оценку для каждой степени не требуется.
Непрерывное правдоподобие
Почему можно перемножать плотности, если вероятность каждого точного наблюдения нулевая? Рассмотрим маленькие интервалы одинаковой ширины около наблюдений. Их совместная вероятность приближённо равна произведению плотностей, умноженному на общую степень ширины. Эта степень не зависит от параметра; сравнение моделей определяется произведением плотностей.
Для независимых наблюдений определяем $L(\theta)=\prod_i f(x_i;\theta)$. Это функция параметра при фиксированных данных; она сама не обязана быть ни вероятностью, ни плотностью параметра.
$$L(\theta)=(\theta+1)^n\prod_i x_i^\theta,\qquad\ell(\theta)=n\ln(\theta+1)+\theta s,\qquad s=\sum_i\ln x_i.$$Все $x_i$ меньше $1$, поэтому $s<0$. Производная $\ell\prime=n/(\theta+1)+s$ обращается в ноль при $\hat\theta=-n/s-1$. Заметьте: здесь используется сумма логарифмов, а в методе первого момента — сумма самих наблюдений.
Вторая производная $\ell\prime\prime=-n/(\theta+1)^2<0$ на всей области. Кроме того, $\ell\to-\infty$ при $\theta\downarrow-1$ и при $\theta\to\infty$: в последнем случае отрицательное линейное слагаемое обгоняет логарифм. Значит найденный максимум единственный и глобальный.
Если закон записан как $f(x;\alpha)=\alpha x^{\alpha-1}$, $\alpha>0$, это то же семейство с $\alpha=\theta+1$. Нужно отвечать в параметре, который спрашивают. После замены $\hat\alpha=-n/s$, а вычитание единицы требуется только для $\theta$.
Плотность → CDF → квантиль
Функция распределения, по-английски CDF, определяется как $F(x)=P(X\le x)$. Она накапливает вероятность слева направо. В отличие от плотности, её значения всегда между $0$ и $1$.
$$F(x)=0\ (x\le0),\qquad F(x)=x^{\theta+1}\ (0<x<1),\qquad F(x)=1\ (x\ge1).$$Средняя формула получена интегралом от $0$ до $x$. Две внешние части необходимы: ниже носителя вероятность ещё не накопилась, выше носителя она накопилась целиком. Проверки: непрерывность на границах, возрастание и производная $F\prime=f$ внутри интервала.
Квантиль уровня $r$ — порог, слева от которого накоплена доля $r$. В нашем непрерывном строго возрастающем случае она единственна и удовлетворяет $F(q_r)=r$, где $0<r<1$.
$$q_r=r^{1/(\theta+1)}.$$Медиана — квантиль уровня $1/2$. Это не обязательно среднее и не точка, где плотность равна половине. Для плотности $2x$ среднее равно $2/3$, а медиана $\sqrt{1/2}$.
Подстановочная оценка
Когда параметр неизвестен, сначала выбираем метод его оценки. Затем в формулу интересующей характеристики подставляем оценку вместо параметра: $\hat q_r=r^{1/(\hat\theta+1)}$. Это подстановочная оценка, по-английски plug-in estimate.
Например, при $n=4$, $s=-4$ MLE даёт $\hat\theta=0$: оценённая модель равномерна. Её медиана $1/2$, квантиль уровня $0.8$ равна $0.8$. Проверка здесь особенно проста и помогает обнаружить ошибочную степень.
Не округляйте промежуточную оценку параметра до подстановки. Сохраняйте дробь или полную точность и округляйте только финальный ответ. Возврат $F_{\hat\theta}(\hat q_r)=r$ проверяет последнюю часть решения.
Как выбрать первый ход
«Метод моментов» требует интеграла для данного момента. «Максимальное правдоподобие» требует произведения плотностей и проверки максимума. «Медиана» требует CDF, затем уровня $1/2$. Если спрашивают оценку медианы, соедините эти действия именно в таком порядке: параметр → CDF → квантиль → подстановка.
ENWhat changes for continuous observations?
In day 15, we constructed likelihoods from probabilities of individual values. For a continuous random variable, each individual point has probability zero. Its distribution is therefore described by a density, and interval probabilities are integrals of that density.
$$P(a<X<b)=\int_a^b f(x;\theta)dx.$$A density is nonnegative and integrates to $1$ over the whole real line. Its height may exceed $1$: the density $2x$ on $(0,1)$ has height $1.5$ at $x=0.75$, but the entire triangular area is $1$. Do not confuse height with area.
Our working family is $f(x;\theta)=(\theta+1)x^\theta$ for $0<x<1$, zero outside the interval, with $\theta>-1$. A family assigns a distribution to each allowed parameter value. All distributions in this family share the same support.
Check that this is a density. The coefficient $\theta+1$ is positive, and the power integral converges near zero when $\theta>-1$.
$$\int_0^1(\theta+1)x^\theta dx=[x^{\theta+1}]_0^1=1.$$An allowed negative $\theta$ does not make the density negative. For example, at $\theta=-1/2$, the density grows near zero but still has finite area. This is the kind of improper integral introduced in day 8.
Theoretical and sample moments
The first moment is the expectation. Its theoretical value comes from the model: $m_1(\theta)=\E_\theta X$. The sample first moment is the observed mean $\bar x$. These are different objects: the former depends on an unknown parameter; the latter is already known from the data.
For a continuous variable, calculate the mean as a weighted integral: multiply each value $x$ by the density.
$$m_1(\theta)=\int_0^1 x(\theta+1)x^\theta dx=\frac{\theta+1}{\theta+2}.$$Method of moments equates the theoretical moment to the sample moment. This is not a natural identity that holds for every sample; it is a rule for choosing a parameter so that the model reproduces an observed moment.
$$\frac{\theta+1}{\theta+2}=\bar x\quad\Longrightarrow\quad\hat\theta_{\rm MM}=\frac{2\bar x-1}{1-\bar x}.$$For example, when $\bar x=2/3$, the equation gives $\hat\theta=1$. Check backward: the density $2x$ has mean $2/3$. Returning to the original equation checks both the algebra and the choice of moment.
All observations lie strictly between $0$ and $1$, so their mean does too. Then $\hat\theta+1=\bar x/(1-\bar x)>0$, making the estimate admissible. An exact $0$ or $1$ in the data would contradict the stated support; it would not call for mechanical substitution into the formula.
If a different moment is given
A moment of order $r$ is $\E X^r$, and its sample counterpart is $\frac1n\sum_i x_i^r$. For a positive integer $r$, the same calculation gives
$$\E X^r=\int_0^1 x^r(\theta+1)x^\theta dx=\frac{\theta+1}{\theta+r+1}.$$For example, if the mean of squares is $m_2$, solve $(\theta+1)/(\theta+3)=m_2$. Do not insert $m_2$ into the mean formula or replace the mean of squares by the square of the mean. For the values $0.2,0.8$, the mean of squares is $0.34$, while the square of the mean is $0.25$.
An unfamiliar power uses the same method: calculate the required theoretical moment, equate it to the given sample moment, solve, and check the domain. You do not need a separate memorized estimator for every power.
Continuous likelihood
Why multiply densities when every exact observation has probability zero? Consider small intervals of equal width around the observations. Their joint probability is approximately the product of densities multiplied by a common power of the width. That width factor is independent of the parameter, so the product of densities determines the comparison between models.
For independent observations, define $L(\theta)=\prod_i f(x_i;\theta)$. It is a function of the parameter with the data held fixed; it need not be a probability or a density for the parameter.
$$L(\theta)=(\theta+1)^n\prod_i x_i^\theta,\qquad\ell(\theta)=n\ln(\theta+1)+\theta s,\qquad s=\sum_i\ln x_i.$$Every $x_i$ is below $1$, so $s<0$. The derivative $\ell\prime=n/(\theta+1)+s$ vanishes at $\hat\theta=-n/s-1$. Notice the data summary: MLE uses the sum of logarithms, whereas first-moment matching uses the sum of observations themselves.
The second derivative $\ell\prime\prime=-n/(\theta+1)^2<0$ throughout the domain. Also, $\ell\to-\infty$ as $\theta\downarrow-1$ and as $\theta\to\infty$: in the latter case, the negative linear term eventually dominates the logarithm. The maximum is therefore unique and global.
If the model is written as $f(x;\alpha)=\alpha x^{\alpha-1}$, $\alpha>0$, it is the same family with $\alpha=\theta+1$. Answer in the requested parameter. The estimate is $\hat\alpha=-n/s$; subtract one only when estimating $\theta$.
Density → CDF → quantile
The cumulative distribution function, or CDF, is $F(x)=P(X\le x)$. It accumulates probability from left to right. Unlike a density, its values always lie between $0$ and $1$.
$$F(x)=0\ (x\le0),\qquad F(x)=x^{\theta+1}\ (0<x<1),\qquad F(x)=1\ (x\ge1).$$The middle expression comes from integrating from $0$ to $x$. Both outer pieces matter: below the support no probability has accumulated; above it all probability has accumulated. Check continuity at the boundaries, monotonicity, and $F\prime=f$ inside the interval.
A quantile at level $r$ is a threshold with probability $r$ accumulated to its left. In this continuous, strictly increasing case it is unique and satisfies $F(q_r)=r$, where $0<r<1$.
$$q_r=r^{1/(\theta+1)}.$$The median is the quantile at level $1/2$. It need not equal the mean, and it is not where the density equals one half. For the density $2x$, the mean is $2/3$, but the median is $\sqrt{1/2}$.
Plug-in estimation
When the parameter is unknown, first choose an estimation method. Then substitute its estimate into the formula for the desired characteristic: $\hat q_r=r^{1/(\hat\theta+1)}$. This is a plug-in estimate.
For example, with $n=4$, $s=-4$, MLE gives $\hat\theta=0$: the fitted model is uniform. Its median is $1/2$, and its quantile at level $0.8$ is $0.8$. This particularly simple check helps catch a wrong exponent.
Do not round the parameter estimate before substituting it. Keep a fraction or full precision and round only the final answer. Substituting back to check $F_{\hat\theta}(\hat q_r)=r$ verifies the last part of the solution.
Choosing the first move
“Method of moments” calls for an integral giving the specified moment. “Maximum likelihood” calls for a product of densities and a maximum check. “Median” calls for the CDF and then level $1/2$. To estimate a median, combine the steps in this order: parameter → CDF → quantile → substitution.