normaliseDensities {fdadensity} | R Documentation |
Normalise Densities
Description
Preprocessing function to ensure densities integrate to 1
Usage
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
## 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)
[Package fdadensity version 0.1.2 Index]