全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Gauss专版
2995 8
2011-02-19
各位朋友,在gauss中如何求偏导数?谢谢!
二维码

扫码加我 拉你入群

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

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

全部回复
2011-2-20 10:10:13
zhangtao 发表于 2011-2-19 11:58
各位朋友,在gauss中如何求偏导数?谢谢!
gradp 不行么?
二维码

扫码加我 拉你入群

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

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

2011-2-20 15:40:58
Gradp 的官方解释是:Computes first derivative of a function.
所以用这个命令只能求一阶导数,那如何求一阶和二阶偏导数?
二维码

扫码加我 拉你入群

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

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

2011-2-20 15:43:04
gradp

Purpose

Computes the gradient vector or matrix (Jacobian) of a vector-valued function that has been defined in a procedure. Single-sided (forward difference) gradients are computed.

Format

g = gradp(&f,x0);

Input


&f
a pointer to a vector-valued function (f:Kx1 - > Nx1) defined as a procedure. It is acceptable for f(x) to have been defined in terms of global arguments in addition to x, and thus f can return an Nx1 vector:


  
proc f(x);


  
  
retp( exp(x.*b) );


  
endp;

x0
Kx1 vector of points at which to compute gradient.


Output


g
NxK matrix containing the gradients of f with respect to the variable x at x0.


Remarks

gradp will return a row for every row that is returned by f. For instance, if f returns a scalar result, then gradp will return a 1xK row vector. This allows the same function to be used regardless of N, where N is the number of rows in the result returned by f. Thus, for instance, gradp can be used to compute the Jacobian matrix of a set of equations.

Example

proc myfunc(x);

retp( x.*2 .* exp( x.*x./3 ) );

endp;



x0 = 2.5|3.0|3.5;

y = gradp(&myfunc,x0);

  


It is a 3x3 matrix because we are passing it 3 arguments and myfunc returns 3 results when we do that; the off-diagonals are zeros because the cross-derivatives of 3 arguments are 0.
二维码

扫码加我 拉你入群

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

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

2011-2-20 16:36:30
proc myfunc(x);

retp(x.*2.*exp(x.*x./3));

endp;



x0= 2.5|3.0|3.5;

y=gradp(&myfunc,x0);

运行以上例子,怎么会提示以下错误?谢谢!
(0) : error G0008 : '; retp(x.*2.*exp(x.*x./3))' : Syntax error
二维码

扫码加我 拉你入群

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

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

2011-2-22 20:59:12
>> y;

       82.989017       0.00000000       0.00000000
      0.00000000        281.19753       0.00000000
      0.00000000       0.00000000        1087.9541

这是我的运行结果,没出现错误呀……
二维码

扫码加我 拉你入群

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

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

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

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