Ported KL Divergence code, needs testing to plot