# This is a speed-up ratio of about $5$ times faster for Numba and $10$ times faster for Cython. # In[116]: (3890 - 576) / (1160 - 576) # for Python vs numba (3890 - 576) / (901 - 576) # for Python vs Cython # ### Gaussian # In[120]: klGauss_c = lambda x, y: kullback.klGauss(x, y, 0.25) # In[121]: test_fs([klGauss, klGauss_numba, klGauss_cython, klGauss_c], lambda: (r(), r())) # In[122]: get_ipython().run_line_magic('timeit', 'klGauss(r(), r())') # In[123]:
def oneLR(self, mumax, mu): """ One term of the Lai & Robbins lower bound for Gaussian arms: (mumax - mu) / KL(mu, mumax). """ return (mumax - mu) / klGauss(mu, mumax, self.sigma)
def klGauss_vect(xs, y, sig2x=0.25): return np.array([klGauss(x, y, sig2x) for x in xs])
def kl(self, x, y): """ The kl(x, y) to use for this arm.""" return klGauss(x, y, self.sigma)