Learn R Programming

hpa (version 1.0.1)

normalMoment: Calculate k-th order moment of normal distribution

Description

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

Usage

normalMoment(k = 0L, mean = 0, sd = 1, return_all_moments = FALSE,
  is_validation = TRUE)

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 normaly 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

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

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.

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.

Examples

Run this code
# NOT RUN {
##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)

# }

Run the code above in your browser using DataLab