CovarianceOperator: Computes a covariance with respect to a measure. The function...

View source: R/integration.R

CovarianceOperatorR Documentation

Computes a covariance with respect to a measure. The function can be considered internal implementation details of the package, but needs to be exported due to its generic nature.

Description

The implementation depends on the measure

Usage

CovarianceOperator(measure, X, Y, ...)

## S3 method for class 'ReferenceMeasure'
CovarianceOperator(
  measure,
  X,
  Y,
  ...,
  method = c("default", "sample", "MonteCarlo", "integration"),
  tol = 0.01,
  close = FALSE
)

## S3 method for class 'ReferenceMeasureDiscrete'
CovarianceOperator(measure, X, Y, ...)

Arguments

measure

typically a ReferenceMeasure

X

a random variable (or a list of such) on the domain of the measure represented as an R function. It returns multiple values as columns of a matrix.

Y

a random variable (or a list of) on the domain of the measure represented as an R function.

...

possibly further implementation dependent arguments for the computational method

method

a method to be selected. Typical methods are "sample", "MonteCarlo" and "integrate", but only sample is availabel for all reference measures. "sample" uses the prestored sample, "MonteCarlo" uses the simulated function of the reference measure, and "integrate" uses numerical integration. Typically the prestored integration sample performs well with derivatives measures derived ReferenceMeasureUniform, ReferenceMeasusureTransformed, where it proves a dense grid in the area of measure, and ReferenceMeasure discrete where it uses precise computation using a weighted sample. For Cartesian products involving more than one continues measure due to the curse of dimensionality typically only MonteCarlo is expected to work reasonably well.

tol

the absolute or relative tolerance (whichever is larger). accepted for methods with tolerance control.

close

if false the underlying measure is not assumed to be closed, and the function makes it possible to computed unclosed covariance integrals for unclosed reference measures. This is the default.

Value

the scalar products (covariances) of 'X' and 'Y' with respect to the reference measure. For the default ReferenceMeasure method these are obtained from [stats::cov()] applied to ‘X' and 'Y' evaluated on the measure’s sample. The result is a numeric scalar, vector, or matrix depending on the number of columns returned by 'X' and 'Y' (one entry per pair of output components); when 'X' or 'Y' is a list, the results are combined columnwise.

Methods (by class)

  • CovarianceOperator(ReferenceMeasure): method for ReferenceMeasures using a MonteCarlo integration based on the sample provided by getSample(sample)

  • CovarianceOperator(ReferenceMeasureDiscrete): method for ReferenceMeasuresDiscrete explicit computation

Examples

CovarianceOperator(StdReferenceMeasureUnif01,
                   function(x) cbind(x,-x),
                   function(x) cbind(x,-x,2*x+1)
)


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