private static void trainTransitionParameters(double[] emissions, GaussianMarkovModel mm,
			GaussianForwardAlgorithm fa, GaussianBackwardsAlgorithm ba) throws Exception
	{
		int numStates = mm.getMarkovStates().length;
		double[][] A = new double[numStates][numStates] ;  
		
		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++)
				{	
					double newVal = 
				  fa.getLogProbs()[k][i]
				  + Math.log(mm.getMarkovStates()[k].getTransitionProbs()[l])
				  + GaussianViterbi.getLogEmissionProb(emissions[i+1], mm.getMarkovStates()[l])
				  + 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].getTransitionProbs()[l] = 
					(A[k][l]) / sum;
		}
	
	}