Learn R Programming

smcUtils (version 0.2.2)

ess.weights: Measures of weight non-uniformity

Description

These functions calculate heuristic measures of the effective number of samples given a set of weights (probabilities).

Usage

ess.weights(weights, engine="R") cov.weights(weights, engine="R") ent.weights(weights, engine="R")

Arguments

weights
a vector of weights (probabilities)
engine
run using "R" or "C" code

Value

a scalar indicating how uniform the weights are

Details

`ess.weights' calculates the effective sample size, namely `1/(sum(weights^2))'. ESS has a minimum of 1 and a maximum equal to `length(weights)' when weights are uniform.

`cov.weights' calculates the coefficient of variation of the weights, namely `var(weights)/mean(weights)^2'. CoV has a minimum of 0 when weights are uniform and a maximum equal to `length(weights)'.

`ent.weights' calculates the entropy of the weights, namely `-sum(weights * log2(weights))'. Entropy has a minimum of 0 and a maximum equal to `log2(length(weights))' when weights are uniform. (For numerical stability, the log term is actually calculated with `weights+.Machine$double.eps', which can cause the observed minimum to be less than 0.)

References

Liu, J. (2004) _Monte Carlo Strategies in Scientific Computing_

Doucet, A., dr Freitas, N., and Gordon, N. (2001) _Sequential Monte Carlo Methods in Practice_

See Also

resample

Examples

Run this code
ws = renormalize(runif(10))
ess.weights(ws)
cov.weights(ws)
ent.weights(ws)

Run the code above in your browser using DataLab