Package de.jungblut.math

Examples of de.jungblut.math.DoubleVector.max()


   *         is happening.
   */
  public double getProbabilityForSequence(int[] stateSequence) {
    DoubleVector distribution = getTransitionProbabilities(stateSequence);
    // normalize it by the maximum of the log probabilities
    double max = distribution.max();
    double probabilitySum = 0.0d;
    for (int i = 0; i < distribution.getDimension(); i++) {
      double probability = distribution.get(i);
      double normalizedProbability = probability - max;
      // add up the log probabilities
View Full Code Here


  public DoubleVector predict(DoubleVector features) {
    // clamp the features to the visible units, calculate the joint
    // probability for each hidden state and put it into the vector
    DoubleVector probabilities = emissionProbabilityMatrix
        .multiplyVectorRow(features);
    double max = probabilities.max();
    for (int state = 0; state < probabilities.getDimension(); state++) {
      probabilities.set(state, FastMath.exp(probabilities.get(state) - max)
          * hiddenPriorProbability.get(state));
    }
    // normalize again
View Full Code Here

    DoubleVector probabilities = emissionProbabilityMatrix
        .multiplyVectorRow(features);
    // we can add here, both are logarithms
    probabilities.add(transitionProbabilityMatrix
        .multiplyVectorRow(previousOutcome));
    double max = probabilities.max();
    for (int state = 0; state < probabilities.getDimension(); state++) {
      probabilities.set(state, FastMath.exp(probabilities.get(state) - max)
          * hiddenPriorProbability.get(state));
    }
    // normalize again
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.