|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.unihalle.informatik.MiToBo.math.distributions.impl.ParticleDistribution<G>
G
- type of a particlepublic class ParticleDistribution<G extends Copyable<? extends G>>
A distribution represented by weighted particles
Field Summary | |
---|---|
protected double[] |
cweights
|
protected boolean |
equalWeights
|
protected G[] |
particles
|
protected java.util.Random |
rand
|
protected double[] |
weights
|
Constructor Summary | |
---|---|
protected |
ParticleDistribution()
Constructor where all fields are initialized by null . |
|
ParticleDistribution(java.util.Random rand,
G[] particles)
Constructor with equally weighted particles that must be specified. |
|
ParticleDistribution(java.util.Random rand,
G[] particles,
double[] weights)
Constructor with equally weighted particles that must be specified. |
|
ParticleDistribution(java.util.Random rand,
SamplingDistribution<G> density,
int numParticles)
Constructor that samples numParticles from density . |
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected double[] cweights
protected boolean equalWeights
protected G extends Copyable<? extends G>[] particles
protected java.util.Random rand
protected double[] weights
Constructor Detail |
---|
protected ParticleDistribution()
null
.
public ParticleDistribution(java.util.Random rand, G[] particles)
rand
- random generator for samplingparticles
- equally weighted particlespublic ParticleDistribution(java.util.Random rand, G[] particles, double[] weights) throws java.lang.IllegalArgumentException
rand
- random generator for samplingparticles
- particlesweights
- weights of the particles
java.lang.IllegalArgumentException
- when particles- and weights-array do not have same lengthpublic ParticleDistribution(java.util.Random rand, SamplingDistribution<G> density, int numParticles)
numParticles
from density
.
rand
- random generator for samplingdensity
- distribution to sample fromnumParticles
- number of particles to be sampledMethod Detail |
---|
public double computeESS()
public G drawSample()
SamplingDistribution
drawSample
in interface SamplingDistribution<G extends Copyable<? extends G>>
public boolean equalWeights()
public int getNumOfParticles()
public G getParticle(int idx)
public G[] getParticles()
public double getWeight(int idx)
public double[] getWeights()
double getWeightsSum()
public void normalizeWeights()
public void resample()
public void setEqualWeightsFlag(boolean equalWeights)
public void setParticle(int idx, G particle)
public void setWeight(int idx, double weight)
idx
- index of particleweight
- weight of particle
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |