Description Usage Arguments Details Value Examples
This function computes the 1st and 2nd symbolic derivatives of the loss function (gradient/hessian) provided.
1 2 | SymbolicLoss(fc, fc_ref = NULL, verbose = TRUE, plotting = TRUE,
xmin = -10, xmax = 10, xpoint = 20, ...)
|
fc |
The loss function to derivate twice. Gradient and hessian are computed and returned into a list to the user. |
fc_ref |
The loss function for reference to compare when using |
verbose |
Whether the functions should be printed to the console while being returned. Defaults to |
plotting |
Whether the functions should be plotted for debugging purposes. Defaults to |
xmin |
The x-axis minimum when plotting data when |
xmax |
The x-axis maximum when plotting data when |
xpoint |
How many poitns to plot when |
... |
Arguments to pass to |
This function cannot handle any type of input. It cannot handle sums or loops in the function code. It handles the following, in the alphabetic order:
Multiplication
Division
Power
Absolute value function
Arcosine function
Hyperbolic Arcosine function
Arsine function
Hyperbolic Arcsine function
Arctangent function
Arctangent angle function between the x-axis and the vector from the origin (x,y), atan=y/x if x>0 and y>0
Hyperbolic Arctangent function
Modified Bessel function of the first kind
Bessel function of the first kind
Modified Bessel function of the second kind
Sphereical Bessel function
Beta function (Eulerian integral of the first kind)
Cosine function
Hyperbolic cosine function
Cosine function with argument multiplicand pi
Density binomial function
First derivative of the logarithm of the gamma function
Density normal function
Exponential function
Exponential function minus 1
Gamma function (Mellin transform of the negative exponential function)
Natural logarithm of the beta function
Natural logarithm of the absolute value of the gamma function
Natural (e) logarithm function
Common (10) logarithm function
Natural (e) logarithm function with 1 added to the argument
Binary (2) logarithm function
Logarithm function of base b (base)
Normal distribution function
Polygamma function (degree specified by deriv)
Replicate "times" elements of vectors and lists
Replicate "length.out" elements of vectors and lists
Sign function
Sine function
Hyperbolic sine function
Sine function with argument multiplicand pi
Square root function
Tangent function
Hyperbolic tangent function
Tangent function with argument multiplicand pi
Second derivative of the logarithm of the gamma function
A list with grad
as the gradient of the loss function and hess
as the hessian of the loss function.
1 2 3 4 5 6 7 8 9 | # Median Fair loss (just the Fair loss...)
library(Deriv) # loads the required library
fc <- function(x, c=2, t=0.5)
{(c^2) * ((abs(x) / c) - log(1 + (abs(x) / c))) * ifelse(x > 0, 2 * t, 2-2*t)}
fc_ref <- function(x) {x^2} # Quadratic loss, aka Mean Squared Error
SymbolicLoss(fc = fc,
fc_ref = fc_ref,
verbose = TRUE,
plotting = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.