where z is represented as a vector of z ij 's for all i = j. It is possible to calculate the marginal probability of each edge p(z ij = 1 | x , q ) for all i , j in O(n 3 ) time using the inside - outside algorithm ( Baker , 1979 ) on the data structures of Eisner ( 1996 ) .