```Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Estimation Problem in Newton Method
Date: Mon, 14 Jun 2010 10:22:06 +0000 (UTC)
Organization: London School of Economics
Lines: 19
Message-ID: <hv4vse\$9h1\$1@fred.mathworks.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1276510926 9761 172.30.248.38 (14 Jun 2010 10:22:06 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 14 Jun 2010 10:22:06 +0000 (UTC)
Xref: news.mathworks.com comp.soft-sys.matlab:644685

Hi guys,

I got a problem in fitting a distribution in more than 5 observations by using newton method. Here is the code. Thanks!

d = [-1 5 2 -2 4 3 -3 6 3 1 -2]; % Data
x0=[0 1]'; % Starting values
x(:,1)=x0;
N=1;

for n=N:15
m = sum(d-x(1,n))/x(2,n);
s= -3/(2*(x(2,n)))+(1/(2*(x(2,n)^2)))*(sum((d-x(1,n)).^2));
G = [m ; s]; % Gradient Vector
mm = (-3/x(2,n));
ms = (-sum(d-x(1,n))/(2*x(2,n)^2));
ss = (3/(2*(x(2,n)^2)))-(sum((d-x(1,n)).^2))/(x(2,n)^3);
H = [ mm ms ; ms ss]; % Hessian Vector
x(:,n+1) =  x(:,n) - inv(H)*G;
end
```