normalMoment: Calculate k-th order moment of normal distribution

View source: R/RcppExports.R

normalMomentR Documentation

Calculate k-th order moment of normal distribution

Description

This function recursively calculates k-th order moment of normal distribution.

Usage

normalMoment(
  k = 0L,
  mean = 0,
  sd = 1,
  return_all_moments = FALSE,
  is_validation = TRUE,
  is_central = FALSE,
  diff_type = "NO"
)

Arguments

k

non-negative integer moment order.

mean

numeric expected value.

sd

positive numeric standard deviation.

return_all_moments

logical; if TRUE, function returns (k+1)-dimensional numeric vector of moments of normally distributed random variable with mean = mean and standard deviation = sd. Note that i-th vector's component value corresponds to the (i-1)-th moment.

is_validation

logical value indicating whether function input arguments should be validated. Set it to FALSE for slight performance boost (default value is TRUE).

is_central

logical; if TRUE, then central moments will be calculated.

diff_type

string value indicating the type of the argument the moment should be differentiated respect to. Default value is "NO" so the moments itself will be returned. Alternative values are "mean" and "sd". Also "x_lower" and "x_upper" values are available for truncatedNormalMoment.

Details

This function estimates k-th order moment of normal distribution which mean equals to mean and standard deviation equals to sd.

Note that parameter k value automatically converts to integer. So passing non-integer k value will not cause any errors but the calculations will be performed for rounded k value only.

Value

This function returns k-th order moment of normal distribution which mean equals to mean and standard deviation is sd. If return_all_moments is TRUE then see this argument description above for output details.

Examples

## Calculate 5-th order moment of normal random variable which
## mean equals to 3 and standard deviation is 5.

# 5-th moment
normalMoment(k = 5, mean = 3, sd = 5)

# (0-5)-th moments
normalMoment(k = 5, mean = 3, sd = 5, return_all_moments = TRUE)

# 5-th moment derivative respect to mean
normalMoment(k = 5, mean = 3, sd = 5, diff_type = "mean")

# 5-th moment derivative respect to sd
normalMoment(k = 5, mean = 3, sd = 5, diff_type = "sd")


hpa documentation built on May 31, 2023, 8:25 p.m.

Related to normalMoment in hpa...