def test_tklmbda_zero_shape(self): # When lmbda = 0 the CDF has a simple closed form one = mpmath.mpf(1) assert_mpmath_equal( lambda x: sp.tklmbda(x, 0), lambda x: one/(mpmath.exp(-x) + one), [Arg()], rtol=1e-7)
def _pdf(self, x, lam): lam = numpy.zeros(x.shape) + lam output = numpy.zeros(x.shape) indices = (lam <= 0) | (numpy.abs(x) * lam < 1) lam = lam[indices] Fx = special.tklmbda(x[indices], lam) Px = 1 / (Fx**(lam - 1.0) + ((1 - Fx))**(lam - 1.0)) output[indices] = Px return output
def _pdf(self, x, lam): lam = numpy.zeros(x.shape) + lam output = numpy.zeros(x.shape) indices = (lam <= 0) | (numpy.abs(x)*lam < 1) lam = lam[indices] Fx = special.tklmbda(x[indices], lam) Px = 1/(Fx**(lam-1.0) + ((1-Fx))**(lam-1.0)) output[indices] = Px return output
def _cdf(self, x, lam): return special.tklmbda(x, lam)
def _pdf(self, x, lam): Fx = (special.tklmbda(x,lam)) Px = Fx**(lam-1.0) + ((1-Fx))**(lam-1.0) Px = 1.0/(Px) return np.where((lam <= 0) | (abs(x) < 1.0/(lam)), Px, 0.0)