I am trying to understand how can we manually calculate the parameter with highest likelihoods. I don't want to use Maximum likelihood or any numerical method and want to understand the proccess. My explanation might be wrong, kindly let me know if I haven't explained it right.
If I have heights observations $X= [45,55]$ and have first parameter values of $\mu = [40,60]$ and $\sigma = [1,2]$
Likelihood can be given as $P(X|\theta) = N(X;\theta)$ in this case.
If we assume the observations i.i.d, what I understand is that we will have:
$$L(\theta|X) = \prod_{i=1}^{N} N(x_i;\theta) $$
Do I need to loop (product/summation) for each combination of $\mu$ and $sigma$ and argmax
? How can I formulate this?
What I understand is, I will will take all combinations of these parameters and evaluate for X and see which give maximum likelihood, but I am not sure about two values of X, should I take average of that?
Other thing that confuses me is regarding my other question, if I need to go through each combination of $\mu$ and $\sigma$ than isn't it same that we do for marginal likelihood $P(X)$ of Bayes rule, so aren't nominator(likelihood*prior) and marginal likelihood (denominator) in Bayes equally difficult to compute?
Update: I know how to derivate and know that it is effecient to estimate this with MLE, I just wanted make sense of difficulty as I need to compare it with marginal likelihood/evidence and see why they both arent same. I have just written the code to show what i mean by manual/brute-force approach here.
import numpy as np
import scipy.stats as stats
import math
arr = []
max_l = max_m = max_s = 0
for m in [40,60]:
for s in [1,2]:
if stats.norm.pdf(55,m,s)>max_l:
print('max is ',m,s)
max_m = m
max_s = s
max_l = stats.norm.pdf(55,m,s)
print(f"mu:{max_m},sigma:{max_s},max_likilihood:{max_l}")
This produces
mu:60,sigma:2,max_likilihood:0.00876415024678427
I am not sure, how to integrate different $X= [45,55]$ in this loop. Maybe multiple the two evaulation inside second loop stats.norm.pdf(55,m,s)*stats.norm.pdf(45,m,s)
?