Back to index

python3.2  3.2.2
Classes | Functions
test.test_random Namespace Reference

Classes

class  TestBasicOps
class  SystemRandom_TestBasicOps
class  MersenneTwister_TestBasicOps
class  TestDistributions
class  TestModule

Functions

def gamma
def test_main

Function Documentation

def test.test_random.gamma (   z,
  sqrt2pi = (2.0*pi)**0.5 
)

Definition at line 412 of file test_random.py.

00412 
00413 def gamma(z, sqrt2pi=(2.0*pi)**0.5):
00414     # Reflection to right half of complex plane
00415     if z < 0.5:
00416         return pi / sin(pi*z) / gamma(1.0-z)
00417     # Lanczos approximation with g=7
00418     az = z + (7.0 - 0.5)
00419     return az ** (z-0.5) / exp(az) * sqrt2pi * fsum([
00420         0.9999999999995183,
00421         676.5203681218835 / z,
00422         -1259.139216722289 / (z+1.0),
00423         771.3234287757674 / (z+2.0),
00424         -176.6150291498386 / (z+3.0),
00425         12.50734324009056 / (z+4.0),
00426         -0.1385710331296526 / (z+5.0),
00427         0.9934937113930748e-05 / (z+6.0),
00428         0.1659470187408462e-06 / (z+7.0),
00429     ])

Here is the caller graph for this function:

def test.test_random.test_main (   verbose = None)

Definition at line 497 of file test_random.py.

00497 
00498 def test_main(verbose=None):
00499     testclasses =    [MersenneTwister_TestBasicOps,
00500                       TestDistributions,
00501                       TestModule]
00502 
00503     try:
00504         random.SystemRandom().random()
00505     except NotImplementedError:
00506         pass
00507     else:
00508         testclasses.append(SystemRandom_TestBasicOps)
00509 
00510     support.run_unittest(*testclasses)
00511 
00512     # verify reference counting
00513     import sys
00514     if verbose and hasattr(sys, "gettotalrefcount"):
00515         counts = [None] * 5
00516         for i in range(len(counts)):
00517             support.run_unittest(*testclasses)
00518             counts[i] = sys.gettotalrefcount()
00519         print(counts)