taocp

This site has no text of the book. Keep your own copy of TAOCP next to it. See what is checked.

Exercise · Volume 1 · 1.2.10-16

Exercise 1.2.10-16

not stated yet in Lean solution written

RatingM25
MarkersM (mathematical)
KindK3, find a value: compute a number, a set or a closed form from the written solution
SectionSection 1.2.10 of Volume 1. Companion chapter: Analysis of an algorithm

The task

Find the generating function, the mean and the variance of a mixture of the distributions g1,…,grg_1,\ldots,g_r taken with the probabilities p1,…,prp_1,\ldots,p_r.

The exact wording is in your copy of the book.

Hints

Open one hint at a time. Try the exercise again after each.

Hint 1

Condition on which distribution is used.

Hint 2

For the variance, write EX2E X^2 with the formula (13) for each gkg_k.

Solution

Show the solution

The probability that X=jX=j is ∑kpk[zj]gk(z)\sum_kp_k[z^j]g_k(z), so g(z)=∑k=1rpkgk(z)g(z)=\sum_{k=1}^rp_kg_k(z). Let μk=gk′(1)\mu_k=g_k'(1) and vk=var⁡(gk)v_k=\operatorname{var}(g_k). Then g′(1)=∑kpkμkg'(1)=\sum_kp_k\mu_k, so mean⁡(g)=∑kpkμk\operatorname{mean}(g)=\sum_kp_k\mu_k.

By (13), gk′′(1)=vk+μk2−μkg_k''(1)=v_k+\mu_k^2-\mu_k. Then g′′(1)=∑kpk(vk+μk2−μk)g''(1)=\sum_kp_k(v_k+\mu_k^2-\mu_k) and

var⁡(g)=g′′(1)+g′(1)−g′(1)2=∑kpkvk+∑kpkμk2−(∑kpkμk)2.\operatorname{var}(g)=g''(1)+g'(1)-g'(1)^2=\sum_kp_kv_k+\sum_kp_k\mu_k^2-\Bigl(\sum_kp_k\mu_k\Bigr)^2.

Since ∑pk=1\sum p_k=1, ∑kpkμk2−(∑kpkμk)2=∑j<kpjpk(μj−μk)2\sum_kp_k\mu_k^2-(\sum_kp_k\mu_k)^2=\sum_{j<k}p_jp_k(\mu_j-\mu_k)^2 (expand the right side and use ∑jpj=1\sum_jp_j=1). So

var⁡(g)=∑kpkvar⁡(gk)+∑j<kpjpk(mean⁡(gj)−mean⁡(gk))2.\operatorname{var}(g)=\sum_kp_k\operatorname{var}(g_k)+\sum_{j<k}p_jp_k\bigl(\operatorname{mean}(g_j)-\operatorname{mean}(g_k)\bigr)^2.

Check

Take g1=1g_1=1 (the value 00) and g2=z2g_2=z^2 (the value 22) with p1=p2=12p_1=p_2=\frac12. Then g=12+12z2g=\frac12+\frac12z^2, with mean 11 and variance 11. The formula gives 0+12⋅12⋅(0−2)2=10+\frac12\cdot\frac12\cdot(0-2)^2=1.

Remarks

The first term is the mean within the groups and the second is the spread between the groups. This is the law of total variance.

This solution is drafted, and a person has not reviewed it yet. The source.

In Lean

not stated yet The exercise is not stated in Lean yet.

The status is computed from the Lean build. The node of the map.

Something is wrong? Report it.