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 a 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 with respect to. Default value is "NO" so the moments themselves 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 the value of parameter k automatically converts to an integer. So passing a non-integer k value will not cause any errors but the calculations will be performed for the rounded k value only.

Value

This function returns k-th order moment of normal distribution whose mean equals mean and whose standard deviation equals 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 April 14, 2026, 5:09 p.m.

Related to normalMoment in hpa...