Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Value for epsilon in Python

Is there a standard value for (or method for obtaining) epsilon in Python? I need to compare floating point values and want to compare against the smallest possible difference.

In C++ there's a function provided numeric_limits::epsilon( ) which gives the epsilon value for any given data type. Is there an equivalent in Python?

like image 705
thornate Avatar asked Mar 02 '12 05:03

thornate


People also ask

How do I write an epsilon value in Python?

If you want the epsilon for Python's float , use sys.

How do I get epsilon value?

A = E l C ; where A is the absorbance; C is the concentration and l is the cell's width, E (epsilon coefficient) and its unit is mol/dm3.

How do you use e in Python?

The Python Math Library comes with the exp() function that we can use to calculate the power of e . For example, ex, which means the exponential of x. The value of e is 2.718281828459045.

How do I obtain the machine epsilon in SAS?

To get machine epsilon, use eps = constant('maceps').


1 Answers

The information is available in sys.float_info, which corresponds to float.h in C99.

>>> import sys >>> sys.float_info.epsilon 2.220446049250313e-16 
like image 53
strcat Avatar answered Oct 07 '22 13:10

strcat