def __calculate_min_prob_rule_cell_probability(default_value, cell_probability: ProbabilityArrayCell, parent_cell_1_probability: ProbabilityArrayCell, parent_cell_2_probability: ProbabilityArrayCell, rule: sRule): if cell_probability == default_value: cell_probability = ProbabilityArrayCell() cell_probability.item_1 = min(min(rule.probability * parent_cell_1_probability.item_1), parent_cell_2_probability.item_1) cell_probability.item_2 = rule.probability * \ parent_cell_1_probability.item_2 * \ parent_cell_2_probability.item_2 else: cell_probability.item_1 = max(cell_probability.item_1, min(min(rule.probability), parent_cell_1_probability.item_1, parent_cell_2_probability.item_1)) cell_probability.item_2 = cell_probability.item_2 + rule.probability * \ parent_cell_1_probability.item_2 * \ parent_cell_2_probability.item_2 return cell_probability
def __calculate_viterbi_rule_cell_probability(default_value, cell_probability: ProbabilityArrayCell, parent_cell_1_probability: ProbabilityArrayCell, parent_cell_2_probability: ProbabilityArrayCell, rule: sRule): if cell_probability == default_value: cell_probability = ProbabilityArrayCell() cell_probability.item_1 = math.log10(rule.probability) + \ parent_cell_1_probability.item_1 * parent_cell_2_probability.item_1 cell_probability.item_2 = (rule.probability * parent_cell_1_probability.item_2 * parent_cell_2_probability.item_2) else: cell_probability.item_1 = max(cell_probability.item_1, math.log10(parent_cell_1_probability.item_1 + parent_cell_2_probability.item_1)) cell_probability.item_2 = cell_probability.item_2 + (rule.probability * parent_cell_1_probability.item_2 * parent_cell_2_probability.item_2) return cell_probability
def __calculate_baum_welch_rule_cell_probability(default_value, cell_probability: ProbabilityArrayCell, parent_cell_1_probability: ProbabilityArrayCell, parent_cell_2_probability: ProbabilityArrayCell, rule: sRule) -> ProbabilityArrayCell: if cell_probability == default_value: cell_probability = ProbabilityArrayCell() cell_probability.item_1 = rule.probability * \ parent_cell_1_probability.item_1 * \ parent_cell_2_probability.item_1 cell_probability.item_2 = rule.probability * \ parent_cell_1_probability.item_2 * \ parent_cell_2_probability.item_2 else: cell_probability.item_1 = cell_probability.item_1 + \ (rule.probability * parent_cell_1_probability.item_1 * parent_cell_2_probability.item_1) cell_probability.item_2 = cell_probability.item_2 + \ (rule.probability * parent_cell_1_probability.item_2 * parent_cell_2_probability.item_2) return cell_probability