Examples of HMM


Examples of aima.core.probability.hmm.impl.HMM

    sensorModel.put(Boolean.TRUE, new Matrix(new double[][] { { 0.9, 0.0 },
        { 0.0, 0.2 } }));
    sensorModel.put(Boolean.FALSE, new Matrix(new double[][] {
        { 0.1, 0.0 }, { 0.0, 0.8 } }));
    Matrix prior = new Matrix(new double[] { 0.5, 0.5 }, 2);
    return new HMM(ExampleRV.RAIN_t_RV, transitionModel, sensorModel, prior);
  }
View Full Code Here

Examples of com.nr.ci.HMM

        }
      }
    }

    // Try to discover the model, given the symbols
    HMM hmm=new HMM(atrans,b,symbols);
    hmm.forwardbackward();

    // Inspect results
    int jmax=0,ncorrect=0;
    double test;
    for (i=0;i<N;i++) {
      test=0;
      for (j=0;j<M;j++) {
        if (hmm.pstate[i][j] > test) {
          test=hmm.pstate[i][j];
          jmax=j;
        }
      }
//      System.out.printf(state[i] << " %f\n", jmax);
      if (jmax == state[i]) ncorrect++;
    }
    System.out.printf("Fraction correct: %f\n", (double)(ncorrect)/N);
    localflag = (double)(ncorrect)/N < 0.75;
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** HMM: Actual state was not the top probability more than 25% of the time");
     
    }

    // Inspect reconstructed transition matrix
    int jpen=0;
    ncorrect=0;
    for (i=0;i<N;i++) {
      test=0.0;
      for (j=0;j<M;j++) {
        if (hmm.pstate[i][j] > test) {
          test=hmm.pstate[i][j];
          jmax=j;
        }
      }

      // Find second largest
      test=0.0;
      for (j=0;j<M;j++) {
        if (j != jmax) {
          if (hmm.pstate[i][j] > test) {
            test=hmm.pstate[i][j];
            jpen=j;
          }
        }
      }
   
//      System.out.printf(state[i] << " %f\n", jmax);
      if (jmax == state[i] || jpen == state[i]) ncorrect++;
    }
    System.out.printf("Fraction correct: %f\n", (double)(ncorrect)/N);
    double beforeBW=(double)(ncorrect)/N;
    localflag = (double)(ncorrect)/N < 0.95;
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** HMM: Actual state was not in top 2 probabilities more than 5% of the time");
     
    }
   
//    System.out.println("Log-likelihood: %f\n", hmm.loglikelihood());

    // Test Baum-Welch reestimation
    for (i=0;i<100;i++) {
      hmm.baumwelch();
      hmm.forwardbackward();
//      System.out.println("Log-likelihood: %f\n", hmm.loglikelihood());
    }

    // Inspect reconstructed transition matrix
    ncorrect=0;
View Full Code Here

Examples of edu.cmu.sphinx.linguist.acoustic.HMM

            //        + " size " + endNodeMap.size());
            Map<HMM, HMMNode> resultMap = new HashMap<HMM, HMMNode>();
            Unit baseUnit = endNode.getBaseUnit();
            Unit lc = endNode.getLeftContext();
            for (Unit rc : entryPoints) {
                HMM hmm = hmmPool.getHMM(baseUnit, lc, rc, HMMPosition.END);
                HMMNode hmmNode = resultMap.get(hmm);
                if (hmmNode == null) {
                    hmmNode = new HMMNode(hmm, LogMath.LOG_ONE);
                    resultMap.put(hmm, hmmNode);
                }
View Full Code Here

Examples of edu.cmu.sphinx.linguist.acoustic.HMM

            curNode = ep.getNode();
            lc = baseUnit;
            for (int i = 1; i < units.length - 1; i++) {
                baseUnit = units[i];
                rc = units[i + 1];
                HMM hmm = hmmPool.getHMM(baseUnit, lc, rc, HMMPosition.INTERNAL);
                if (hmm == null) {
                    logger.severe("Missing HMM for unit " + baseUnit.getName() + " with lc=" + lc.getName() + " rc=" + rc.getName());
                } else {
                    curNode = curNode.addSuccessor(hmm, probability);
                }
View Full Code Here

Examples of edu.cmu.sphinx.linguist.acoustic.HMM

            HashMap<HMM, HMMNode> singleUnitMap = new HashMap<HMM, HMMNode>();

            for (Unit lc : exitPoints) {
                Node epNode = new Node(LogMath.LOG_ZERO);
                for (Unit rc : getEntryPointRC()) {
                    HMM hmm = hmmPool.getHMM(baseUnit, lc, rc, HMMPosition.BEGIN);
                    Node addedNode;

                    if ((addedNode = map.get(hmm)) == null) {
                        addedNode = epNode.addSuccessor(hmm, getProbability());
                        map.put(hmm, addedNode);
View Full Code Here

Examples of edu.cmu.sphinx.linguist.acoustic.HMM

         */
        private void connectSingleUnitWords(Unit lc, Node epNode, HashMap<HMM, HMMNode> map) {
            if (!singleUnitWords.isEmpty()) {
               
                for (Unit rc : entryPoints) {
                    HMM hmm = hmmPool.getHMM(baseUnit, lc, rc, HMMPosition.SINGLE);
                   
                    HMMNode tailNode;
                    if (( tailNode = map.get(hmm)) == null) {
                        tailNode = (HMMNode)
                                epNode.addSuccessor(hmm, getProbability());
View Full Code Here

Examples of edu.cmu.sphinx.linguist.acoustic.HMM

            if (generateUnitStates) {
                arc = new LexTreeUnitState(hmmNode, getWordHistory(), previous
                        .getSmearTerm(), smearProbability, languageProbability,
                        insertionProbability, collapsed);
            } else {
                HMM hmm = hmmNode.getHMM();
                arc = new LexTreeHMMState(hmmNode, getWordHistory(), previous
                        .getSmearTerm(), smearProbability, hmm.getInitialState(),
                        languageProbability, insertionProbability, null, collapsed);
            }
            return arc;
        }
View Full Code Here

Examples of edu.cmu.sphinx.linguist.acoustic.HMM

                                getSmearProb(), logOne, logOne,
                                this.getNode(), collapsed);
                    }
                } else {
                    for (int i = 0; i < nodes.length; i++) {
                        HMM hmm = nodes[i].getHMM();
                        arcs[i] = new LexTreeHMMState(nodes[i],
                                getWordHistory(), getSmearTerm(),
                                getSmearProb(), hmm.getInitialState(),
                                logOne, logOne, this.getNode(), collapsed);
                    }
                }
                putCachedArcs(arcs);
            }
View Full Code Here

Examples of edu.cmu.sphinx.linguist.acoustic.HMM

         * @return a list of SearchState objects
         */
        @Override
        public SearchStateArc[] getSuccessors() {
            SearchStateArc[] arcs = new SearchStateArc[1];
            HMM hmm = getHMMNode().getHMM();
            arcs[0] = new LexTreeHMMState(getHMMNode(), getWordHistory(),
                    getSmearTerm(), getSmearProb(), hmm.getInitialState(),
                    logOne, logOne, parentNode, collapsed);
            return arcs;
        }
View Full Code Here

Examples of edu.cmu.sphinx.linguist.acoustic.HMM

        return new TableEventMap(key, table);
    }

    @Override
    public HMM get(HMMPosition position, Unit unit) {
        HMM hmm = super.get(position, unit);
        if (null != hmm) return hmm;

        int[] ids = new int[3];
        ids[1] = symbolTable.get(unit.getName());
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.