G - type of a particlepublic class ParticleDistribution<G extends Copyable<? extends G>> extends Object implements SamplingDistribution<G>
| Modifier and Type | Field and Description |
|---|---|
protected double[] |
cweights |
protected boolean |
equalWeights |
protected G[] |
particles |
protected Random |
rand |
protected double[] |
weights |
| Modifier | Constructor and Description |
|---|---|
protected |
ParticleDistribution()
Constructor where all fields are initialized by
null. |
|
ParticleDistribution(Random rand,
G[] particles)
Constructor with equally weighted particles that must be specified.
|
|
ParticleDistribution(Random rand,
G[] particles,
double[] weights)
Constructor with equally weighted particles that must be specified.
|
|
ParticleDistribution(Random rand,
SamplingDistribution<G> density,
int numParticles)
Constructor that samples
numParticles from density. |
| Modifier and Type | Method and Description |
|---|---|
double |
computeESS()
Compute effective sample size (ESS).
|
G |
drawSample()
Generate a new sample from this density.
|
boolean |
equalWeights()
Returns true if all particle weights are equal
|
int |
getNumOfParticles()
Get number of particles
|
G |
getParticle(int idx)
Get idx-th particle
|
G[] |
getParticles()
Get particles
|
double |
getWeight(int idx)
Get weight of idx-th particle
|
double[] |
getWeights()
Get particle weights
|
(package private) double |
getWeightsSum()
Get sum of weights
|
void |
normalizeWeights()
Normalize the particle weights to sum to 1.
|
void |
resample()
Resample this distribution and equalize weights
|
void |
setEqualWeightsFlag(boolean equalWeights)
Set the "equal weights"-flag
|
void |
setParticle(int idx,
G particle)
Set idx-th particle
|
void |
setWeight(int idx,
double weight)
Set weight for particle specified by idx.
|
protected double[] weights
protected double[] cweights
protected Random rand
protected boolean equalWeights
protected ParticleDistribution()
null.public ParticleDistribution(Random rand, G[] particles)
rand - random generator for samplingparticles - equally weighted particlespublic ParticleDistribution(Random rand, G[] particles, double[] weights) throws IllegalArgumentException
rand - random generator for samplingparticles - particlesweights - weights of the particlesIllegalArgumentException - when particles- and weights-array do not have same lengthpublic ParticleDistribution(Random rand, SamplingDistribution<G> density, int numParticles)
numParticles from density.rand - random generator for samplingdensity - distribution to sample fromnumParticles - number of particles to be sampledpublic G drawSample()
SamplingDistributiondrawSample in interface SamplingDistribution<G extends Copyable<? extends G>>public int getNumOfParticles()
public G[] getParticles()
public G getParticle(int idx)
public void setParticle(int idx,
G particle)
public double[] getWeights()
public double getWeight(int idx)
public void setWeight(int idx,
double weight)
idx - index of particleweight - weight of particlepublic void normalizeWeights()
public void resample()
double getWeightsSum()
public boolean equalWeights()
public void setEqualWeightsFlag(boolean equalWeights)
public double computeESS()
Copyright © 2010–2020 Martin Luther University Halle-Wittenberg, Institute of Computer Science, Pattern Recognition and Bioinformatics. All rights reserved.