/** * Computes the probabilities of the various states over time given the * observation sequence. Rabiner calls these the "gammas". * @param alphas * Forward probabilities. * @param betas * Backward probabilities. * @param scaleFactor * Amount to scale the gamma by * @return * Gammas. */ protected ArrayList<Vector> computeStateObservationLikelihood( ArrayList<WeightedValue<Vector>> alphas, ArrayList<WeightedValue<Vector>> betas, double scaleFactor ) { final int N = alphas.size(); ArrayList<Vector> gammas = new ArrayList<Vector>( N ); for( int n = 0; n < N; n++ ) { Vector alphan = alphas.get(n).getValue(); Vector betan = betas.get(n).getValue(); gammas.add( computeStateObservationLikelihood( alphan, betan, scaleFactor ) ); } return gammas; }
/** * Computes the probabilities of the various states over time given the * observation sequence. Rabiner calls these the "gammas". * @param alphas * Forward probabilities. * @param betas * Backward probabilities. * @param scaleFactor * Amount to scale the gamma by * @return * Gammas. */ protected ArrayList<Vector> computeStateObservationLikelihood( ArrayList<WeightedValue<Vector>> alphas, ArrayList<WeightedValue<Vector>> betas, double scaleFactor ) { final int N = alphas.size(); ArrayList<Vector> gammas = new ArrayList<Vector>( N ); for( int n = 0; n < N; n++ ) { Vector alphan = alphas.get(n).getValue(); Vector betan = betas.get(n).getValue(); gammas.add( computeStateObservationLikelihood( alphan, betan, scaleFactor ) ); } return gammas; }
/** * Creates a new {@code DefaultWeightedValueDiscriminant} whose weight * and value are taken from the given weighted value. * * @param other * The other weighted value to make a shallow copy of. */ public DefaultWeightedValueDiscriminant( final WeightedValue<? extends ValueType> other) { this(other.getValue(), other.getWeight()); }
/** * Computes the probabilities of the various states over time given the * observation sequence. Rabiner calls these the "gammas". * @param alphas * Forward probabilities. * @param betas * Backward probabilities. * @param scaleFactor * Amount to scale the gamma by * @return * Gammas. */ protected ArrayList<Vector> computeStateObservationLikelihood( ArrayList<WeightedValue<Vector>> alphas, ArrayList<WeightedValue<Vector>> betas, double scaleFactor ) { final int N = alphas.size(); ArrayList<Vector> gammas = new ArrayList<Vector>( N ); for( int n = 0; n < N; n++ ) { Vector alphan = alphas.get(n).getValue(); Vector betan = betas.get(n).getValue(); gammas.add( computeStateObservationLikelihood( alphan, betan, scaleFactor ) ); } return gammas; }
/** * Gets the sum of the weights of the ensemble members. * * @return * The sum of the ensemble member weights. */ public double getWeightSum() { double sum = 0.0; for (WeightedValue<?> weighted : this.getMembers()) { sum += weighted.getWeight(); } return sum; }
/** * Computes the probability distribution over all states for each * observation. * @param observations * @return * The list of state belief probabilities for each observation. */ public ArrayList<Vector> stateBeliefs( Collection<? extends ObservationType> observations ) { ArrayList<Vector> bs = this.computeObservationLikelihoods(observations); ArrayList<WeightedValue<Vector>> alphas = this.computeForwardProbabilities(bs, true); ArrayList<Vector> beliefs = new ArrayList<Vector>( alphas.size() ); for( WeightedValue<Vector> alpha : alphas ) { beliefs.add( alpha.getValue() ); } return beliefs; }
/** * Gets the sum of the weights of the ensemble members. * * @return * The sum of the ensemble member weights. */ public double getWeightSum() { double sum = 0.0; for (WeightedValue<?> weighted : this.getMembers()) { sum += weighted.getWeight(); } return sum; }
/** * Computes the probability distribution over all states for each * observation. * @param observations * @return * The list of state belief probabilities for each observation. */ public ArrayList<Vector> stateBeliefs( Collection<? extends ObservationType> observations ) { ArrayList<Vector> bs = this.computeObservationLikelihoods(observations); ArrayList<WeightedValue<Vector>> alphas = this.computeForwardProbabilities(bs, true); ArrayList<Vector> beliefs = new ArrayList<Vector>( alphas.size() ); for( WeightedValue<Vector> alpha : alphas ) { beliefs.add( alpha.getValue() ); } return beliefs; }
/** * Creates a new {@code DefaultWeightedValueDiscriminant} whose weight * and value are taken from the given weighted value. * * @param other * The other weighted value to make a shallow copy of. */ public DefaultWeightedValueDiscriminant( final WeightedValue<? extends ValueType> other) { this(other.getValue(), other.getWeight()); }
/** * Gets the sum of the weights of the ensemble members. * * @return * The sum of the ensemble member weights. */ public double getWeightSum() { double sum = 0.0; for (WeightedValue<?> weighted : this.getMembers()) { sum += weighted.getWeight(); } return sum; }
/** * Computes the probability distribution over all states for each * observation. * @param observations * @return * The list of state belief probabilities for each observation. */ public ArrayList<Vector> stateBeliefs( Collection<? extends ObservationType> observations ) { ArrayList<Vector> bs = this.computeObservationLikelihoods(observations); ArrayList<WeightedValue<Vector>> alphas = this.computeForwardProbabilities(bs, true); ArrayList<Vector> beliefs = new ArrayList<Vector>( alphas.size() ); for( WeightedValue<Vector> alpha : alphas ) { beliefs.add( alpha.getValue() ); } return beliefs; }
/** * Creates a new {@code DefaultWeightedValueDiscriminant} whose weight * and value are taken from the given weighted value. * * @param other * The other weighted value to make a shallow copy of. */ public DefaultWeightedValueDiscriminant( final WeightedValue<? extends ValueType> other) { this(other.getValue(), other.getWeight()); }
public UnivariateGaussian.PDF getMean( List<? extends WeightedValue<? extends Double>> samples) { UnivariateGaussian.PDF pdf = UnivariateGaussian.WeightedMaximumLikelihoodEstimator.learn( samples,DEFAULT_VARIANCE); double weightSum = 0.0; double sumSquared = 0.0; for( WeightedValue<? extends Double> sample : samples ) { final double w = sample.getWeight(); weightSum += w; sumSquared += w*w; } double ws2 = weightSum*weightSum; pdf.setVariance( pdf.getVariance() * sumSquared / ws2 ); return pdf; }