def setUp(self):
        """Setup the test probabilities.
        """
        self.a_num_states = 4
        self.y_num_states = 8
        self.z_num_states = 8
        self.letter_pause_num_states = 1
        self.word_space_num_states = 1
        self.num_outputs = 2

        (self.a_states, self.a_prior_probs, self.a_transition_probs,
         self.a_emission_probs, self.y_states, self.y_prior_probs,
         self.y_transition_probs, self.y_emission_probs, self.z_states,
         self.z_prior_probs, self.z_transition_probs, self.z_emission_probs,
         self.letter_pause_states, self.letter_pause_prior_probs,
         self.letter_pause_transition_probs, self.letter_pause_emission_probs,
         self.word_space_states, self.word_space_prior_probs,
         self.word_space_transition_probs,
         self.word_space_emission_probs) = part_2_a()

        self.evidence_vector = [1, 0, 1, 1, 1]

        self.correct_letter = 'A'
        self.correct_probability = round(0.0310689, 6)

        self.part_2b_answer = part_2_b(self.evidence_vector, self.a_states,
                                       self.a_prior_probs,
                                       self.a_transition_probs,
                                       self.a_emission_probs)
    def test_part_2b_probability_case1(self):
        #evidence_vector = [1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1,1,0,1,1,1,0,1,0,1,0,0,0,0,0,0,0]
        #evidence_vector = [0,0,0,0,0,0,0,1,1,1,0,1,0,1,1,1,0,1,1,1,0,0,0,1,0,1,1,1,0,0,1,1,1,0,0,1,1,1,0,1,0,1,0,0,0,0,0,0,1,0,1,1,1,1,0,0,0]
        evidence_vector = [
            1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0,
            1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1
        ]
        letter, probability =  part_2_b(evidence_vector, self.a_states + self.y_states + self.z_states + self.letter_pause_states + self.word_space_states,\
                                        dict(self.a_prior_probs.items() + self.y_prior_probs.items() + self.z_prior_probs.items() + self.letter_pause_prior_probs.items() + self.word_space_prior_probs.items()), \
                                        dict(self.a_transition_probs.items() + self.y_transition_probs.items() + self.z_transition_probs.items() + self.letter_pause_transition_probs.items()+ self.word_space_transition_probs.items()),\
                                        dict(self.a_emission_probs.items() + self.y_emission_probs.items() + self.z_emission_probs.items() + self.letter_pause_emission_probs.items() + self.word_space_emission_probs.items()))

        print(letter, probability)
    def setUp(self):
        """Setup the test probabilities.
        """
        self.a_num_states = 4
        self.y_num_states = 8
        self.z_num_states = 8
        self.letter_pause_num_states = 1
        self.word_space_num_states = 1
        self.num_outputs = 2

        (self.a_states,
         self.a_prior_probs,
         self.a_transition_probs,
         self.a_emission_probs,
         self.y_states,
         self.y_prior_probs,
         self.y_transition_probs,
         self.y_emission_probs,
         self.z_states,
         self.z_prior_probs,
         self.z_transition_probs,
         self.z_emission_probs,
         self.letter_pause_states,
         self.letter_pause_prior_probs,
         self.letter_pause_transition_probs,
         self.letter_pause_emission_probs,
         self.word_space_states,
         self.word_space_prior_probs,
         self.word_space_transition_probs,
         self.word_space_emission_probs) = part_2_a()

#        self.evidence_vector = [1, 0, 1, 1, 1]
#        self.evidence_vector = [1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1,0,1,1,1]
#        self.evidence_vector = [1,1,1,0,1,1,1,0,1,0,0,0,1,0,0,0,1,1,1,1,1,0,1,1,1,0,1,0,0,0,0,0,1,1,1]
        self.evidence_vector =  [1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1]
        self.correct_letter = 'A'
        self.correct_probability = round(0.0310689, 6)
        prior_probs = {}
        for key, value in self.a_prior_probs.iteritems():
            prior_probs[key] = value
        for key, value in self.y_prior_probs.iteritems():
            prior_probs[key] = value
        for key, value in self.z_prior_probs.iteritems():
            prior_probs[key] = value
        for key, value in self.letter_pause_prior_probs.iteritems():
            prior_probs[key] = value
        for key, value in self.word_space_prior_probs.iteritems():
            prior_probs[key] = value
        states = []
        states = states + self.a_states + self.y_states + self.z_states + self.letter_pause_states + self.word_space_states 
#        states.append(self.a_states)
#        states.append(self.y_states)
#        states.append(self.z_states)
#        states.append(self.letter_pause_states)
#        states.append(self.word_space_states)
        transition_probs = {}
        for key, value in self.a_transition_probs.iteritems():
            transition_probs[key] = value
        for key, value in self.y_transition_probs.iteritems():
            transition_probs[key] = value
        for key, value in self.z_transition_probs.iteritems():
            transition_probs[key] = value
        for key, value in self.letter_pause_transition_probs.iteritems():
            transition_probs[key] = value
        for key, value in self.word_space_transition_probs.iteritems():
            transition_probs[key] = value
        emission_probs = {}
        for key, value in self.a_emission_probs.iteritems():
            emission_probs[key] = value
        for key, value in self.y_emission_probs.iteritems():
            emission_probs[key] = value
        for key, value in self.z_emission_probs.iteritems():
            emission_probs[key] = value
        for key, value in self.letter_pause_emission_probs.iteritems():
            emission_probs[key] = value
        for key, value in self.word_space_emission_probs.iteritems():
            emission_probs[key] = value
