I am a beginner coder and was working on a data science project that needed to plot the likelihood of a population characteristics regarding to mu, the population mean, using the normal distribution.
So I created a normal distribution density function that takes a variable x (that draws the curve) and mu (the parameter I'm trying to find), (with the variance sigma^2 already predefined).
But I'm having trouble creating a list of functions with a varying parameter mu, while stille containing x.
The normal distribution density function that I created looks something like this :
def n(x, mu):
return #normal distribution
Then I created a list of mu ranging from 0 to 100 and a list of n_functions that takes the corresponding mu argument using the lambda function :
mu_list = [mu for mu in np.arange(0, 100, .1)]
n_list = []
for mu in mu_list :
n_list.append(lambda x : n(x, mu) )
But then when I execute one of the functions in the list i realised that they were all using the same mu parameters, whereas I wanted to have them varying from 0 to 100.
n_list[0](x) == n_list[100](x)
Can anyone explain to me what I did wrong ?