A Derivation of variational inference