hpaDist0 {hpa} | R Documentation |
Fast pdf and cdf for standardized univariate PGN distribution
Description
This function uses fast algorithms to calculate densities and probabilities (along with their derivatives) related to standardized PGN distribution.
Usage
dhpa0(
x,
pc,
mean = 0,
sd = 1,
is_parallel = FALSE,
log = FALSE,
is_validation = TRUE,
is_grad = FALSE
)
phpa0(
x,
pc,
mean = 0,
sd = 1,
is_parallel = FALSE,
log = FALSE,
is_validation = TRUE,
is_grad = FALSE
)
Arguments
x |
numeric vector of functions arguments. |
pc |
polynomial coefficients without the first term. |
mean |
expected value (mean) of the distribution. |
sd |
standard deviation of the distribution. |
is_parallel |
logical; if TRUE then multiple cores will be used for some calculations. Currently unavailable. |
log |
logical; if |
is_validation |
logical value indicating whether function input
arguments should be validated. Set it to |
is_grad |
logical; if |
Details
Functions dhpa0
and
phpa0
are similar to dhpa
and
phpa
correspondingly. However there are two key
differences. First, dhpa0
and phpa0
are deal with univariate PGN distribution only. Second, this distribution
is standardized to zero mean and unit variances. Moreover pc
is
similar to pol_coefficients
argument of dhpa
but
without the first component i.e. pc=pol_coefficients[-1]
. Also
mean
and sd
are not the arguments of the normal density
but actual mean and standard deviation of the resulting distribution. So
if these arguments are different from 0
and 1
correspondingly
then standardized PGN distribution will be linearly transformed to have
mean mean
and standard deviation sd
.
Value
Both functions return a list.
Function dhpa0
returns a list with element named
"den"
that is a numeric vector of density values.
Function phpa0
returns a list with element named
"prob"
that is a numeric vector of probabilities.
If is_grad = TRUE
then elements "grad_x"
and "grad_pc"
will be add to the list containing gradients respect to input argument
x
and parameters pc
correspondingly. If log = TRUE
then
additional elements will be add to the list containing density, probability
and gradient values for logarithms of corresponding functions. These
elements will be named as "grad_x_log"
, "grad_pc_log"
,
"grad_prob_log"
and "grad_den_log"
.
Examples
# Calculate density and probability of standartized PGN
# distribution
# distribution parameters
pc <- c(0.5, -0.2)
# function arguments
x <- c(-0.3, 0.8, 1.5)
# probability density function
dhpa0(x, pc)
# cumulative distribution function
phpa0(x, pc)
# Additionally calculate gradients respect to arguments
# and parameters of the PGN distribution
dhpa0(x, pc, is_grad = TRUE)
phpa0(x, pc, is_grad = TRUE)
# Let's denote by X standardized PGN random variable and repeat
# calculations for 2 * X + 1
dhpa0(x, pc, is_grad = TRUE, mean = 1, sd = 2)
phpa0(x, pc, is_grad = TRUE, mean = 1, sd = 2)