Linear Algebra
Let bold lower case letters denote vectors and bold upper case letters denote matrices.
Machine learning algorithms apply operations on vectors. If we express , then we can express it as a column vector in pattern recognition:
- each dimension represents a extracted feature
- the “points” that represent objects are the head (tip, endpoint) of a feature vector.
The length or 2-norm of a vector is denoted :
- more generally, the p-norm of a vector is given by:
see inner product.
Eigenvectors & Eigenvalues
We call e an eigenvector and the corresponding eigenvalue of matrix A if:
Probability Theory
The axioms of probabilities are
- if , then
- i.e. if the even is guaranteed to be true in all possible states of the world, then its probability is 1.
- if , then
- i.e. “not ( and )”, meaning and are mutually exclusive (cannot both happen at once)
- i.e. probability of or .
- In plain words: If two events cannot happen at the same time, the probability of either happening is simply the sum of their individual probabilities (the sum rule / finite additivity).
Some consequences of these axioms:
- — i.e. all probabilities must fall within 0 and 1. - If our events are mutually exclusive and include all possible outcomes, they sum up to 1 - In our case:
- the entailment symbol is a tautology (a statement that is necessarily and always true).
- NOT (), AND (), OR ()
The Sum Rule (marginalization)
This is just the fraction of total events where both and happened at the same time.
denotes the sum of all occurences for this event: . If we only care about the probability of regardless of what is doing, I sum the entire column.
Dividing that column sum by the total N gives the second equation, the marginal probability:
To get the probability of one variable alone, sum out (marginalize) all possible values of the other variable. In other words, whenever you have the joint probability of two variables happening together, , but you only care about , you collapse or “erase” by adding up the probabilities across every possible value could take.
Let's say we have a table tracking people by Hair color () and Eye color ()
The cell for gives the joint probability . If you simply want the overall probability of someone having Brown Hair regardless of eye color, you add up:
Because we summed over all options for eye color, eye color disappears from the final result, leaving us with just . That process of summing away an unwanted variable is called marginalization.
The Product Rule
To find the chance that both things happen, find the chance that happens first, then multiply by the chance that happens given that already occurred.
Applying the two rules
- is the box chosen (red or blue), with prior probabilities of 0.4 and 0.6 respectively.
- is the fruit/item picked ( for green, orange for the other).
- In the red box: 2 green out of 8 total items
- In the blue box: 3 green out of 4 total items
We now want to estimate , i.e. the overall chance of picking a green object, regardless of which box it came from, which makes it a marginalization problem.
Because the color of the fruit depends on which box I pick from, I cannot evaluate F in isolation. The full chain of reasoning works in three steps:
- First, by the Sum Rule, I expand the marginal probability into the sum of all joint scenarios
- Second, by the Product Rule, I break each joint event into a sequence: the chance of choosing that box, multiplied by the chance of drawing green once I look inside that specific box:
- Plug in the counts from above. It was also given that and .
See Probability Density Function, Gaussian distribution.
Note that if during some calculus, I get , I should ask whether it’s a density or a probability.
Computing Weighted Averages and Expectations
Imagine we toss a coin, and for every head I get one cent, for every tail i get 2 cents. After 10 throws, how many cents do I expect to have?
First, we have a function which encodes how many cents we get for every toss:
It’s a fair coin 50/50:
By definition, the expectation is:
So after 10 throws, I expect to have cents.
We can use probability densities to estimate weighted averages of functions.
The average value of function under the distribution is called expectation of , and it is denoted by and it's given by:
The variance is defined as the expectation of :
where the expectation is the mean value of , .
So by using the integral from above, where , this definition is equivalent with:
Substituting back in yields:
- it is an indication of how much variability there is in x around its mean value.
In short: Variance is the mean of the squares minus the square of the mean.
Bayes’ Rule
Recall Bayes’ Theorem:
It’s easy to reach this form. From above, using the product rule:
Thus,
The denominator can be expressed using the sum and product rules as:
If we only have two outcomes, the hypothesis is either true () or false () — the denominator simply adds up the two ways this evidence could ever exist:
This is also known as the Law of Total Probability
some notes to myself
We recaped 1) joint probability and 2) conditional probability
The joint I always use the same equation: the probability that one of them happens (either x or y) times the probability that the other one happened, given the first already happened)
The conditional can be derived exactly from above, actually:
For this I don’t need Bayes’ Rule.
In the real world, however, I observe the evidence and want to infer the hidden cause (hypothesis/parameter), but my model or known data only tells me how causes produce evidence (). So I need to reason backwards, and that’s where Bayes’ Rule comes in.
Bayes’ Rule is literally just the inversion tool for when you only know how things run forward.