The inside algorithm calculates formula_20 probabilities for all formula_21 of a parse subtree rooted at formula_22 for subsequence formula_23. Outside algorithm calculates formula_24 probabilities of a complete parse tree for sequence from root excluding the calculation of formula_23. The variables and refine the estimation of probability parameters of an PCFG. It is possible to reestimate the PCFG algorithm by finding the expected number of times a state is used in a derivation through summing all the products of and divided by the probability for a sequence given the model formula_11. It is also possible to find the expected number of times a production rule is used by an expectation-maximization that utilizes the values of and . The CYK algorithm calculates formula_27 to find the most probable parse tree formula_28 and yields formula_29.