function for computing marginals in trees added
tree example added