Re: Gradient and Hessian matrix of cumulative normal ditribution
- To: mathgroup at smc.vnet.net
- Subject: [mg67942] Re: Gradient and Hessian matrix of cumulative normal ditribution
- From: "Valeri Astanoff" <astanoff at yahoo.fr>
- Date: Mon, 17 Jul 2006 06:52:03 -0400 (EDT)
- References: <e95aub$gu9$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hello Pratim, For a numerical computation of the hessian at a given point, you could proceed this way : In[1]:=<<Statistics` In[2]:=gradHess[fun_, {x1_,x2_}, {vx1_,vx2_}, eps_]:= Module[{data,f}, data=Table[{u1,u2,fun /. x1 -> u1 /. x2 -> u2}, {u1, vx1-eps, vx1+eps,eps}, {u2, vx2-eps, vx2+eps,eps}]//Flatten[#,1]&; f=Interpolation[data, InterpolationOrder -> {2,2}]; {grad[f[x1,x2],{x1,x2}], hess[f[x1,x2],{x1,x2}]}/. x1 -> vx1 /. x2 -> vx2 ]; grad[fun_,{x1_,x2_}] := {D[fun,x1],D[fun,x2]}; hess[fun_,{x1_,x2_}] := grad[grad[fun,{x1,x2}],{x1,x2}]; Example with your data : In[5]:=r = {{1, 0.2}, {0.2, 1}}; ndist = MultinormalDistribution[{0, 0}, r]; cdf=CDF[ndist,{x1,x2}] ; In[8]:=gradHess[cdf,{x1,x2},{1,0.8},0.001] Out[8]={{0.176603,0.233018},{{-0.192939,0.0816784},{0.0816784,-0.20275}}} With a higher precision, hessian is slightly modified : In[9]:=gradHess[cdf,{x1,x2},{1,0.8},0.000001] Out[9]={{0.176603,0.233018},{{-0.192604,0.0816569},{0.0816569,-0.20259}}} hth Valeri Astanoff