hsaDist: Probabilities and Moments Hermite Spline Approximation

hsaDistR Documentation

Probabilities and Moments Hermite Spline Approximation

Description

The set of functions similar to dhpa-like functions. The difference is that instead of a polynomial these functions utilize a spline.

Usage

dhsa(x, m, knots, mean = 0, sd = 1, log = FALSE)

ehsa(m, knots, mean = 0, sd = 1, power = 1)

Arguments

x

numeric vector of values for which the function should be estimated.

m

numeric matrix whose rows correspond to the spline intervals while columns represent the variables powers. Therefore the element in i-th row and j-th column represents the coefficient associated with the variable that 1) belongs to the i-th interval i.e. between the i-th and (i + 1)-th knots 2) raised to the power of (j - 1).

knots

a numeric vector sorted in ascending order representing the knots of the spline.

mean

expected value of a normal distribution.

sd

standard deviation of a normal distribution.

log

logical; if TRUE then probabilities p are given as log(p) or derivatives will be given with respect to log(p).

power

non-negative integer representing the moment order, i.e., E(X ^ power) will be estimated.

Details

In contrast to dhpa-like functions these functions may deal with univariate distributions only. In future this functions will be generalized to work with multivariate distributions. The main idea of these functions is to use squared spline instead of squared polynomial in order to provide greater numeric stability and approximation accuracy. To provide spline parameters please use m and knots arguments (i.e. instead of pol_degrees and pol_coefficients arguments that were used to specify the polynomial for dhpa-like functions).

Value

Function dhsa returns vector of probability densities of the same length as x. Function ehsa returns moment value.

See Also

dhpa, bsplineGenerate

Examples

## Examples demonstrating dhsa and ehsa functions' application.

# Generate b-splines
b <- bsplineGenerate(knots = c(-2.1, 1.5, 1.5, 2.2, 3.7, 4.2, 5),
                     degree = 3)
                      
# Combine b-splines into a spline
spline <- bsplineComb(splines = b, weights = c(1.6, -1.2, 3.2))

# Assign parameters using the spline created above
knots <- spline$knots
m <- spline$m
mean <- 1
sd <- 2

# Estimate the density at particular points
x <- c(2, 3.7, 8)
dhsa(x, 
     m = m, knots = knots,
     mean = mean, sd = sd)
     
# Calculate expected value
ehsa(m = m, knots = knots,
     mean = mean, sd = sd,
     power = 1) 
     
# Evaluate the third moment
ehsa(m = m, knots = knots,
     mean = mean, sd = sd,
     power = 3) 

hpa documentation built on April 14, 2026, 5:09 p.m.

Related to hsaDist in hpa...