Distributions {RTMB} | R Documentation |
Distributions and special functions for which AD is implemented
Description
The functions listed in this help page are all applicable for AD types. Method dispatching follows a simple rule: If at least one argument is an AD type then a special AD implementation is selected. In all other cases a default implementation is used (typically that of the stats package). Argument recycling follows the R standard (although wihout any warnings).
Usage
## S4 method for signature 'ad,ad.,logical.'
dexp(x, rate = 1, log = FALSE)
## S4 method for signature 'num,num.,logical.'
dexp(x, rate = 1, log = FALSE)
## S4 method for signature 'osa,ANY,ANY'
dexp(x, rate = 1, log = FALSE)
## S4 method for signature 'simref,ANY,ANY'
dexp(x, rate = 1, log = FALSE)
## S4 method for signature 'ad,ad,ad.,logical.'
dweibull(x, shape, scale = 1, log = FALSE)
## S4 method for signature 'num,num,num.,logical.'
dweibull(x, shape, scale = 1, log = FALSE)
## S4 method for signature 'osa,ANY,ANY,ANY'
dweibull(x, shape, scale = 1, log = FALSE)
## S4 method for signature 'simref,ANY,ANY,ANY'
dweibull(x, shape, scale = 1, log = FALSE)
## S4 method for signature 'ad,ad,ad,logical.'
dbinom(x, size, prob, log = FALSE)
## S4 method for signature 'num,num,num,logical.'
dbinom(x, size, prob, log = FALSE)
## S4 method for signature 'osa,ANY,ANY,ANY'
dbinom(x, size, prob, log = FALSE)
## S4 method for signature 'simref,ANY,ANY,ANY'
dbinom(x, size, prob, log = FALSE)
## S4 method for signature 'ad,ad,ad,missing,logical.'
dbeta(x, shape1, shape2, log)
## S4 method for signature 'num,num,num,missing,logical.'
dbeta(x, shape1, shape2, log)
## S4 method for signature 'osa,ANY,ANY,ANY,ANY'
dbeta(x, shape1, shape2, log)
## S4 method for signature 'simref,ANY,ANY,ANY,ANY'
dbeta(x, shape1, shape2, log)
## S4 method for signature 'ad,ad,ad,missing,logical.'
df(x, df1, df2, log)
## S4 method for signature 'num,num,num,missing,logical.'
df(x, df1, df2, log)
## S4 method for signature 'osa,ANY,ANY,ANY,ANY'
df(x, df1, df2, log)
## S4 method for signature 'simref,ANY,ANY,ANY,ANY'
df(x, df1, df2, log)
## S4 method for signature 'ad,ad.,ad.,logical.'
dlogis(x, location = 0, scale = 1, log = FALSE)
## S4 method for signature 'num,num.,num.,logical.'
dlogis(x, location = 0, scale = 1, log = FALSE)
## S4 method for signature 'osa,ANY,ANY,ANY'
dlogis(x, location = 0, scale = 1, log = FALSE)
## S4 method for signature 'simref,ANY,ANY,ANY'
dlogis(x, location = 0, scale = 1, log = FALSE)
## S4 method for signature 'ad,ad,missing,logical.'
dt(x, df, log)
## S4 method for signature 'num,num,missing,logical.'
dt(x, df, log)
## S4 method for signature 'osa,ANY,ANY,ANY'
dt(x, df, log)
## S4 method for signature 'simref,ANY,ANY,ANY'
dt(x, df, log)
## S4 method for signature 'ad,ad,ad,missing,logical.'
dnbinom(x, size, prob, log)
## S4 method for signature 'num,num,num,missing,logical.'
dnbinom(x, size, prob, log)
## S4 method for signature 'osa,ANY,ANY,ANY,ANY'
dnbinom(x, size, prob, log)
## S4 method for signature 'simref,ANY,ANY,ANY,ANY'
dnbinom(x, size, prob, log)
## S4 method for signature 'ad,ad,logical.'
dpois(x, lambda, log = FALSE)
## S4 method for signature 'num,num,logical.'
dpois(x, lambda, log = FALSE)
## S4 method for signature 'osa,ANY,ANY'
dpois(x, lambda, log = FALSE)
## S4 method for signature 'simref,ANY,ANY'
dpois(x, lambda, log = FALSE)
## S4 method for signature 'ad,ad,missing,ad.,logical.'
dgamma(x, shape, scale, log)
## S4 method for signature 'num,num,missing,num.,logical.'
dgamma(x, shape, scale, log)
## S4 method for signature 'osa,ANY,ANY,ANY,ANY'
dgamma(x, shape, scale, log)
## S4 method for signature 'simref,ANY,ANY,ANY,ANY'
dgamma(x, shape, scale, log)
## S4 method for signature 'ad,ad.,ad.,missing,missing'
pnorm(q, mean, sd)
## S4 method for signature 'num,num.,num.,missing,missing'
pnorm(q, mean, sd)
## S4 method for signature 'ad,ad,missing,ad.,missing,missing'
pgamma(q, shape, scale)
## S4 method for signature 'num,num,missing,num.,missing,missing'
pgamma(q, shape, scale)
## S4 method for signature 'ad,ad,missing,missing'
ppois(q, lambda)
## S4 method for signature 'num,num,missing,missing'
ppois(q, lambda)
## S4 method for signature 'ad,ad.,missing,missing'
pexp(q, rate)
## S4 method for signature 'num,num.,missing,missing'
pexp(q, rate)
## S4 method for signature 'ad,ad,ad.,missing,missing'
pweibull(q, shape, scale)
## S4 method for signature 'num,num,num.,missing,missing'
pweibull(q, shape, scale)
## S4 method for signature 'ad,ad,ad,missing,missing,missing'
pbeta(q, shape1, shape2)
## S4 method for signature 'num,num,num,missing,missing,missing'
pbeta(q, shape1, shape2)
## S4 method for signature 'ad,ad.,ad.,missing,missing'
qnorm(p, mean, sd)
## S4 method for signature 'num,num.,num.,missing,missing'
qnorm(p, mean, sd)
## S4 method for signature 'ad,ad,missing,ad.,missing,missing'
qgamma(p, shape, scale)
## S4 method for signature 'num,num,missing,num.,missing,missing'
qgamma(p, shape, scale)
## S4 method for signature 'ad,ad.,missing,missing'
qexp(p, rate)
## S4 method for signature 'num,num.,missing,missing'
qexp(p, rate)
## S4 method for signature 'ad,ad,ad.,missing,missing'
qweibull(p, shape, scale)
## S4 method for signature 'num,num,num.,missing,missing'
qweibull(p, shape, scale)
## S4 method for signature 'ad,ad,ad,missing,missing,missing'
qbeta(p, shape1, shape2)
## S4 method for signature 'num,num,num,missing,missing,missing'
qbeta(p, shape1, shape2)
## S4 method for signature 'ad,ad,missing'
besselK(x, nu)
## S4 method for signature 'num,num,missing'
besselK(x, nu)
## S4 method for signature 'ad,ad,missing'
besselI(x, nu)
## S4 method for signature 'num,num,missing'
besselI(x, nu)
## S4 method for signature 'ad,ad'
besselJ(x, nu)
## S4 method for signature 'num,num'
besselJ(x, nu)
## S4 method for signature 'ad,ad'
besselY(x, nu)
## S4 method for signature 'num,num'
besselY(x, nu)
dbinom_robust(x, size, logit_p, log)
dsn(x, alpha, log)
dSHASHo(x, mu, sigma, nu, tau, log)
dtweedie(x, mu, phi, p, log)
dnbinom2(x, mu, var, log)
dnbinom_robust(x, log_mu, log_var_minus_mu, log)
dlgamma(x, shape, scale, log)
## S4 method for signature 'ad,ad.,ad.,logical.'
dnorm(x, mean = 0, sd = 1, log = FALSE)
## S4 method for signature 'num,num.,num.,logical.'
dnorm(x, mean = 0, sd = 1, log = FALSE)
## S4 method for signature 'osa,ANY,ANY,ANY'
dnorm(x, mean = 0, sd = 1, log = FALSE)
## S4 method for signature 'simref,ANY,ANY,ANY'
dnorm(x, mean = 0, sd = 1, log = FALSE)
## S4 method for signature 'ANY,ANY,ANY,ANY'
dlnorm(x, meanlog = 0, sdlog = 1, log = FALSE)
## S4 method for signature 'osa,ANY,ANY,ANY'
dlnorm(x, meanlog = 0, sdlog = 1, log = FALSE)
## S4 method for signature 'num,num.,num.,logical.'
dlnorm(x, meanlog = 0, sdlog = 1, log = FALSE)
## S4 method for signature 'advector,missing,missing,missing,missing'
plogis(q)
## S4 method for signature 'advector,missing,missing,missing,missing'
qlogis(p)
dcompois(x, mode, nu, log = FALSE)
dcompois2(x, mean, nu, log = FALSE)
## S4 method for signature 'ad,ad,ad,missing,missing'
pbinom(q, size, prob)
## S4 method for signature 'num,num,num,missing,missing'
pbinom(q, size, prob)
## S4 method for signature 'ad,ad.,ad,logical.'
dmultinom(x, size = NULL, prob, log = FALSE)
## S4 method for signature 'num,num.,num,logical.'
dmultinom(x, size = NULL, prob, log = FALSE)
## S4 method for signature 'osa,ANY,ANY,ANY'
dmultinom(x, size = NULL, prob, log = FALSE)
## S4 method for signature 'simref,ANY,ANY,ANY'
dmultinom(x, size = NULL, prob, log = FALSE)
## S4 method for signature 'ANY,ANY,ANY,ANY'
dmultinom(x, size = NULL, prob, log = FALSE)
Arguments
x |
observation vector |
rate |
parameter |
log |
Logical; Return log density/probability? |
shape |
parameter |
scale |
parameter |
size |
parameter |
prob |
parameter |
shape1 |
parameter |
shape2 |
parameter |
df1 |
parameter |
df2 |
parameter |
location |
parameter |
df |
parameter |
lambda |
parameter |
q |
vector of quantiles |
mean |
parameter |
sd |
parameter |
p |
parameter |
nu |
parameter |
logit_p |
parameter |
alpha |
parameter |
mu |
parameter |
sigma |
parameter |
tau |
parameter |
phi |
parameter |
var |
parameter |
log_mu |
parameter |
log_var_minus_mu |
parameter |
meanlog |
Parameter; Mean on log scale. |
sdlog |
Parameter; SD on log scale. |
mode |
parameter |
Details
Specific documentation of the functions and arguments should be looked up elsewhere:
All S4 methods behave as the corresponding functions in the stats package. However, some arguements may not be implemented in the AD case (e.g.
lower-tail
).Other funtions behave as the corresponding TMB versions for which documentation should be looked up online.
Value
In autodiff contexts an object of class "advector"
is returned; Otherwise a standard numeric vector.
Functions
-
dexp(x = ad, rate = ad., log = logical.)
: AD implementation of dexp -
dexp(x = num, rate = num., log = logical.)
: Default method -
dexp(x = osa, rate = ANY, log = ANY)
: OSA implementation -
dexp(x = simref, rate = ANY, log = ANY)
: Simulation implementation. Modifiesx
and returns zero. -
dweibull(x = ad, shape = ad, scale = ad., log = logical.)
: AD implementation of dweibull -
dweibull(x = num, shape = num, scale = num., log = logical.)
: Default method -
dweibull(x = osa, shape = ANY, scale = ANY, log = ANY)
: OSA implementation -
dweibull(x = simref, shape = ANY, scale = ANY, log = ANY)
: Simulation implementation. Modifiesx
and returns zero. -
dbinom(x = ad, size = ad, prob = ad, log = logical.)
: AD implementation of dbinom -
dbinom(x = num, size = num, prob = num, log = logical.)
: Default method -
dbinom(x = osa, size = ANY, prob = ANY, log = ANY)
: OSA implementation -
dbinom(x = simref, size = ANY, prob = ANY, log = ANY)
: Simulation implementation. Modifiesx
and returns zero. -
dbeta(x = ad, shape1 = ad, shape2 = ad, ncp = missing, log = logical.)
: AD implementation of dbeta -
dbeta(x = num, shape1 = num, shape2 = num, ncp = missing, log = logical.)
: Default method -
dbeta(x = osa, shape1 = ANY, shape2 = ANY, ncp = ANY, log = ANY)
: OSA implementation -
dbeta(x = simref, shape1 = ANY, shape2 = ANY, ncp = ANY, log = ANY)
: Simulation implementation. Modifiesx
and returns zero. -
df(x = ad, df1 = ad, df2 = ad, ncp = missing, log = logical.)
: AD implementation of df -
df(x = num, df1 = num, df2 = num, ncp = missing, log = logical.)
: Default method -
df(x = osa, df1 = ANY, df2 = ANY, ncp = ANY, log = ANY)
: OSA implementation -
df(x = simref, df1 = ANY, df2 = ANY, ncp = ANY, log = ANY)
: Simulation implementation. Modifiesx
and returns zero. -
dlogis(x = ad, location = ad., scale = ad., log = logical.)
: AD implementation of dlogis -
dlogis(x = num, location = num., scale = num., log = logical.)
: Default method -
dlogis(x = osa, location = ANY, scale = ANY, log = ANY)
: OSA implementation -
dlogis(x = simref, location = ANY, scale = ANY, log = ANY)
: Simulation implementation. Modifiesx
and returns zero. -
dt(x = ad, df = ad, ncp = missing, log = logical.)
: AD implementation of dt -
dt(x = num, df = num, ncp = missing, log = logical.)
: Default method -
dt(x = osa, df = ANY, ncp = ANY, log = ANY)
: OSA implementation -
dt(x = simref, df = ANY, ncp = ANY, log = ANY)
: Simulation implementation. Modifiesx
and returns zero. -
dnbinom(x = ad, size = ad, prob = ad, mu = missing, log = logical.)
: AD implementation of dnbinom -
dnbinom(x = num, size = num, prob = num, mu = missing, log = logical.)
: Default method -
dnbinom(x = osa, size = ANY, prob = ANY, mu = ANY, log = ANY)
: OSA implementation -
dnbinom(x = simref, size = ANY, prob = ANY, mu = ANY, log = ANY)
: Simulation implementation. Modifiesx
and returns zero. -
dpois(x = ad, lambda = ad, log = logical.)
: AD implementation of dpois -
dpois(x = num, lambda = num, log = logical.)
: Default method -
dpois(x = osa, lambda = ANY, log = ANY)
: OSA implementation -
dpois(x = simref, lambda = ANY, log = ANY)
: Simulation implementation. Modifiesx
and returns zero. -
dgamma(x = ad, shape = ad, rate = missing, scale = ad., log = logical.)
: AD implementation of dgamma -
dgamma(x = num, shape = num, rate = missing, scale = num., log = logical.)
: Default method -
dgamma(x = osa, shape = ANY, rate = ANY, scale = ANY, log = ANY)
: OSA implementation -
dgamma(x = simref, shape = ANY, rate = ANY, scale = ANY, log = ANY)
: Simulation implementation. Modifiesx
and returns zero. -
pnorm(q = ad, mean = ad., sd = ad., lower.tail = missing, log.p = missing)
: AD implementation of pnorm -
pnorm(q = num, mean = num., sd = num., lower.tail = missing, log.p = missing)
: Default method -
pgamma( q = ad, shape = ad, rate = missing, scale = ad., lower.tail = missing, log.p = missing )
: AD implementation of pgamma -
pgamma( q = num, shape = num, rate = missing, scale = num., lower.tail = missing, log.p = missing )
: Default method -
ppois(q = ad, lambda = ad, lower.tail = missing, log.p = missing)
: AD implementation of ppois -
ppois(q = num, lambda = num, lower.tail = missing, log.p = missing)
: Default method -
pexp(q = ad, rate = ad., lower.tail = missing, log.p = missing)
: AD implementation of pexp -
pexp(q = num, rate = num., lower.tail = missing, log.p = missing)
: Default method -
pweibull( q = ad, shape = ad, scale = ad., lower.tail = missing, log.p = missing )
: AD implementation of pweibull -
pweibull( q = num, shape = num, scale = num., lower.tail = missing, log.p = missing )
: Default method -
pbeta( q = ad, shape1 = ad, shape2 = ad, ncp = missing, lower.tail = missing, log.p = missing )
: AD implementation of pbeta -
pbeta( q = num, shape1 = num, shape2 = num, ncp = missing, lower.tail = missing, log.p = missing )
: Default method -
qnorm(p = ad, mean = ad., sd = ad., lower.tail = missing, log.p = missing)
: AD implementation of qnorm -
qnorm(p = num, mean = num., sd = num., lower.tail = missing, log.p = missing)
: Default method -
qgamma( p = ad, shape = ad, rate = missing, scale = ad., lower.tail = missing, log.p = missing )
: AD implementation of qgamma -
qgamma( p = num, shape = num, rate = missing, scale = num., lower.tail = missing, log.p = missing )
: Default method -
qexp(p = ad, rate = ad., lower.tail = missing, log.p = missing)
: AD implementation of qexp -
qexp(p = num, rate = num., lower.tail = missing, log.p = missing)
: Default method -
qweibull( p = ad, shape = ad, scale = ad., lower.tail = missing, log.p = missing )
: AD implementation of qweibull -
qweibull( p = num, shape = num, scale = num., lower.tail = missing, log.p = missing )
: Default method -
qbeta( p = ad, shape1 = ad, shape2 = ad, ncp = missing, lower.tail = missing, log.p = missing )
: AD implementation of qbeta -
qbeta( p = num, shape1 = num, shape2 = num, ncp = missing, lower.tail = missing, log.p = missing )
: Default method -
besselK(x = ad, nu = ad, expon.scaled = missing)
: AD implementation of besselK -
besselK(x = num, nu = num, expon.scaled = missing)
: Default method -
besselI(x = ad, nu = ad, expon.scaled = missing)
: AD implementation of besselI -
besselI(x = num, nu = num, expon.scaled = missing)
: Default method -
besselJ(x = ad, nu = ad)
: AD implementation of besselJ -
besselJ(x = num, nu = num)
: Default method -
besselY(x = ad, nu = ad)
: AD implementation of besselY -
besselY(x = num, nu = num)
: Default method -
dbinom_robust()
: AD implementation -
dsn()
: AD implementation -
dSHASHo()
: AD implementation -
dtweedie()
: AD implementation -
dnbinom2()
: AD implementation -
dnbinom_robust()
: AD implementation -
dlgamma()
: AD implementation -
dnorm(x = ad, mean = ad., sd = ad., log = logical.)
: AD implementation of dnorm -
dnorm(x = num, mean = num., sd = num., log = logical.)
: Default method -
dnorm(x = osa, mean = ANY, sd = ANY, log = ANY)
: OSA implementation -
dnorm(x = simref, mean = ANY, sd = ANY, log = ANY)
: Simulation implementation. Modifiesx
and returns zero. -
dlnorm(x = ANY, meanlog = ANY, sdlog = ANY, log = ANY)
: AD implementation of dlnorm. -
dlnorm(x = osa, meanlog = ANY, sdlog = ANY, log = ANY)
: OSA implementation. -
dlnorm(x = num, meanlog = num., sdlog = num., log = logical.)
: Default method. -
plogis( q = advector, location = missing, scale = missing, lower.tail = missing, log.p = missing )
: Minimal AD implementation of plogis -
qlogis( p = advector, location = missing, scale = missing, lower.tail = missing, log.p = missing )
: Minimal AD implementation of qlogis -
dcompois()
: Conway-Maxwell-Poisson. Calculate density. -
dcompois2()
: Conway-Maxwell-Poisson. Calculate density parameterized via the mean. -
pbinom(q = ad, size = ad, prob = ad, lower.tail = missing, log.p = missing)
: AD implementation of pbinom -
pbinom(q = num, size = num, prob = num, lower.tail = missing, log.p = missing)
: Default method -
dmultinom(x = ad, size = ad., prob = ad, log = logical.)
: AD implementation of dmultinom -
dmultinom(x = num, size = num., prob = num, log = logical.)
: Default method -
dmultinom(x = osa, size = ANY, prob = ANY, log = ANY)
: OSA implementation -
dmultinom(x = simref, size = ANY, prob = ANY, log = ANY)
: Simulation implementation. Modifiesx
and returns zero. -
dmultinom(x = ANY, size = ANY, prob = ANY, log = ANY)
: Default implementation that checks for invalid usage.
Examples
MakeTape( function(x) pnorm(x), x=numeric(5))$jacobian(1:5)