refactoring gradient calculations and adding likelihood terms with derivations.
Merge branch 'porkchop' of https://github.com/pbailis/spark into porkchop