Added derivation to documentation of perplexity calculating function.