getSample: Get a sample from the reference measure

View source: R/helpers.R View source: R/classes.R

getSampleR Documentation

Get a sample from the reference measure

Description

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.

Usage

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, ...)

Arguments

x

the ReferenceMeasure or distribution

...

further parameters to simulate, which might or might not be called.

Value

a sample of the distribution in the form that would be expected from a dataset, like e.g. a vector or a data.matrix.

Methods (by class)

  • 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

Functions

  • 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

See Also

Other ReferenceMeasures: B2N01, ReferenceMeasureDiscrete(), ReferenceMeasureTransformed(), ReferenceMeasureUniform(), StdReferenceMeasureUnif01, expectation(), isInDomain()

Other ReferenceMeasures: B2N01, ReferenceMeasureDiscrete(), ReferenceMeasureTransformed(), ReferenceMeasureUniform(), StdReferenceMeasureUnif01, expectation(), isInDomain()

Examples

getSample(B2Unif01)

hist(getSample(StdReferenceMeasureUnif01))
mean(cos(getSample(StdReferenceMeasureN01)))


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