> For the complete documentation index, see [llms.txt](https://justinthezhu.gitbook.io/stat110/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://justinthezhu.gitbook.io/stat110/untitled-5.md).

# Section 6

**Moment** - Moments describe the shape of a distribution. The first three moments, are related to Mean, Variance, and Skewness of a distribution. The $$k-th$$ moment of a random variable *X* is

$$
\mu'\_k = E(X^k)
$$

Mean, Variance, and other moments (Skewness, Kurtosis, etc.) can be expressed in terms of the moments of a random variable.

* Mean $$\mu'\_1 = E(X)$$
* Variance $$\mu'\_2 = E(X^2) = Var(X) + (\mu\_1')^2$$

## Moment Generating Functions

**MGF** For any random variable X, the **moment generating function (MGF)** of X is an exponential function of X if it exists for a finitely-sized interval centered around 0. The MGF is just a function of a dummy variable *t*.

$$
M\_X(t) = E(e^{tX})
$$

**Why is it called the Moment Generating Function?** Because the $$k-th$$ derivative of the moment generating function evaluated 0 is the $$k-th$$ moment of *X*!

$$
\mu\_k' = E(X^k) = M\_X^{(k)}(0)
$$

Why does this relationship hold? By differentiation under the integral sign and then plugging in $$t=0$$:

$$
M\_X^{(k)}(t) = \frac{d^k}{dt^k}E(e^{tX}) = E(\frac{d^k}{dt^k}e^{tX}) = E(X^ke^{tX})
$$

$$
M\_X^{(k)}(0) = E(X^ke^{0X}) = E(X^k) = \mu\_k'
$$

## MGF Properties

**MGF of linear combination of X**: MGF of linear combination of X. If we have $$Y = aX + c$$, then $$M\_Y(t) = E(e^{t(aX + c)}) = e^{ct}E(e^{(at)X}) = e^{ct}M\_X(at)$$

**Uniqueness of the MGF**: *If it exists, the MGF uniquely defines the distribution*. This means that for any two random variables *X* and *Y*, they are distributed the same (their CDFs/PDFs are equal) if and only if their MGF’s are equal. You can’t have different PDFs when you have two random variables that have the same MGF.

**Summing Independent R.V.s by Multiplying MGFs**:

If *X* and *Y* are independent, then the MGF of the sum of two random variables is the product of the MGFs of those two random variables.

$$
M\_{(X+Y)}(t) = E(e^{t(X + Y)}) = E(e^{tX}e^{tY}) = E(e^{tX})E(e^{tY}) = M\_X(t) \cdot M\_Y(t)
$$

$$
M\_{(X+Y)}(t) = M\_X(t) \cdot M\_Y(t)
$$

## Joint Distributions

Sometimes we have more than one random variable of interest, and we want to study probabilities associated with all of the random variables. Instead of studying the distributions of $$X\_1, X\_2, X\_3$$ separately, we can study the distribution of the multivariate vector $$\textbf{X} = (X\_1, X\_2, X\_3)$$. Joint PDFs and CDFs are analogous to multivariate versions of univariate PDFs and CDFs. Usually joint PDFs and PMFs carry more information than the marginal ones do, because they account for the interactions between the various random variables. If, however, the random variables are independent, then the joint PMF/PDF is just the product of the marginals and we get no extra information by studying them jointly rather than marginally.

Both the Joint PMF and Joint PDF must be non-negative and sum/integrate to 1. ($$\sum\_x \sum\_y P(X=x, Y=y) = 1$$) ($$\int\_x\int\_y f\_{X,Y}(x,y) = 1$$). Like in the univariate case, you sum/integrate the PMF/PDF to get the CDF.

## Conditional Distributions

By Bayes' Rule, $$P(A|B) = \frac{P(B|A)P(A)}{P(B)}$$ Similar conditions apply to conditional distributions of random variables.

For discrete random variables: $$P(Y=y|X=x) = \frac{P(X=x, Y=y)}{P(X=x)} = \frac{P(X=x|Y=y)P(Y=y)}{P(X=x)}$$

For continuous random variables: $$f\_{Y|X}(y|x) = \frac{f\_{X,Y}(x, y)}{f\_X(x)} = \frac{f\_{X|Y}(x|y)f\_Y(y)}{f\_X(x)}$$


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://justinthezhu.gitbook.io/stat110/untitled-5.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
