| aDistDens | R Documentation |
Computes the distance between probability densities in the Bayes Hilbert
space, i.e. the L^2 distance of their functional clr transforms. It is
the functional counterpart of the Aitchison distance aDist for
compositions.
aDistDens(z, z_step, f, g = NULL, p = NULL, type = c("rows", "cross"))
z |
numeric vector, equidistant grid of points on the domain. |
z_step |
spacing of the grid |
f |
strictly positive density values on the grid: a vector of the same
length as |
g |
|
p |
optional vector of the same length as |
type |
|
For densities f and g with respect to the Lebesgue
measure on [a, b], the distance is
d(f, g)^2 = \int_a^b \left(\mathrm{fcenLR}(f)(t) - \mathrm{fcenLR}(g)(t)\right)^2 dt,
see fcenLR. If the density p of a reference measure
P is given, f and g are P-densities and the
distance of the weighted Bayes space B^2(P) is computed,
d_P(f, g)^2 = \int \left(\mathrm{fcenLR}_P(f)(t) - \mathrm{fcenLR}_P(g)(t)\right)^2 p(t)\,dt,
see fcenLRp.
The integrals are approximated by the trapezoidal rule (trapzc)
on the equidistant grid z. On this grid the distance equals the
weighted Aitchison distance aDist(f, g, weights = c * p) of the
density values, where c = h (1/2, 1, \dots, 1, 1/2) are the trapezoidal
weights for spacing h; aDistDens uses exactly this computation.
Like the Aitchison distance, the result does not change if a density is
multiplied by a positive constant, so the densities do not need to be
normalised.
The distance follows the convention of Egozcue and Pawlowsky-Glahn (2016),
without the factor 1/P(\Omega) that van den Boogaart et al. (2014)
include in the inner product of the Bayes space; for that convention divide
the result by \sqrt{b - a} (or by
\sqrt{P(\Omega)}).
If g is NULL, the distances between all densities in
f as an object of class "dist". Otherwise a vector
(type = "rows") or a matrix (type = "cross") of distances.
Matthias Templ
Egozcue, J.J., Diaz-Barrero, J.L. and Pawlowsky-Glahn, V. (2006) Hilbert space of probability density functions based on Aitchison geometry. Acta Mathematica Sinica, English Series, 22 (4), 1175-1182. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1007/s10114-005-0678-2")}
Egozcue, J.J. and Pawlowsky-Glahn, V. (2016) Changing the reference measure in the simplex and its weighting effects. Austrian Journal of Statistics, 45 (4), 25-44. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.17713/ajs.v45i4.126")}
Talska, R., Menafoglio, A., Hron, K., Egozcue, J. J., Palarea-Albaladejo, J. (2020). Weighting the domain of probability densities in functional data analysis. Stat, 9 (1), e283. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1002/sta4.283")}
van den Boogaart, K.G., Egozcue, J.J. and Pawlowsky-Glahn, V. (2014) Bayes Hilbert spaces. Australian & New Zealand Journal of Statistics, 56 (2), 171-194. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1111/anzs.12074")}
aDist, fcenLR, fcenLRp,
trapzc
t <- seq(-4.7, 4.7, length = 1000)
t_step <- diff(t[1:2])
f <- dnorm(t, mean = 0, sd = 1.5)
g <- dnorm(t, mean = 1, sd = 1.5)
aDistDens(t, t_step, f, g)
# same value from the clr transforms
sqrt(trapzc(t_step, (fcenLR(t, t_step, f) - fcenLR(t, t_step, g))^2))
# scale invariance: densities need not be normalised
aDistDens(t, t_step, 10 * f, g)
# distance matrix of several densities (one per row)
dens <- t(sapply(c(0, 0.5, 1, 2), function(m) dnorm(t, mean = m, sd = 1.5)))
aDistDens(t, t_step, dens)
# with respect to a reference measure P (here a normal distribution)
p <- dnorm(t, sd = 2) / trapzc(t_step, dnorm(t, sd = 2))
aDistDens(t, t_step, f / p, g / p, p = p)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.