##### 5.2.1.1 Basic concepts to review

*If some characters seem to be missing, it's because MathJax is not loaded correctly. Refreshing the page should fix it.*

###### Random variable

Formally, a random variable is a measurable function from a set of possible outcomes to a measurable space . The probability that takes on a value in a measurable set is written as:

, where is the probability measure on .

The randomness comes from the randomness of the outcomes in .

Informally, a random variable is a variable that probabilistically takes on different values. You can think of a random variable as being like a variable in a programming language. They take on values, have types, and have domains over which they are applicable.

*Random variable* is a general concept. Almost everything in life can be described using a random variable. The time it takes you to commute to work is a normal random variable. The number of people you date before finding your life partner is a geometric random variable.

###### Probability distribution

A probability distribution is a function that describes possible outcomes of a random variable along with its corresponding probabilities.

###### Normal random variable

Also known as the Gaussian random variable, this is the single most important random variable. It's parameterized by a random variable, parametrized by a mean and variance .

The term we want to go over in this function is . Intuitively, it punishes the value far away from the mean, but the punishment is less when the variance is high. The term is normalization so that it integrates to 1.

Here is the PDF of the normal distribution with different parameters.

###### Categorical distribution

Also known as the multinoulli distribution, the categorical distribution is a generalization of the Bernoulli distribution. It describes the possible results of a random variable that can take on one of possible categories, with the probability of each category separately specified.

###### Binomial random variable

A binomial random variable represents the number of successes in n successive independent trials, each succeeding with probability and failing with probability . One example is the number of heads in coin flips, each with a 0.5 probability of landing head. The binomial distribution is the basis for the binomial test for statistical significance. When there's only 1 trial, it's known as the Bernoulli distribution.

Below is the PMF of the binomial distribution with different parameters.

###### Multinomial random variable

The multinomial random variable is a generalization of the binomial distribution. Instead of having only two outcomes like with a coin flip, it can have multiple outcomes like with a k-sided die. When the number of trials is 1, it's the categorical distribution.

###### Poisson random variable

The Poisson distribution is, in my opinion, among the more interesting distributions. It expresses the probability of a given number of events occurring in a fixed interval if these events occur with a known constant rate. This rate is denoted as . Note that the Poisson distribution is *memoryless*, which means the probability that an event occurs is independent of the time since the last event.

One pretty neat perspective is to see the Poisson distribution as an approximation of the Binomial where is large, is small, and . For example, a Binomial random variable of 10000 trials with the success rate of 0.01 can be seen as a Poisson random variable of events happening every 10000 * 0.01 = 100 trials.

Below is the PMF of the Poisson distribution with different values of , made by Skbkekas.

Poisson vs binomial according to Data Science Central:If your question has an average probability of an event happening per unit (i.e. per unit of time, cycle, event) and you want to find the probability of a certain number of events happening in a period of time (or a number of events), then use the Poisson Distribution.

If you are given an exact probability and you want to find the probability of the event happening a certain number of times out of x (i.e. 10 times out of 100, or 99 times out of 1000), use the Binomial Distribution formula.

###### Geometric random variable

If each trial has the probability of success of p, then the geometric random variable represents the number of independent trials until the first success. One example is the number of candidates you have to interview until you hire someone.

Below is the PMF of the geometric distribution with different values of , made by Skbkekas.

###### Beta random variable

Beta is my favorite distribution (what do you mean you don't have a favorite distribution?). It's a random variable that estimates another random variable.

Say, we have a coin with an unknown probability of turning heads. Let represent this probability. After flips, we get heads and tails. We might want to estimate that . However, this is unreliable, especially if is small. We'd like to say something like this: can also be more than, less than, or equal to , the values further away from having a smaller probability. And the higher the value of , the higher the probability of being . The beta distribution allows you to do that.

The beta random variable is represented using two variables: to represent the number of successes and to represent the number of failures. The beta distribution can represent beyond coin flips. In fact, and can represent continuous value (though they can't be non-positive).

is the Gamma function: . The term is the normalization constant so that the expression integrates to 1.

We can also incorporate a priori belief in the beta distribution. For example, if before even flipping the coin, we believe that the coin has a moderate chance of being biased towards heads, we can set the a priori to be . Then after 10 coin flips of which 7 are heads and 3 are tails, we can update the distribution to be . In fact, in Bayesian inference, the beta distribution is the conjugate prior probability distribution for Bernoulli, binomial, negative binomial, and geometric distributions.

Below is the PDF of the geometric distribution with different parameters.

The multivariate generalization of the beta random variable is called Dirichlet.

###### Exponential family of distributions

A class of distributions is in the exponential family if it can be written in the form:

where:

- is the parameter of the distribution, e.g. if it's the normal distribution then .
- is the sufficient statistic. For most distributions, . For the beta distribution, .
- is the normalization constant so that the expression integrates to 1.

The exponential family of distribution is important because it provides a general framework for working with many of the most common distributions, including the Bernoulli, binomial, Poisson, normal, and more.

You can write the PMF and PDF of those distributions to match the form defined above. For example, given the Poisson random variable , with , belongs to the exponential family because can be written in the form .

More examples that show that other distributions belong to the exponential family can be found here and here.

###### Marginal distribution, joint distribution, conditional distribution

A joint probability distribution gives the probability of two or more events happening at the same time. For example, given two discrete random variables and , the joint probability distribution of and gives the probability of for any combination of value and value .

A marginal distribution gives the probabilities of various values of a subset of variables without reference to the values of the other variables. For example, given the joint distribution of and , we want to have a marginal probability distribution of without reference to .

A conditional probability distribution gives the probability of a subset of events occurring assuming that other events also occur. One example is .

*This book was created by Chip Huyen with the help of wonderful friends. For feedback, errata, and suggestions, the author can be reached here. Copyright ©2021 Chip Huyen.*