Solving for the optimal weights - Maximizing the likelihood