Package CHEM :: Package datatype :: Module compress
[hide private]
[frames] | no frames]

Module compress



Classes [hide private]
  Codec
  EliasGammaCodec
Encode/Decode integer according to: http://www.inference.phy.cam.ac.uk/mackay/itprnn/code/c/compress/ Integer must be >=1, unless codec is initialized with the "signed=True" FORMAT: -run of zeros of length = 1 - bits needed to encode data -data, first bit MUST be 1 -(optional) 1 bit for the sign notice, that zero cannot be encoded by this scheme.
  IntegerCodec
OPTIONS:...
  QRCodec
  GolombCodec
FORMAT:...
  ReorderBits
  RandomReorderBits
  MEGICodec
FORMAT:...
  PowerLawCodec
FORMAT:...
  MEGRCodec
MEG vector encoding zero runs.
Functions [hide private]
 
log_factorial(N, base=None)
Use the Gosper approximation of a factorial (much better than Stirling) to caculate the log_{base} N!
 
IntegerWidth(N)
 
FullInteger(N)
 
RandomSet(A, N=sys.maxint)
 
RandomDict(A, N=sys.maxint, maxC=15)
 
test()
 
main()
Function Details [hide private]

log_factorial(N, base=None)

 

Use the Gosper approximation of a factorial (much better than Stirling) to caculate the log_{base} N!

$log N! \approx 0.5 \log [\pi (2*N + 1/3)]+N \log N - N$