全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
4242 1
2009-12-20
悬赏 3 个论坛币 已解决
我想通过SAS完成求一个函数F的hessian矩阵和一阶导数,不知应该怎么求?能否告知是调用哪个模块?请大家给我指个方向,谢谢!

最佳答案

bobguy 查看完整内容

Unfortunately, SAS does not provide gradian and hessian for a given function. If the function is explicitly defined, one could provide the information(simple math mostly) to some sas procs. Otherwise most sas procs will calculate it for you WITHIN those procs using finite difference method. Here is an example of the Newton-Raphson methed in Finite difference formulae for a quadratic equation. I ...
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2009-12-20 19:20:05
Unfortunately, SAS does not provide gradian and hessian for a given function. If the function is explicitly defined, one could provide the information(simple math mostly) to some sas procs. Otherwise most sas procs will calculate it for you WITHIN those procs using finite difference method.

Here is an example of the Newton-Raphson methed in Finite difference formulae for a quadratic equation. I hope this sheds light on the approach.

HTH.


501  ****Newton's Method;
502  ***Finite difference formulae;
503  ***example f(x)=x^2 + x -3;
504
505  ***min f(-0.5) = -3.25   ;
506
507  %macro f(x);
508       (&x)**2+(&x)-3
509  %mend;
510
511  %macro f1st(x, h);
512   (  (  %f(&x+&h) ) -  (  %f(&x-&h)  ) )/(2*&h)
513  %mend;
514
515  %macro f2nd(x, h);
516   (  (  %f(&x+&h)  )  - 2*( %f(&x) ) +  ( %f(&x-&h) ) )/(&h**2)
517  %mend;
518
519  data _null_;
520
521   x0=90;h=0.006;
522   do i = 1 to 100;
523       z1=%f1st(x0, h); z2=%f2nd(x0, h);
524
525      x=x0 - z1 /z2;
526       if abs  ( %f1st(x, h) )  <1e-6 then do;
527            *evaluate function values at optimal point;
528            z0=%f(x);  z1=%f1st(x, h);  z2=%f2nd(x, h);
529            put i= x= z0= z1= z2=;
530            stop;
531       end;
532       else x0=x;
533   end;
534  run;

i=1 x=-0.499999835 z0=-3.25 z1=3.2998479E-7 z2=2
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群