#! /usr/bin/python2

from __future__ import division

import numpy


# JAKE
def calc_perplexity(test_counts_dict, trigram_probs_dict):
    '''
    # Calculates perplexity of contents of file_string
    # according to probabilities in trigram_probs_dict.
    '''

    test_probs = []

    for trigram, count in test_counts_dict.items():

        for n in range(count):
            logprob = numpy.log10(trigram_probs_dict[trigram])
            test_probs.append(logprob)

    logprob = sum(test_probs)
    print "LOGPROB: {0}" .format(logprob)

    norm = logprob / len(test_probs)

    perplexity = numpy.power(2, -norm)

    return perplexity

@@ -396,10 +396,9 @@
 .log
-10
+2
 (tri
@@ -540,20 +540,23 @@
 b)%0A%0A    
-norm
+entropy
  = logpr
@@ -614,12 +614,15 @@
 2, -
-norm
+entropy
 )%0A%0A 

Use log2 instead of log10.