| weightedStats | R Documentation |
The function computes the expectation and variance of 'X' for the probability distribution given by the density f with respect to the measure. The method supports lists even if the individual measure does not.
weightedStats(
measure,
X,
f,
method = c("default", "sample", "MonteCarlo", "integration"),
tol = 0.01
)
## S3 method for class 'ReferenceMeasure'
weightedStats(
measure,
X,
f,
method = c("default", "sample", "MonteCarlo", "integration"),
...
)
## S3 method for class 'ReferenceMeasureDiscrete'
weightedStats(measure, X, f, method, tol)
measure |
should be a reference measure. Other classes can implement the method. |
X |
a function (or list of functions) providing the statistics |
f |
a function providing the density with respect to X |
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. |
... |
further arguments to integration methods e.g. tol. |
The default method for reference measures used [getSample] and Monte Carlo integration with respect to this sample to perform the computation. More advanced methods e.g. using numerical integration might be implemented for certain subclasses.
a list with the elements E for the computed expectation and V for the computed variance.
weightedStats(ReferenceMeasure): method for ReferenceMeasure
weightedStats(ReferenceMeasureDiscrete): method for ReferenceMeasureDiscrete exact computation based on X and w of the measure.
[getSample]
weightedStats(ReferenceMeasureUniform(0,1),function(x) x, function(x) x^2)
weightedStats(ReferenceMeasureUniform(0,1),as.function(B2Unif01Basis5), function(x) x^2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.