Inside and outside probabilities
The inside probability
is the total probability of generating words
, given the root nonterminal
and a grammar
:

The outside probability
is the total probability of beginning with the start symbol
and generating the nonterminal
and all the words outside
, given a grammar
:

Computing inside probabilities
Base Case:

General case:
Suppose there is a rule
in the grammar, then the probability of generating
starting with a subtree rooted at
is:

The inside probability
is just the sum over all such possible rules:

Computing outside probabilities
Base Case:

Here the start symbol is
.
General case:
Suppose there is a rule
in the grammar that generates
.
Then the left contribution of that rule to the outside probability
is:

Now suppose there is a rule
in the grammar. Then the right
contribution of that rule to the outside probability
is:

The outside probability
is the sum of the left and right
contributions over all such rules:
