Doubt in Linear Reg by 'MLE' method - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: Doubt in Linear Reg by 'MLE' method (/thread-26642.html) |
Doubt in Linear Reg by 'MLE' method - kumarants - May-08-2020 import numpy as np from scipy.optimize import minimize import matplotlib.pyplot as plt def lik(parameters): m=parameters[0] b=parameters[1] sigma=parameters[2] for i in np.arange(0,len(x)): y_exp=m*X+b L=(len(x)/2*np.log(2*np.pi)+len(x)/2*np.log(sigma**2)+1/(2*sigma**2)*sum((y-y_exp**2)) return L x=np.array([1,4,5,6,9]) y=np.array([2,6,7,9,15]) lik.model=minimize(lik,np.array([2,2,2]),method='L-BFGS-B') Please clarify in resolving this error
RE: Doubt in Linear Reg by 'MLE' method - nnk - May-08-2020 I can see parenthesis is not closed for below statement in your code L=(len(x)/2*np.log(2*np.pi)+len(x)/2*np.log(sigma**2)+1/(2*sigma**2)*sum((y-y_exp**2))) Hope this is enough... I can see parenthesis is not closed for below statement in your code L=(len(x)/2*np.log(2*np.pi)+len(x)/2*np.log(sigma**2)+1/(2*sigma**2)*sum((y-y_exp**2)))Hope this is enough... RE: Doubt in Linear Reg by 'MLE' method - kumarants - May-08-2020 Yes...now solved...Thank you |