Professional Documents
Culture Documents
Module6 Slides
Module6 Slides
Module6 Slides
D Manjunath
Networking Lab
Department of Electrical Engineering
Indian Institute of Technology
November 2, 2020
IITlogo
DM EE 325
Reiterating: Slides will be necessarily terse and you have to read from
the textbook to get a full grasp of the material
You are expected to take notes during the lecture.
IITlogo
DM EE 325
Statistics
IITlogo
DM EE 325
Statistics
There are some numerical facts about the population that investigators
want to know, e.g., average family income in a demographic.
These numerical facts are called parameters.
These cannot be determined exactly but can be estimated from samples.
Major Issue: Acccuracy of the estimate.
How close is the estimate going to be to the true value?
How confident are we about this closeness? i.e., what is the probability
that the estimate is ‘wrong.’
Paramenters are estimated by statistics, or numbers which can be
computed from the sample.
If x1 , . . . , xn is the set of n measurements from n samples, some function
f (x1 , . . . , xn ) is a statistic.
To summarise: Statistics are what the investigator knows from the
samples. Parameters are what they want to know.
IITlogo
DM EE 325
TRP Ratings
IITlogo
DM EE 325
TRP ratings: background
IITlogo
DM EE 325
TRP ratings: background
IITlogo
DM EE 325
TRP ratings: organisations involved
In India, the popularity of different programs are measured with a
number called the TRP (Televising Rating Point) rating. It is indicative
of TV viewership of a program.
“People Meters” are placed in a sample of the homes to determine what
the households are watching.
People meters essentially determines the channel to which the TV set is
tuned. This information alongwith the times is recorded and stored
suitably for later analysis.
In India, TRP measurement is conducted by several
organisations—Joint Industry Board Television Audience Measurement
Research (JIB-TAM), ORG-MARG’s Indian Television Audience
Measurement (INTAM), (these two have now merged), Audience
Measurement and Analytics (aMap), Doordarshan Audience Ratings
team (DART);
Broadcast Audience Research Council (BARC) is a cross industry body
that oversees the TV audience measurement. Telecom Regulatory
Authority of India (TRAI) regulates the process and provides IITlogo
IITlogo
DM EE 325
TRP ratings: issues
IITlogo
DM EE 325
TRP ratings: some more economics
It costs more than twenty five crore rupees per year to obtain and
analyse the data annually.
Media planning and buying agencies use these ratings to place
advertising time on TV shows.
The buyers of the analysis may pay up to ten crore rupees per month.
IITlogo
DM EE 325
IITlogo
DM EE 325
On Sampling
DM EE 325
Esimation
IITlogo
DM EE 325
Estimators: Point and Interval Estimate
DM EE 325
Recap: Sums of Independent Random Variables
DM EE 325
The Unit Normal
IITlogo
DM EE 325
The Unit Normal
Prob(0 ≤ Z < 1) ≈
Prob(0 ≤ Z > 1) ≈
Prob(0 ≤ Z > 2) ≈
Prob(Z > zα ) = α
Percentile 90 95 97.5 99 99.5 99.9 99.95
α 0.1 0.05 0.025 0.01 0.005 0.001 0.0005
zα 1.28 1.645 1.96 2.33 2.58 3.08 3.27
IITlogo
DM EE 325
Sample Mean
Assume a population with mean µ and variance σ 2 .
µ is unknown and is to be estimated, σ is known.
Neither is known and are to be estimated.
‘Obvious method’: Obtain n independent samples whose values will be
X1 , . . . Xn and calculate the sample mean as an estimator for the mean.
Pn
Xi
Sample Mean := X̄n := i=1
n
Clearly, X̄n is a random variable. Characterising this random variable
characterises the quality of the estimate.
The expectation and variance of the sample mean are
Pn Pn
i=1 Xi i=1 E(Xi )
E X̄n = E = = µ
n n
Pn Pn
σ2
i=1 Xi i=1 VAR(Xi )
VAR X̄n = VAR = =
n n n
What is the distribution X̄n ? IITlogo
Consider the sum of the square of the deviations from the mean, i.e.,
n
X 2
V = (Xi − µ)
i=1
n
X Xn
2
(Xi − µ) = X2i − nµ2
i=1 i=1
n
!
X 2
E(V) = E (Xi − µ)
i=1
n
X
2
= E (Xi − µ)
i=1
= nσ 2
DM EE 325
Sample Variance: Known mean
Consider the sum of the square of the deviations from the mean, i.e.,
n
X 2
V = (Xi − µ)
i=1
n
X Xn
2
(Xi − µ) = X2i − nµ2
i=1 i=1
n
!
X 2
E(V) = E (Xi − µ)
i=1
n
X
2
= E (Xi − µ)
i=1
= nσ 2
DM EE 325
Sample Variance: Known mean
Consider the sum of the square of the deviations from the mean, i.e.,
n
X 2
V = (Xi − µ)
i=1
n
X Xn
2
(Xi − µ) = X2i − nµ2
i=1 i=1
n
!
X 2
E(V) = E (Xi − µ)
i=1
n
X
2
= E (Xi − µ)
i=1
= nσ 2
DM EE 325
Sample Variance: Known mean
Consider the sum of the square of the deviations from the mean, i.e.,
n
X 2
V = (Xi − µ)
i=1
n
X Xn
2
(Xi − µ) = X2i − nµ2
i=1 i=1
n
!
X 2
E(V) = E (Xi − µ)
i=1
n
X
2
= E (Xi − µ)
i=1
= nσ 2
DM EE 325
Sample Variance: Known mean
Consider the sum of the square of the deviations from the mean, i.e.,
n
X 2
V = (Xi − µ)
i=1
n
X Xn
2
(Xi − µ) = X2i − nµ2
i=1 i=1
n
!
X 2
E(V) = E (Xi − µ)
i=1
n
X
2
= E (Xi − µ)
i=1
= nσ 2
DM EE 325
Sample Variance: Unknown mean
Consider the sum of the square of the deviations from the mean, i.e.,
n
X 2
V = Xi − X̄
i=1
n n
X 2 X 2
Xi − X̄ = X2i − n X̄
i=1 i=1
n
!
X 2
E(V) = E X2i − n X̄
i=1
n
¯ 2 E (X)
¯ 2
X
E X2i − nE (X)
=
i=1
= nVAR(X1 ) + n(E(X1 ))2 − nVAR X̄ − n(E X̄ )
2
2 2 σ
= nσ + nµ − n − nµ2 = (n − 1)σ 2 .
n
IITlogo
V
Thus, when µ is not known, n−1 is the unbiased estimate of VAR(X1 ) .
DM EE 325
Sample Variance: Unknown mean
Consider the sum of the square of the deviations from the mean, i.e.,
n
X 2
V = Xi − X̄
i=1
n n
X 2 X 2
Xi − X̄ = X2i − n X̄
i=1 i=1
n
!
X 2
E(V) = E X2i − n X̄
i=1
n
¯ 2 E (X)
¯ 2
X
E X2i − nE (X)
=
i=1
= nVAR(X1 ) + n(E(X1 ))2 − nVAR X̄ − n(E X̄ )
2
2 2 σ
= nσ + nµ − n − nµ2 = (n − 1)σ 2 .
n
IITlogo
V
Thus, when µ is not known, n−1 is the unbiased estimate of VAR(X1 ) .
DM EE 325
Sample Variance: Unknown mean
Consider the sum of the square of the deviations from the mean, i.e.,
n
X 2
V = Xi − X̄
i=1
n n
X 2 X 2
Xi − X̄ = X2i − n X̄
i=1 i=1
n
!
X 2
E(V) = E X2i − n X̄
i=1
n
¯ 2 E (X)
¯ 2
X
E X2i − nE (X)
=
i=1
= nVAR(X1 ) + n(E(X1 ))2 − nVAR X̄ − n(E X̄ )
2
2 2 σ
= nσ + nµ − n − nµ2 = (n − 1)σ 2 .
n
IITlogo
V
Thus, when µ is not known, n−1 is the unbiased estimate of VAR(X1 ) .
DM EE 325
Sample Variance: Unknown mean
Consider the sum of the square of the deviations from the mean, i.e.,
n
X 2
V = Xi − X̄
i=1
n n
X 2 X 2
Xi − X̄ = X2i − n X̄
i=1 i=1
n
!
X 2
E(V) = E X2i − n X̄
i=1
n
¯ 2 E (X)
¯ 2
X
E X2i − nE (X)
=
i=1
= nVAR(X1 ) + n(E(X1 ))2 − nVAR X̄ − n(E X̄ )
2
2 2 σ
= nσ + nµ − n − nµ2 = (n − 1)σ 2 .
n
IITlogo
V
Thus, when µ is not known, n−1 is the unbiased estimate of VAR(X1 ) .
DM EE 325
Sample Variance: Unknown mean
Consider the sum of the square of the deviations from the mean, i.e.,
n
X 2
V = Xi − X̄
i=1
n n
X 2 X 2
Xi − X̄ = X2i − n X̄
i=1 i=1
n
!
X 2
E(V) = E X2i − n X̄
i=1
n
¯ 2 E (X)
¯ 2
X
E X2i − nE (X)
=
i=1
= nVAR(X1 ) + n(E(X1 ))2 − nVAR X̄ − n(E X̄ )
2
2 2 σ
= nσ + nµ − n − nµ2 = (n − 1)σ 2 .
n
IITlogo
V
Thus, when µ is not known, n−1 is the unbiased estimate of VAR(X1 ) .
DM EE 325
Sample Variance: Unknown mean
Consider the sum of the square of the deviations from the mean, i.e.,
n
X 2
V = Xi − X̄
i=1
n n
X 2 X 2
Xi − X̄ = X2i − n X̄
i=1 i=1
n
!
X 2
E(V) = E X2i − n X̄
i=1
n
¯ 2 E (X)
¯ 2
X
E X2i − nE (X)
=
i=1
= nVAR(X1 ) + n(E(X1 ))2 − nVAR X̄ − n(E X̄ )
2
2 2 σ
= nσ + nµ − n − nµ2 = (n − 1)σ 2 .
n
IITlogo
V
Thus, when µ is not known, n−1 is the unbiased estimate of VAR(X1 ) .
DM EE 325
Sampling from a Normal Population
X̄ − µ
√
σ/ n
is standard normal.
Define Pn
2 − X̄)2
i=1 (Xi
S =
n−1
Can show that X̄ and S2 are independent random variables.
IITlogo
DM EE 325
Known Variance
In this case we say that (X̄n − zδ/2 √σn ) is the γ confidence interval for µ.
If the population is not from a normal distribution, invoke CLT to use
the preceding as an approximation.
Alternatively, use Chebyshev inequality to
σ σ
Prob X̄n − √ ≤ µ ≤ X̄n + √ ≥ 1 − δ = γ.
nδ nδ
IITlogo
DM EE 325
Known Variance
In this case we say that (X̄n − zδ/2 √σn ) is the γ confidence interval for µ.
If the population is not from a normal distribution, invoke CLT to use
the preceding as an approximation.
Alternatively, use Chebyshev inequality to
σ σ
Prob X̄n − √ ≤ µ ≤ X̄n + √ ≥ 1 − δ = γ.
nδ nδ
IITlogo
DM EE 325
Unknown Variance: Distributions of X̄ and S2
DM EE 325
Chi-Square and t Distributions
IITlogo
DM EE 325
Unknown Variance: Distributions of X̄ and S2
Can show that X̄ and S2 are independent with X̄ being normal and
(n − 1)S2 /σ 2 being χ2n−1 .
√
This means n X̄−µ S is Student t distribution, tn−1 .
This helps in obtaining the confidence interval when the variance is
unknown.
√ X̄ − µ
Prob −tα/2,n−1 < n < tα/2,n−1 = 1 − α
S
S2
2 2
Prob χα/2,n−1 ≤ (n − 1) 2 ≤ χα/2,n−1 = 1 − α
σ
IITlogo
DM EE 325
Likelihood Function
IITlogo
DM EE 325
Maximum Likelihood Estimate
Find the θ that maximises the likelihood of the observations.
θ̂ = arg max L(x1 , . . . , xK |θ)
θ
Can also maximise the Log Likelihood function.
Likelihood and log likelihood functions and MLEs
Bernouilli
YK
L(x; p) = pxi (1 − p)1−xi = pn (1 − p)K−n
i=1
PK
i=1 xi
p̂ =
K
Poisson
K PK
i=1 xi
−λ λxi −Kλ λ
Y
L(x; λ) = e = e QK
xi ! i=1 xi
i=1
K
X K
Y
log L(x; λ) = −Kλ + xi log λ − log( xi ) IITlogo
i=1 i=1
PK
i=1 xi
λ̂ = DM EE 325
Maximum Likelihood Estimate
i=1
2πσ ( 2πσ)K
K
√ X (xi − µ)2
log L(x; λ) = −K log( 2πσ) −
2σ 2
i=1
PK
i=1 xi
µ̂ =
K
MLE for Uniform in (0, a)
1
L(x; λ) =
aK
â = max{x1 , x2 , . . . , xK }
Expectation of Estimate is the bias and variance is the mean squared IITlogo
error.
DM EE 325
Minimum Mean Square Error Estimate
2
θ̂ = arg minθ E θ − θ̂ .
IITlogo
DM EE 325
Hypothesis Testing
DM EE 325
Hypothesis Testing
DM EE 325
Test Procedures
IITlogo
DM EE 325
Example 1
DM EE 325
Example 2
The monthly expenditure on food of a household income is Gaussian
with mean 7,500 and standard deviation 900. With large retail stores
(supermarkets in malls), the mean expenditure will reduce but the
standard deviation will remain the same. We will check the expenditure
of 25 households.
Let X be the expenses after the supermarkets enter the area.
H0 : X is Gaussian with µ = 7500 and σ = 900.
H1 : X is Gaussian with µ < 7500 and σ = 900
Test statistic is the sample mean, X̄, of the expenses. This has
σ = 900/5 = 180.
Consider the rejection region X̄ < 7080.
α = is the probability of a Gaussian random variable with parameters
(7500, 180) being lesser than 7080; this corresponds
Prob(Z < −7/3) , i.e., α = 0.01.
The value of β depends on the true value of µ.
For true µ = 7200, β is the probability of X̄ ≥ 7080 for a Gaussian
variable with parameters (7200, 180), i.e.,
IITlogo
β = Prob(X > 2/3) = 0.7486.
For true µ = 7000, β = 0.174.
DM EE 325
In example 1, change rejection region to ≥ 9.
α = 0.041, β(0.3) = 0.887, and β(0.5) = 0.252.
In example 2, change rejection region to ≤ 7200.
α = 0.05, β(7200) = 0.5, and β(7000) = 0.1335.
Summary: Decreasing size of rejection region to obtain a smaller value
of α results in a larger value of β for a particular set of the parameters.
IITlogo
DM EE 325
Some more terminology
IITlogo
DM EE 325
Some more terminology
IITlogo
DM EE 325
Some more terminology
IITlogo
DM EE 325
Testing for Mean of a Normal Population with Known
Variance
H0 : µ = µ0 versus H1 : µ 6= µ0 .
Test obtains X1 , . . . , Xn and computes the sample X̄.
A reasonable rejection region: {X1 , . . . , Xn : |X̄ − µ0 | > c}
X̄ is Gaussian with unknown mean µ and known standard deviation σ.
If α is specified, choose c such that Prob(|X̄ − µ0 | > c | µ = µ0 ) = α;
X̄−µ
Let Z := (σ/ √0
n)
Prob(|X̄ − µ0 | > c | µ = µ0 ) = α;
√
c n
Prob |Z| > = α
σ
√
c n
2Prob Z > = α
σ
Prob Z > zα/2 = α/2
√
c n
= zα/2
σ IITlogo
zα/2 σ
c = √
n
DM EE 325
Testing for Mean of a Normal Population with Known
Variance
√
n
Reject H0 if σ |X̄ − µ0 | > zα/2
√
n
Accept H0 if σ |X̄ − µ0 | ≤ zα/2
A reasonable choice of α depends on the specifics of the situation,
essentially the ‘cost’ of a Type I error. It will also depend on ‘the
conviction’ about H0 . Strong beliefs would require strong data to
‘overthrow’ H0 .
An alternative view:
X̄−µ0
Consider v = (σ/ √
n)
Let p be the probability that the unit normal exceeds v.
Now observe that p is critical significance level of the test, i.e, if α < p,
H0 is accepted.
p is called the p-value of the test.
p is the probability, caclulated assuming that H0 is true, of obtaining the
value of the test statistic (e.g., sample mean) at least as contradictory to
H0 as the value calculated from the available sample. IITlogo
DM EE 325
Example
DM EE 325
Type II Error
We now obtain β(µ).
X̄−µ
Define Z = (σ/ √ . Of course Z is the unit normal if the X̄ were
n)
Gaussian with mean µ and variance σ 2 /m.
X̄ − µ0
β(µ) = Prob −zα/2 ≤ √ < zα/2
σ/ n
µ X̄ − µ0 − µ µ
= Prob −zα/2 − √ ≤ √ ≤ zα/2 − √
σ/ n σ/ n σ/ n
µ µ0 µ
= Prob −zα/2 − √ ≤ Z − √ ≤ zα/2 − √
σ/ n σ/ n σ/ n
µ0 − µ µ −µ
= Prob √ − zα/2 ≤ Z ≤ 0 √ + zα/2
σ/ n σ/ n
µ0 − µ µ0 − µ
= Φ √ + zα/2 − Φ √ − zα/2
σ/ n σ/ n
Here Φ(x) is the CDF of the unit normal, i.e.,
Z x
1 y2 IITlogo
√ e− 2 dx
2π −∞
DM EE 325
Type II Error and Number of Samples
Rejection region is determined by α.
β(µ) can be used to determine the number of samples that may be
required.
Assume a requirement that β(µ1 ) = β, i.e.,
µ0 − µ µ0 − µ
Φ √ + zα/2 − Φ √ − zα/2 = β.
σ/ n σ/ n
Let µ1 > µ0 ; then
µ0 − µ1
√ − zα/2 ≤ −zα/2
(σ/ n)
Since Φ is an increasing function,
µ0 − µ1
Φ √ − zα/2 ≤ Φ(−zα/2 ) = α/2 ≈ 0
(σ/ n)
µ0 − µ
β ≈ Φ √ + zα/2 = Φ(z−β )
σ/ n
µ0 − µ
−zβ = √ + zα/2
σ/ n IITlogo
Solve for n.
DM EE 325
Remarks
For tests involving mean of a normal population with known variance,
we use the sample mean from n iid samples.
X̄−µ
The test statistic Z = (σ/ √ 0 measures the deviation of the sample
n)
mean from µ0 in “units of the standard deviation.”
H0 is rejected if Z is sufficiently large in the direction pointed to by H1 .
Connections can be drawn with “Interval Estimate” of the mean of a
normal population.
σ σ
Prob µ ∈ X̄ − zα/2 √ , X̄ − zα/2 √ = 1−α
n n
Hence
if µ = µ0 , then with probability
(1 − α) it will be in the interval
X̄ − zα/2 √σn , X̄ − zα/2 √σn .
This means that H0 is rejected with significance level α if
σ σ IITlogo
µ0 ∈ / X̄ − zα/2 √ , X̄ − zα/2 √ .
n n
DM EE 325
Bernoulli Populations
H0 : p ≤ p0 versus H1 : p > p0 . Pn
Random binary valued samples Xi . Sample statistic X = i=1 Xi .
n
X n i
Prob(X ≥ k) = p (1 − p)n−i
i
i=k
This is an increasing function in p. And if H0 is true, we will analyse
for p = p0 . Thus we have
n
X n i
Prob(X ≥ k) = p (1 − p0 )n−i
i 0
i=k
Reasonable rejection region would be X > K ∗ where
n
∗
X n i
K = min{k : p (1 − p0 )n−i < α}
i 0
i=k
It is easier to determine the p-value first. Let X = x.
n
X n i
p − value = p0 (1 − p0 )n−i IITlogo
i=x
i
Accept for α < p-value.
DM EE 325
Example
IITlogo
DM EE 325
Bernoulli Populations: Large Samples
IITlogo
DM EE 325
Testing Two Populations
Motivation:
Two candidate treatments for a disease; interested in fraction cured.
Two processes to manufacture a product; interested in fraction of defects.
Or closer to you—two coaching classes; interested in fraction of
successes.
Probability of success is pi for population i.
With independent sampling all successes are independent with
appropriate probability.
Unequal sample sizes—ni from population i; and Xi successes from ni
samples of population i.
Xi is a Binomial random variable with parameters (ni , pi ).
H0 : p1 = p2 versus H1 : p1 6= p2 .
IITlogo
DM EE 325
Testing Two Populations
Also under H0 the samples form a population of size (n1 + n2 ). And the
total number of successes is Binomial with parameters (n1 + n2 , p1 ).
Let X1 + X2 = k.
Note that we do not know p1 or p2 ; we are just checking to see if they
are equal.
Thus, under H0 , we expect X1 /n1 to be close to X2 /n2 .
Obtain the conditional probability of X1 , given k
n1
n2
i k−i
Prob(X1 = i|X1 + Xk ) = n1 +n2
k