| hpaDist0 | R Documentation |
These functions use fast algorithms to calculate densities and probabilities (along with their derivatives) related to the standardized PGN distribution.
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
)
x |
numeric vector of function 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 |
Functions dhpa0 and
phpa0 are similar to dhpa and
phpa, respectively. However, there are two key
differences. First, dhpa0 and phpa0
deal only with univariate PGN distributions. Second, this distribution
is standardized to zero mean and unit variance. 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.
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 added to the list containing gradients with respect to input
argument x and parameters pc, respectively.
If log = TRUE, then additional elements will be added 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",
"prob_log" and "den_log".
# Calculate density and probability of standardized 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 with respect to arguments
# and parameters of the PGN distribution
dhpa0(x, pc, is_grad = TRUE)
phpa0(x, pc, is_grad = TRUE)
# Let X be a standardized PGN random variable and repeat
# the 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.