# Section 7

**Multinomial (Multivariate Discrete)**

Let us say that the vector $$\vec{\textbf{X}} = (X\_1, X\_2, X\_3, \dots, X\_k) \sim {Mult}\_k(n, \vec{p})$$ where $$\vec{p} = (p\_1, p\_2, \dots, p\_k)$$

**Story** - We have *n* items, and then can fall into any one of the *k* buckets independently with the probabilities $$\vec{p} = (p\_1, p\_2, \dots, p\_k)$$.

**Example** - Let us assume that every year, 100 students in the Harry Potter Universe are randomly and independently sorted into one of four houses with equal probability. The number of people in each of the houses is distributed $$Mult\_4(100,\vec{p})$$, where $$\vec{p} = (.25, .25, .25, .25)$$. Note that $$X\_1 + X\_2 + \cdots + X\_4 = 100$$, and they are dependent.

**Multinomial Coefficient** The number of permutations of *n* objects where you have *n*1, *n*2, *n*3 . . . , *n\*\*k* of each of the different variants is the **multinomial coefficient**

$$
{n \choose n\_1n\_2\dots n\_k} = \frac{n!}{n\_1!n\_2!\dots n\_k!}
$$

**Joint PMF** - For $$n\_1, n\_2, n\_3 \dots, n\_k$$,

$$
P(X\_1 = n\_1, X\_2 = n\_2, \dots, X\_k = x\_k) = {n \choose n\_1n\_2\dots n\_k}p\_1^{n\_1}p\_2^{n\_2}\dots p\_k^{n\_k}
$$

**Lumping** If you lump together multiple categories in a multinomial, then it is still multinomial. A multinomial with two dimensions (success, failure) is a binomial distribution.

**Marginal PMF and Lumping**

$$
X\_i \sim Bin(n, p\_i)
$$

$$
X\_i + X\_j \sim Bin(n, p\_i + p\_j)
$$

$$
X\_1, X\_2, X\_3 \sim Mult\_3(n, (p\_1, p\_2, p\_3)) \Longrightarrow X\_1, X\_2 + X\_3 \sim Mult\_2(n, (p\_1, p\_2 + p\_3))
$$

$$
X\_1, X\_2, \dots, X\_{k-1} | X\_k = n\_k \sim Mult\_{k-1}\left(n - n\_k, \left(\frac{p\_1}{1 - p\_k}, \frac{p\_2}{1 - p\_k}, \dots, \frac{p\_{k-1}}{1 - p\_k}\right)\right)
$$

## Covariance and Correlation

**Covariance** is the two-random-variable equivalent of Variance, defined by the following:

$$
Cov(X, Y) = E\[(X - E(X))(Y - E(Y))] = E(XY) - E(X)E(Y)
$$

**Correlation** is a rescaled variant of Covariance that is always between -1 and 1.

$$
Corr(X, Y) = \frac{Cov(X, Y)}{\sqrt{Var(X)Var(Y)}} = \frac{Cov(X, Y)}{\sigma\_X\sigma\_Y}
$$

**Covariance and Indepedence** - If two random variables are independent, then they are uncorrelated. The inverse is not necessarily true.

**Covariance and Variance** - Covariance of a variable with itself is just the variance!

$$
Cov(X, X) = E(XX) - E(X)E(X) =  E(X^2) - \[E(X)]^2 = Var(X)
$$

$$
Var(X + Y) = Var(X) + Var(Y) + 2Cov(X, Y)
$$

$$
Var(X\_1 + X\_2 + \dots + X\_n ) = \sum\_{i = 1}^{n}Var(X\_i) + 2\sum\_{i < j} Cov(X\_i, X\_j)
$$

**Covariance and Linearity** - For random variables *W*, *X*, *Y*, *Z* and constants *b*, *c*:

$$
Cov(X + b, Y + c) = Cov(X, Y)
$$

$$
Cov(2X, 3Y) = 6Cov(X, Y)
$$

$$
Cov(W + X, Y + Z) = Cov(W, Y) + Cov(W, Z) + Cov(X, Y) + Cov(X, Z)
$$

**Covariance and Invariance** - Correlation, Covariance, and Variance are addition-invariant, which means that adding a constant to the term(s) does not change the value. Let *b* and *c* be constants

$$
Cov(X + b, Y + c) = Cov(X, Y)
$$

$$
Cov(2X, 3Y) = 6Cov(X, Y)
$$

$$
Cov(W + X, Y + Z) = Cov(W, Y) + Cov(W, Z) + Cov(X, Y) + Cov(X, Z)
$$

In addition to addition-invariance, Correlation is *scale-invariant*, which means that multiplying the terms by any constant does not affect the value. Covariance and Variance are not scale-invariant.

$$
Corr(2X, 3Y) = \frac{Cov(2X, 3Y)}{\sqrt{Var(2X)Var(3Y)}} = \frac{6Cov(X, Y)}{\sqrt{36Var(X)Var(Y)}} = \frac{Cov(X, Y)}{\sqrt{Var(X)Var(Y)}} = Corr(X, Y)
$$


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://justinthezhu.gitbook.io/stat110/untitled-6.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
