View source: R/helpers.R View source: R/classes.R
| getSample | R Documentation |
This provides a sample of data form the support of the reference measure, e.g. to test functions or to be used as integration points. The sample can optionally come as a weighted sample to ensure integration. In order to achieve good performance and reproducability the sample is typically fixed and not random, except in cases where no good algorithm for a deterministic grid could be implemented.
This function is here for fast and reproducable Monte Carlo integration, with respect to a measure. Unlike a [simulate] it is allowed to return the same sample in different calls and to provide default size rather than a requested one.
getSample(x, ...)
## S3 method for class 'ReferenceMeasure'
getSample(x, ...)
## S3 method for class 'ReferenceMeasureCartesianProduct'
getSample(x, ...)
## S3 method for class 'BayesSpace'
getSample(x, ...)
## S3 method for class 'L2Space'
getSample(x, ...)
getSample(x, ...)
## S3 method for class 'ReferenceMeasureDiscrete'
getSample(x, ...)
hasWeights(x)
## Default S3 method:
hasWeights(x, ...)
getWeights(x, ...)
x |
the ReferenceMeasure or distribution |
... |
further parameters to simulate, which might or might not be called. |
a sample of the distribution in the form that would be expected from a dataset, like e.g. a vector or a data.matrix.
getSample(ReferenceMeasure): method for referencemeasure, please overwrite
getSample(ReferenceMeasureCartesianProduct): method for ReferenceMeasureCartesianProduct
getSample(BayesSpace): method for BayesSpace
getSample(L2Space): method for L2Space
getSample(ReferenceMeasureDiscrete): method for discrete measures, returning a weighted sample
hasWeights(): generic method checking whether its weighted sample
hasWeights(default): default method checking for a weights attribute.
getWeights(): generic method for retrieving weights of a sample
Other ReferenceMeasures:
B2N01,
ReferenceMeasureDiscrete(),
ReferenceMeasureTransformed(),
ReferenceMeasureUniform(),
StdReferenceMeasureUnif01,
expectation(),
isInDomain()
Other ReferenceMeasures:
B2N01,
ReferenceMeasureDiscrete(),
ReferenceMeasureTransformed(),
ReferenceMeasureUniform(),
StdReferenceMeasureUnif01,
expectation(),
isInDomain()
getSample(B2Unif01)
hist(getSample(StdReferenceMeasureUnif01))
mean(cos(getSample(StdReferenceMeasureN01)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.