Here is the derivation of Maximum Likelihood Estimation.