1 of 25

Statistics and Distributions�

Prof. André E. Lazzaretti

lazzaretti@utfpr.edu.br

2 of 25

Summary Statistics and Independence

  • A statistic of a random variable is a deterministic function of that random variable.
  • The summary statistics of a distribution provide numbers that summarize and characterize the distribution.
  • We will discuss:
    • Mean and the variance.
    • Distributions.

3 of 25

Means and Covariances

4 of 25

Expected Value

Discrete: a fair six-sided die

X ∈ {1, 2, 3, 4, 5, 6}, p(x) = 1/6

g(x) = x

E[X] = Σ x·p(x) = (1+2+3+4+5+6)·1/6

= 21/6 = 3.5

g(x) = x²

E[X²] = (1+4+9+16+25+36)·1/6

= 91/6 ≈ 15.17

No roll ever shows 3.5: the expected value is a probability-weighted average, not a likely outcome.

5 of 25

Expected Value

Discrete: a fair six-sided die

X ∈ {1, 2, 3, 4, 5, 6}, p(x) = 1/6

g(x) = x

E[X] = Σ x·p(x) = (1+2+3+4+5+6)·1/6

= 21/6 = 3.5

g(x) = x²

E[X²] = (1+4+9+16+25+36)·1/6

= 91/6 ≈ 15.17

No roll ever shows 3.5: the expected value is a probability-weighted average, not a likely outcome.

Continuous: density p(x) = 2x on [0, 1]

Valid density: ∫₀¹ 2x dx = [x²]₀¹ = 1

g(x) = x

E[X] = ∫₀¹ x·2x dx = [2x³/3]₀¹

= 2/3 ≈ 0.67

g(x) = x²

E[X²] = ∫₀¹ x²·2x dx = [x⁴/2]₀¹

= 0.5

More mass sits near 1, so the mean lies above the midpoint 0.5.

6 of 25

Means and Covariances

7 of 25

Covariance: Example

Definition

Each pair has p = 1/4, so E[x] = 2.5, E[y] = 4

Cov[x, y] = mean of the products

= (3 + 0.5 + 0.5 + 3)/4 = 1.75

Shortcut: E[xy] − E[x]E[y]

E[xy] = (2 + 6 + 15 + 24)/4 = 11.75

Cov[x, y] = 11.75 − 2.5·4 = 1.75

Positive: y rises as x rises. Reversing y to (6, 5, 3, 2) flips every product: Cov = −1.75.

​

x

y

x − E[x]

y − E[y]

product

A

1

2

−1.5

−2

3

B

2

3

−0.5

−1

0.5

C

3

5

0.5

1

0.5

D

4

6

1.5

2

3

E[.]

2.5

4

0

0

1.75

8 of 25

Means and Covariances

9 of 25

Means and Covariances

10 of 25

Covariance Matrix and Correlation: Example

Covariance matrix

Same four points as the covariance example:

(1, 2), (2, 3), (3, 5), (4, 6), each p = 1/4

V[x] = (2.25 + 0.25 + 0.25 + 2.25)/4 = 1.25

V[y] = (4 + 1 + 1 + 4)/4 = 2.5

Cov[x, y] = 1.75

Σ: variances on the diagonal, Cov off it

Correlation

corr[x, y] = Cov[x, y] / √(V[x]·V[y])

= 1.75 / √(1.25 · 2.5)

= 1.75 / 1.77 ≈ 0.99

Rescale y by 10 (score out of 100)

V[y] = 250, Cov[x, y] = 17.5

corr = 17.5 / √(1.25 · 250) ≈ 0.99

Covariance grows with the units of y; correlation stays the same. Near +1, the points lie almost on a line.

​

x

y

x

1.25

1.75

y

1.75

2.5

11 of 25

Empirical Means and Covariances

12 of 25

Mean, Mode, and Median

The median is the “middle” value if we sort the values, i.e., 50% of the values are greater than the median and 50% are smaller than the median.

The mode is the most frequently occurring value.

​

13 of 25

Mean, Median, and Mode

Waiting times for 7 customers (minutes), sorted:

Mean = total ÷ count� = 42 ÷ 7� = 6 min

2, 3, 3, 4, 5, 7, 18

Count = 7 customers; total waiting time = 42 minutes.

Mean (average)

Median (middle)

Mode (most frequent)

Middle position = (7 + 1) ÷ 2� = 4th value�Median = 4 min

3 occurs twice; every other�value occurs once.�Mode = 3 min

The 18-minute wait pulls the mean upward: mean (6) > median (4) > mode (3).

14 of 25

Statistical Independence

15 of 25

Examples

