Bernoulli Distribution :
Expectation and Variance
Bernoulli Sequence
Suppose we have a sequence of independent , then we call a Bernoulli process
- essentially just a sequence of 0’s and 1’s.
- i.e. if takes values with
Per Bayes’ Theorem, when you have a sequence of independent observations, the joint probability of seeing that specific sequence is the product of their individual probabilities. This is the likelihood function. Because multiplying many small probabilities causes numerical underflow and is difficult to differentiate, we take the natural logarithm. The log function converts the product into a sum , resulting in the log-likelihood function .
The MLE for the parameter is found by maximizing the log-likelihood. The MLE answers a reverse question: given the data sequence we actually observed, what is the most optimal, probable value for the unknown parameter ? To find the maximum of the log-likelihood function, we take its first derivative with respect to and set it to zero.
This derivation formally proves that the most statistically sound estimate for the probability of a Bernoulli event is simply the empirical sample mean — the total number of successes divided by the total number of trials.
The Categorical Distribution
The Bernouli distribution can be extended to multiple classes, rather than just a binary success or failure.
One-of-K Encoding: To mathematically handle multiple classes, an observation is represented as a vector using one-of-K (or one-hot) encoding. If the observed class is , then the -th element of the vector is 1 (), and all other elements are 0 ().
The Probability Mass Function (i.e. probability of observing a specific vector ) is defined as:
- because of one-hot-encoding all exponents are except for the single index where
Just as the Bernoulli MLE yields the empirical sample mean for a single probability, the MLE for the Categorical distribution calculates the empirical probability for each class. The estimator sums the values of the -th index across all independent observations. Since is only when class is observed, the numerator represents the absolute count of times class appeared in the dataset. Dividing this count by the total number of measurements gives the optimal parameter estimate for that specific class.