#        print prior_probs
#        print states
#        prior_probs_bis = {}
#        for i in range(len(states)):
#            prior_probs_bis[states[i]] = prior_probs[states[i]]
#        print prior_probs_bis
        print emission_probs
        
        
        self.part_2b_answer = part_2_b(self.evidence_vector,
                                       states,
                                       prior_probs,
                                       transition_probs,
                                       emission_probs)
    def setUp(self):
        """Setup the test probabilities.
        """
        self.a_num_states = 4
        self.y_num_states = 8
        self.z_num_states = 8
        self.letter_pause_num_states = 1
        self.word_space_num_states = 1
        self.num_outputs = 2

        (self.a_states, self.a_prior_probs, self.a_transition_probs,
         self.a_emission_probs, self.y_states, self.y_prior_probs,
         self.y_transition_probs, self.y_emission_probs, self.z_states,
         self.z_prior_probs, self.z_transition_probs, self.z_emission_probs,
         self.letter_pause_states, self.letter_pause_prior_probs,
         self.letter_pause_transition_probs, self.letter_pause_emission_probs,
         self.word_space_states, self.word_space_prior_probs,
         self.word_space_transition_probs,
         self.word_space_emission_probs) = part_2_a()

        self.evidence_vector = [1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1]
        # A A A
        #self.evidence_vector = [1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1]
        # ZZ
        #self.evidence_vector = [1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1]
        # Y Y Y
        #self.evidence_vector = [1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1]
        # Z Z Z
        #self.evidence_vector = [1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1]
        # A Y
        #self.evidence_vector = [1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1]
        # A Y Z
        #self.evidence_vector = [1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1]
        #self.evidence_vector = [1, 0]
        # Y Z
        #self.evidence_vector = [1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0,0, 1, 0]
        # AYZ
        self.evidence_vector = [1, 0, 1, 1, 1]

        self.correct_letter = 'A'
        self.correct_probability = round(0.0310689, 6)

        # Temp
        """
	self.evidence_vector = [1,0,1,1,1,0,0,0,1,0,1,1,1]
	self.a_states = ['A1','A2','A3','Aend','L1']
	self.a_prior_probs = {'A1' : 0.333,
			      'A2' : 0.0,
			      'A3' : 0.0,
			    'Aend' : 0.0,
			      'L1' : 0.0}
	self.a_transition_probs = {'A1'  : {'A1'  : 0.2,
	                	            'A2'  : 0.8,
        		                    'A3'  : 0.0,
                               		    'Aend': 0.0},
	                           'A2'  : {'A1'  : 0.0,
             			            'A2'  : 0.2,
                	        	    'A3'  : 0.8,
		                            'Aend': 0.0},
	                           'A3'  : {'A1'  : 0.0,
             			            'A2'  : 0.0,
                               		    'A3'  : 0.667,
                               		    'Aend': 0.1665,
					    'L1'  : 0.1665},
                      		   'Aend': {'A1'  : 0.0,
                               		    'A2'  : 0.0,
                               		    'A3'  : 0.0,
                               		    'Aend': 1.0},
				   'L1'  : {'L1'  : 0.667,
					    'A1'  : 0.111,
					    'Y1'  : 0.111,
					    'Z1'  : 0.111}}
	self.a_emission_probs = {'A1' : [0.2,0.8],
				 'A2' : [0.8,0.2],
				 'A3' : [0.2,0.8],
				'Aend': [0.0,0.0],
				 'L1' : [0.8,0.2]}
	"""
        # Temp
        #self.states = self.a_states + self.letter_pause_states
        self.states = self.a_states
        self.trans_probs = self.a_transition_probs.copy()
        #self.trans_probs.update(self.letter_pause_transition_probs)
        self.prior_probs = self.a_prior_probs.copy()
        #self.prior_probs.update(self.letter_pause_prior_probs)
        self.emission_probs = self.a_emission_probs.copy()
        #self.emission_probs.update(self.letter_pause_emission_probs)
        """
        self.states = self.z_states + self.word_space_states
        self.trans_probs =  self.z_transition_probs.copy()
	self.trans_probs.update(self.word_space_transition_probs)
	self.prior_probs = self.z_prior_probs.copy()
	self.prior_probs.update(self.word_space_prior_probs)
	self.emission_probs = self.z_emission_probs.copy()
	self.emission_probs.update(self.word_space_emission_probs)

        self.states = self.a_states + self.letter_pause_states + self.word_space_states + self.y_states + self.z_states
        self.trans_probs =  self.a_transition_probs.copy()
	self.trans_probs.update(self.word_space_transition_probs)
	self.trans_probs.update(self.letter_pause_transition_probs)
	self.trans_probs.update(self.y_transition_probs)
	self.trans_probs.update(self.z_transition_probs)
	self.prior_probs = self.a_prior_probs.copy()
	self.prior_probs.update(self.word_space_prior_probs)
	self.prior_probs.update(self.letter_pause_prior_probs)
	self.prior_probs.update(self.y_prior_probs)
	self.prior_probs.update(self.z_prior_probs)
	self.emission_probs = self.a_emission_probs.copy()
	self.emission_probs.update(self.word_space_emission_probs)
	self.emission_probs.update(self.letter_pause_emission_probs)
	self.emission_probs.update(self.y_emission_probs)
	self.emission_probs.update(self.z_emission_probs)
	"""

        self.part_2b_answer = part_2_b(self.evidence_vector, self.states,
                                       self.prior_probs, self.trans_probs,
                                       self.emission_probs)