wrote untested log likelihood and gradient and marginals and normalization constant code