Updated inference and objective functions to show expectations w.r.t. Z