X and Y are independent if knowing X does not change the distribution of Y.�Discrete case: P(X = x, Y = y) = P(X = x)P(Y = y), for every x and y.

Independent: two fair coin tosses

Dependent: draws without replacement

First toss (X) ↓ / Second toss (Y) →

X / Y

H

T

Total

H

1/4

1/4

1/2

T

1/4

1/4

1/2

Total

1/2

1/2

1

P(H, H) = 1/4 = (1/2)(1/2)�P(Y = H | X = H) = 1/2 = P(Y = H)

Bag: one red ball and one blue ball.�X = first draw; Y = second draw.�Draw twice without replacement.

P(X = R) = P(Y = R) = 1/2�P(Y = R | X = R) = 0 ≠ P(Y = R)

The first draw changes the second.

Important: zero covariance alone does not prove independence.

16 of 25

Gaussian Distribution

17 of 25

18 of 25

Mixture of Gaussian Distributions

19 of 25

Mixture of Gaussians

Solid blue: mixture p(x). Dashed gray: αp₁(x) and (1 − α)p₂(x). Dotted: mean E[x].

20 of 25

Bernoulli Distribution

21 of 25

Bernoulli Distribution

p(x | μ) = μx(1 − μ)1 − x for x ∈ {0, 1}. The animation moves μ between 0.05 and 0.95.

22 of 25

Binomial Distribution

23 of 25

Binomial Distribution

p(m | N, μ) = C(N, m) μm(1 − μ)N − m. Dotted line: mean Nμ. First μ moves (N = 10), then N steps (μ = 0.3).

24 of 25

Exercise

1. Expected value

A tip t (in $) has density p(t) = t/2 on [0, 2].

Show p(t) is valid, then find E[t] and V[t].

2. Covariance and correlation

Four customers, with x = drinks and y = bill ($):

(1, 3), (1, 5), (3, 7), (3, 9)

Find the empirical means, the covariance matrix Σ (divide by N) and corr[x, y].

3. Mean, median and mode

Seven waiting times (min): 1, 2, 2, 3, 5, 6, 16.

Find the mean, median and mode. Which one best describes a typical wait?

4. Statistical independence

X = 1 for a pastry and Y = 1 for a large drink, with P(X = 0, Y = 0) = 0.4 and 0.2 for each other pair.

Are X and Y independent? Find Cov[X, Y].

5. Mixture of Gaussians

Service time x (min) is N(2, 0.5²) for 70% of orders (simple drinks) and N(5, 1²) for 30% (espresso).

Find E[x] and V[x] for a random order.

6. Bernoulli and binomial

Customers buy a pastry independently, μ = 0.4.

(a) One customer, x ∈ {0, 1}: find E[x] and V[x].

(b) m buyers of N = 5: find p(m = 2), E[m], V[m].

25 of 25

Answers

1. Expected value

∫₀² t/2 dt = [t²/4]₀² = 1, so p(t) is valid.

E[t] = ∫₀² t²/2 dt = 4/3 ≈ $1.33

E[t²] = ∫₀² t³/2 dt = 2; V[t] = 2 − 16/9 = 2/9 ≈ 0.22

2. Covariance and correlation

E[x] = 2, E[y] = 6

V[x] = (1 + 1 + 1 + 1)/4 = 1

V[y] = (9 + 1 + 1 + 9)/4 = 5

Cov[x, y] = (3 + 1 + 1 + 3)/4 = 2

corr[x, y] = 2/√(1 · 5) ≈ 0.89

3. Mean, median and mode

Mean = 35/7 = 5, median = 3, mode = 2 (minutes)

Median is best; the 16-min wait pulls the mean up.

4. Statistical independence

P(X = 1) = P(Y = 1) = 0.2 + 0.2 = 0.4

P(X = 1, Y = 1) = 0.2 ≠ 0.4 · 0.4, so dependent

Cov[X, Y] = E[XY] − E[X]E[Y] = 0.2 − 0.16 = 0.04

5. Mixture of Gaussians

E[x] = 0.7 · 2 + 0.3 · 5 = 2.9 min

Within: 0.7 · 0.5² + 0.3 · 1² = 0.475

Between: 0.7 · 2² + 0.3 · 5² − 2.9² = 1.89

V[x] = 0.475 + 1.89 ≈ 2.37 min²

6. Bernoulli and binomial

(a) E[x] = μ = 0.4, V[x] = μ(1 − μ) = 0.24

(b) p(m = 2) = C(5, 2) · 0.4² · 0.6³ ≈ 0.35

E[m] = Nμ = 2, V[m] = Nμ(1 − μ) = 1.2

Σ =

1

2

2

5