Weighted populations
The UncertainScalarPopulation
type allows representation of an uncertain scalar represented by a population of values who will be sampled according to a vector of explicitly provided probabilities. Think of it as an explicit kernel density estimate.
Generic constructor
UncertainData.UncertainValues.UncertainValue
— MethodUncertainValue(values::Vector, probs::Union{Vector, AbstractWeights})
Construct a population whose members are given by values
and whose sampling probabilities are given by probs
. The elements of values
can be either numeric or uncertain values of any type.
Type documentation
UncertainData.UncertainValues.UncertainScalarPopulation
— TypeUncertainScalarPopulation(values, probs)
UncertainScalarPopulation(values, probs::Vector{Number})
UncertainScalarPopulation(values, probs::Statsbase.AbstractWeights)
An UncertainScalarPopulation
, which consists of some population members (values
) and some weights (probs
) that indicate the relative importance of the population members (for example during resampling).
Fields
values
: The members of the population. Can be either numerical values, any type of uncertain value defined in this package (including populations), andMeasurement
instances from Measurements.jl.probs
: The probabilities of sampling each member of the population.
Constructors
- If
values
contains only scalar numeric values, then thevalues
field will be of typeVector{Number}
. - If
values
contains one or more uncertain values, then thevalues
field will be of typeVector{AbstractUncertainValue}
Example
# Uncertain population consisting of CertainValues (scalars get promoted to
# CertainValue), theoretical distributions and KDE distributions
pop1 = UncertainScalarPopulation(
[3.0, UncertainValue(Normal, 0, 1), UncertainValue(Gamma, 2, 3),
UncertainValue(Uniform, rand(1000))], [0.5, 0.5, 0.5, 0.5])
# Uncertain population consisting of scalar values
pop2 = UncertainScalarPopulation([1, 2, 3], rand(3))
pop3 = UncertainScalarPopulation([1, 2, 3], Weights(rand(3)))
# Uncertain population consisting of uncertain populations
pop4 = UncertainScalarPopulation([pop1, pop2], [0.1, 0.5])
# Uncertain population consisting of uncertain populations, a scalar and
# a normal distribution. Assign random weights.
vals = [pop1, pop2, 2, UncertainValue(Normal, 0.3, 0.014)]
pop5 = UncertainScalarPopulation(vals, Weights(rand(4)))