private static void trainTransitionParameters(String[] emissions, MarkovModel mm,
			ForwardAlgorithm fa, BackwardsAlgorithm ba) throws Exception
	{
		int numStates = mm.getMarkovStates().length;
		double[][] A = new double[numStates][numStates] ;  // all zero; no pseudocounts
		
		double logPx = fa.getLogFinalPValue();
		
		for( int i=0; i < emissions.length-1; i++)
			for( int k=0; k < numStates; k++)
				for( int l=0; l < numStates; l++)
				{
					int nextEmissionIndex = 
						mm.getIndexForEmission(emissions[i+1]);
					
					double newVal = 
				  fa.getLogProbs()[k][i]
				  + Math.log(mm.getMarkovStates()[k].getTransitionDistribution()[l])
				 + Math.log(mm.getMarkovStates()[l].getEmissionDistribution()[nextEmissionIndex]) 
				  + ba.getLogProbs()[l][i+1] - logPx;
					
					A[k][l] += Math.exp(newVal);
				}
		
		for( int k=0; k < numStates; k++)
		{
			double sum =0;
			
			for( int l=0; l < numStates; l++)
				sum += A[k][l];
			
			for( int l=0; l < numStates; l++)
				mm.getMarkovStates()[k].getTransitionDistribution()[l] = 
					(A[k][l]) / sum;
		}
	
	}