cpplib04.gms : Test extrinsic functions in cppcclib

Description

Here we test that the extrinsic function in cppcclib for the tri-variate
normal distribution CDF works as expected, by comparing the function
values to precomputed ones and derivative values to numeric derivatives.

Note that both the GAMS extrinsic values and the precomputed values for the
CDF are computed via an iterative approximation scheme that has
low precision compared to other functions (e.g. uni- or bi-variate
normal CDF).  Precision depends on the inputs.  For the interesting
case (x/y/z not far from zero, r/s/t closer to zero so the covariance
matrix has nice rank) precision better than 1e-8 is not assured.

Contributor: Steve


Small Model of Type : GAMS


Category : GAMS Test library


Main file : cpplib04.gms

$title Test extrinsic functions in cppcclib (CPPLIB04,SEQ=655)

$onText
Here we test that the extrinsic function in cppcclib for the tri-variate
normal distribution CDF works as expected, by comparing the function
values to precomputed ones and derivative values to numeric derivatives.

Note that both the GAMS extrinsic values and the precomputed values for the
CDF are computed via an iterative approximation scheme that has
low precision compared to other functions (e.g. uni- or bi-variate
normal CDF).  Precision depends on the inputs.  For the interesting
case (x/y/z not far from zero, r/s/t closer to zero so the covariance
matrix has nice rank) precision better than 1e-8 is not assured.

Contributor: Steve
$offText
$onDollar

$funcLibIn mvnLib cppcclib

function xdf    'CDF of trivariate normal'  / mvnLib.cdfTVN /;

$if not set INFILE $set INFILE tvnInit

$macro f0         xdf.value(      data(T,'x'),data(T,'y'),data(T,'z'),data(T,'r'),data(T,'s'),data(T,'t'))
$macro f1(j)      xdf.grad (j:    data(T,'x'),data(T,'y'),data(T,'z'),data(T,'r'),data(T,'s'),data(T,'t'))
$macro f1n(j)     xdf.gradn(j:    data(T,'x'),data(T,'y'),data(T,'z'),data(T,'r'),data(T,'s'),data(T,'t'))
$macro f2(j1,j2)  xdf.hess (j1:j2:data(T,'x'),data(T,'y'),data(T,'r'),data(T,'r'),data(T,'s'),data(T,'t'))
$macro f2n(j1,j2) xdf.hessn(j1:j2:data(T,'x'),data(T,'y'),data(T,'r'),data(T,'r'),data(T,'s'),data(T,'t'))

$include extrtest3a.inc

fdata(T, 'f_') = data(T,'cdf');

scalar
 aeps0       'absolute error tolerance: function' / 1e-7 /
 reps0       'relative error tolerance: function' / 1e-8 /
 aeps1       'absolute error tolerance: grad'     / 2e-2 /
 reps1       'relative error tolerance: grad'     / 2e-2 /
 aeps2       'absolute error tolerance: hess'     / 1e-2 /
 reps2       'relative error tolerance: hess'     / 1e-2 /
 aepsr       'absolute error tolerance: hess Xr'  / .01 /
 repsr       'relative error tolerance: hess Xr'  / .15 /
 ;

$include extrtest3b.inc