def test_logGamma(): xs = range(1, 10 + 1) rs = [ 0.000000000000000000000000, 0.000000000000000000000000, 0.693147180559945286226764, 1.791759469228054957312679, 3.178053830347945751810812, 4.787491742782045811566149, 6.579251212010101212968038, 8.525161361065414666882134, 10.604602902745250858629333, 12.801827480081469090578139 ] for (x, r) in zip(xs, rs): v = ps.logGamma(x) assert about_equal(v, r, 24) assert about_equal(ps.logGamma(1234), 7546.991994272256306430790573, 24)
def test_logGamma_logFac_a(): random.seed(17) for n in range(100): x = int(2000 * random.random() + 1) v = ps.logFac(x) w = ps.logGamma(x + 1) assert about_equal(v, w, 10)
def test_logGamma_logFac_b(): random.seed(17) for n in range(100): x = 2000 * random.random() + 1 y = int(math.floor(x)) z = int(math.ceil(x)) u = ps.logFac(y) v = ps.logFac(z) w = ps.logGamma(x + 1) assert u <= w assert w <= v