Specifically, when h = 0, the marginals are given by and for h > 0, the marginals are given by where δ h,m is the Kronecker delta.
the complexity of evaluating all the relevant marginals is dominated by the matrix inversion, and the total complexity is therefore O(n 3 ).