Math - Probability, Random Variables and Distributions (Notes)
Random Variable
- Let the sample space of random experiment be S, X = X(e) is a real-valued single-valued function defined on sample space S. X = X(e) is called a random variable.
- Essentially a function about basic events, independent variable is basic event, dependent variable is function value.
Random Experiment:
Satisfies:
(1) Repeatability: Experiment can be repeated under same conditions;
(2) Knowability: Each experiment has more than one possible result, and all possible results of experiment can be clearly identified in advance;
(3) Uncertainty: Before conducting an experiment, cannot determine which result will appear, but one of the results must appear.
Sample Space:
The set of all basic results of a random experiment is called the sample space. Elements of sample space are called sample points or basic events. That is, sample space is essentially a set, each element is a result of one random experiment.
Sample and Random Variable:
Samples in mathematical statistics have duality, that is, samples can be viewed both as a set of observed values and as random variables.
First, before sampling. Cannot determine sample’s observed values, so can be viewed as random variables.
Second, after sample is extracted and observed, sample has specific observed values, so can be viewed as a set of determined values.
Probability Distribution
Let’s look at the simplest coin toss event. Theoretically, probability of heads and tails are both 50%

Try with Code
function flipCoin(){
for (let index = 0; index < 10; index++) {
// Round random number
let randomNum = Math.round(Math.random())
// If random is 1 then heads
if(randomNum === 1){
console.log('Heads')
}else{
console.log('Tails')
}
}
}
flipCoin()
Try 10 times result:

Try 1000 times

More sampling times in statistics, closer to theoretical situation
Probability distribution actually describes probability law of random variables.
Discrete Distribution Models
Bernoulli Distribution
This is distribution of a single random variable, and this variable only has two values, 0 or 1.

or

Example:
Assume you want to have children, probability of boy is p, probability of girl is 1-p
Bernoulli experiment: Have one child
Bernoulli distribution: Have one child, probability of boy is p, probability of girl is 1-p, this is Bernoulli distribution

Categorical Distribution (also called Multinoulli Distribution)
It describes a single random variable with k different states. Here k is a finite value, if k is 2, then categorical distribution becomes Bernoulli distribution. I’ve listed the formula and diagram of this distribution.

Normal Distribution
Formula:

In this formula there are two parameters, μ represents mean, σ represents variance.
