Created
August 16, 2012 01:03
-
-
Save vchahun/3365224 to your computer and use it in GitHub Desktop.
Never use scipy.stats!!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scipy.stats as ss | |
import math | |
import numpy as np | |
from timeit import timeit | |
np_log_poisson = lambda k, l: -l + k * np.log(l) - math.lgamma(k+1) | |
log_poisson = lambda k, l: -l + k * math.log(l) - math.lgamma(k+1) | |
%timeit -n 10000 ss.poisson.logpmf(5, 4) # 164.0 us | |
%timeit -n 10000 ss.poisson._logpmf(5, 4) # 23.1 us | |
%timeit -n 10000 np_log_poisson(5, 4) # 11.2 us | |
%timeit -n 10000 log_poisson(5, 4) # 1.2 us |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(to be pendantic about it)