Trees | Index | Help |
---|
Package Bio :: Module mathfns |
|
This provides useful general math tools.
Functions: fcmp Compare two floating point numbers, up to a specified precision. intd Represent a floating point number as an integer. safe_log log, but returns an arbitrarily small number for log(0). safe_exp exp, but returns a large or small number instead of overflows.Function Summary | |
---|---|
fcmp(x, y, precision) -> -1, 0, or 1 | |
intd(x[, digits_after_decimal]) -> int x, rounded | |
safe_exp(n, under=None, over=None) -> e**n | |
safe_log(n, zero=None, neg=None) -> log(n) | |
safe_log2(n, zero=None, neg=None) -> log(n) |
Variable Summary | |
---|---|
float |
LOG2 = 0.69314718055994529 |
Function Details |
---|
fcmp(x, y, precision)fcmp(x, y, precision) -> -1, 0, or 1 |
intd(x, digits_after_decimal=0)intd(x[, digits_after_decimal]) -> int x, rounded Represent a floating point number with some digits after the decimal point as an integer. This is useful when floating point comparisons are failing due to precision problems. e.g. intd(5.35, 1) -> 54. |
safe_exp(n, under=None, over=None)safe_exp(n, under=None, over=None) -> e**n Guaranteed not to overflow. Instead of overflowing, it returns the values of 'under' for underflows or 'over' for overflows. |
safe_log(n, zero=None, neg=None)safe_log(n, zero=None, neg=None) -> log(n) Calculate the log of n. If n is 0, returns the value of zero. If n is negative, returns the value of neg. |
safe_log2(n, zero=None, neg=None)safe_log2(n, zero=None, neg=None) -> log(n) Calculate the log base 2 of n. If n is 0, returns the value of zero. If n is negative, returns the value of neg. |
Variable Details |
---|
LOG2
|
Trees | Index | Help |
---|
Generated by Epydoc 2.1 on Sat Jul 16 15:49:03 2005 | http://epydoc.sf.net |