normaliseDensities: Normalise Densities

Description Usage Arguments Details Value References Examples

View source: R/normaliseDensities.R

Description

Preprocessing function to ensure densities integrate to 1

Usage

1
normaliseDensities(dmatrix, dSup = 1:ncol(dmatrix))

Arguments

dmatrix

Matrix with rows representing distinct densities on dSup - all entries must be nonnegative

dSup

Support (grid) for Density domain

Details

Uses trapezoidal integration to normalise the densities to have integral 1

Value

matrix 'dmatrix' consisting of rows of input of the same name that have been normalised to have integral 1

References

Functional Data Analysis for Density Functions by Transformation to a Hilbert space, Alexander Petersen and Hans-Georg Mueller, 2016

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Normalise collection of truncated normal densities

mu <- seq(-2, 2, by = 0.5)
dSup = seq(-3, 3, length.out = 101)
y <- t(sapply(mu, function(m) dnorm(x = dSup, mean = m)))

# Should return warnings about densities not integrating to 1
lqd = MakeLQDsample(dmatrix = y, dSup = dSup)

# Normalise and rerun without warning
dens <- normaliseDensities(dmatrix = y, dSup = dSup)
lqd = MakeLQDsample(dmatrix = dens, dSup = dSup)

fdadensity documentation built on Dec. 5, 2019, 9:07 a.m.