check.dist.gradient | R Documentation |
Evaluates the gradient function of a distribution object and compares it to a numeric gradient computed from the log density function.
check.dist.gradient(ds, x, h=1e-7)
ds |
A distribution object with defined log density and gradient functions. |
x |
A point inside the support of |
h |
An offset from |
check.dist.gradient
computes the numeric derivative of
ds$log.density
at x
in each of its coordinates and
compares this to the value returned by ds$grad.log.density
.
If the relative error is greater than 0.001
, an error is
reported.
This function can be used when defining a distribution to ensure that the gradient function is implemented correctly.
make.dist
check.dist.gradient(N2weakcor.dist, runif(2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.