mean.BDataSplines: Computes the distribution mean for BDataSplines.

View source: R/operations.R

mean.BDataSplinesR Documentation

Computes the distribution mean for BDataSplines.

Description

This function simply averages the spline coefficients and returns a correponding spline.

Usage

## S3 method for class 'BDataSplines'
mean(x, ..., method = c("classical", "mcd", "mve"))

## S3 method for class 'BDataDensities'
mean(x, ..., method = c("functions", "classical", "mcd", "mve"))

## S3 method for class 'BDataPDFs'
mean(x, ..., method = c("functions", "classical", "mcd", "mve"))

## S3 method for class 'BDataLogPDFs'
mean(x, ..., method = c("functions", "classical", "mcd", "mve"))

## S3 method for class 'BDataLogDensities'
mean(x, ..., method = c("functions", "classical", "mcd", "mve"))

Arguments

x

the BDataSplines object over which to average

...

unused arguments required for generic use

method

the method to be chosen (as in [cov.rob]), functions does operates according to BayesSpace formulas directly on the densities, classical uses the spline representation, mcd and mve apply these robust methods on the spline coefficients.

Value

a BDataSplines with a single observation representing the mean

Functions

  • mean(BDataDensities): method for full densities

  • mean(BDataPDFs): method for full PDFs

  • mean(BDataLogPDFs): method for full logPDFs

  • mean(BDataLogDensities): method for full logDensities

Examples

data(DTD)
Xpdf    = BDataPDFs(DTD$shapePDF,basis=B2Unif01Basis5)
Xspline = as.BDataSplines(Xpdf)
plot(Xspline,col=2:12)
meanXspline = mean(Xspline)
plot(meanXspline,col=1,lwd=3,add=TRUE)

plot(Xspline,as="PDF")
plot(meanXspline,col="red",lwd=3,add=TRUE,as="PDF")

Xdensities = as.BDataDensities(Xpdf)

plot(Xdensities)
meanXdensities = clo(mean(Xdensities))
plot(meanXdensities,col="green",lwd=7,add=TRUE)
plot(meanXspline,col="red",lwd=3,add=TRUE,as="density")

plot(Xpdf)
meanXpdf = mean(Xpdf)
plot(clo(meanXpdf),col="green",lwd=7,add=TRUE)
plot(meanXspline,col="red",lwd=3,add=TRUE,as="PDF",close=TRUE)
plot(as.BDataPDFs(meanXdensities),col="blue",lwd=3,add=TRUE,close=TRUE)
plot(as.BDataPDFs(mean(as.BDataLogPDFs(Xpdf))),col="orange",lwd=3,add=TRUE,close=TRUE)
plot(as.BDataPDFs(mean(as.BDataLogDensities(Xpdf))),col="magenta",lwd=3,add=TRUE,close=TRUE)


DistributionalDDA documentation built on Oct. 20, 2026, 5:06 p.m.