Home > wafo > kdetools > deriv2.m

# deriv2

## PURPOSE

High order partial derivatives of the Gaussian kernel.

k=deriv2(x,y,d)

## DESCRIPTION

``` DERIV2  High order partial derivatives of the Gaussian kernel.

CALL:  k = deriv2(x,y,dstr)

k   =  partial derivatives of the 2D Gaussian kernel
at the point (X,Y).
x,y  = evaluation points
dstr = string defininfg the type of partial derivative

Example: 4'th p. derivative wrt. x and 2'nd p. derivative wrt. y at (0,0)

k42=deriv2(0,0,'42')

## CROSS-REFERENCE INFORMATION

This function calls:
 mkernel Multivariate Kernel Function. str2num Convert string matrix to numeric array.
This function is called by:
 hldpi2 L-stage DPI estimate of smoothing parameter for 2D data hldpi2fft L-stage DPI estimate of smoothing parameter for 2D data

## SOURCE CODE

```001 function k=deriv2(x,y,d)
002 %DERIV2  High order partial derivatives of the Gaussian kernel.
003 %
004 % CALL:  k = deriv2(x,y,dstr)
005 %
006 %  k   =  partial derivatives of the 2D Gaussian kernel
007 %         at the point (X,Y).
008 % x,y  = evaluation points
009 % dstr = string defininfg the type of partial derivative
010 %
011 % Example: 4'th p. derivative wrt. x and 2'nd p. derivative wrt. y at (0,0)
012 %
013 %          k42=deriv2(0,0,'42')
014 %
016
017 %tested on: matlab 5.3
018 %revised pab 16.10.1999
019 %  updated to matlab 5.x + documentation
020 % from kdetools by   Christian C. Beardah 1995
021
022 k=zeros(size(x));
023
024 xd=str2num(d(1));
025 yd=str2num(d(2));
026
027 switch xd,
028 case 0,
029   xterm=1;
030 case 2,
031   xterm=x.^2-1;
032 case 4,
033   xterm=x.^4-6*x.^2+3;
034 case 6,
035   xterm=x.^6-15*x.^4+45*x.^2-15;
036 case 8,
037   xterm=x.^8-28*x.^6+210*x.^4-420*x.^2+105;
038 end;
039 switch yd,
040 case 0,
041   yterm=1;
042 case 2,
043   yterm=y.^2-1;
044 case 4,
045   yterm=y.^4-6*y.^2+3;
046 case 6,
047   yterm=y.^6-15*y.^4+45*y.^2-15;
048 case 8,
049   yterm=y.^8-28*y.^6+210*y.^4-420*y.^2+105;
050 end;
051
052 k=xterm.*yterm.*mkernel(x,y,'gauss');```

Mathematical Statistics
Centre for Mathematical Sciences
Lund University with Lund Institute of Technology

Comments or corrections to the WAFO group

Generated on Thu 06-Oct-2005 02:21:16 for WAFO by m2html © 2003