Learn R Programming

smcUtils (version 0.2.2)

renormalize.weights: Renormalize weights

Description

This function creates a discrete probability distribution from a set of unnormalized (log) weights.

Usage

renormalize.weights(weights, log=FALSE, engine="R")

Arguments

weights
a vector of non-negative numbers
log
a logical indicating whether the weights are given as the logarithm of the weights
engine
run using "R" or "C" code

Value

  • a vector of probabilities that sum to 1

See Also

resampling

Examples

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

log.ws = dnorm(rnorm(10,1,0),log=TRUE)
renormalize.weights(log.ws,log=TRUE)

Run the code above in your browser using DataLab