Questions tagged [epsilon]

The machine epsilon gives an upper bound on the relative error due to rounding in floating point arithmetic. The quantity is also called "macheps" or "unit roundoff".

The IEEE standard does not define the terms machine epsilon and unit roundoff, so differing definitions of these terms are in use, which can cause some confusion.

The following different definition is much more widespread outside academia: Machine epsilon is defined as the smallest number that, when added to one, yields a result different from one.

139 questions
118
votes
3 answers

python numpy machine epsilon

I am trying to understand what is machine epsilon. According to the Wikipedia, it can be calculated as follows: def machineEpsilon(func=float): machine_epsilon = func(1) while func(1)+func(machine_epsilon) != func(1): …
Bob
  • 8,643
  • 19
  • 58
  • 68
74
votes
4 answers

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…
thornate
  • 4,202
  • 9
  • 36
  • 42
56
votes
9 answers

Double.Epsilon for equality, greater than, less than, less than or equal to, greater than or equal to

http://msdn.microsoft.com/en-us/library/system.double.epsilon.aspx If you create a custom algorithm that determines whether two floating-point numbers can be considered equal, you must use a value that is greater than the Epsilon constant…
ss2k
  • 1,158
  • 1
  • 11
  • 19
46
votes
3 answers

C# Decimal.Epsilon

Why doesn't Decimal data type have Epsilon field? From the manual, the range of decimal values is ±1.0 × 10e−28 to ±7.9 × 10e28. The description of Double.Epsilon: Represents the smallest positive Double value greater than zero So it seems,…
Roland Pihlakas
  • 3,739
  • 1
  • 35
  • 58
32
votes
2 answers

.NET Math.Log10() behaves differently on different machines

I found that running Math.Log10(double.Epsilon) will return about -324 on machine A, but will return -Infinity on machine B. They originally behaved the same way by returning -324. Both machines started out using the same OS (WinXP SP3) and .NET…
24
votes
2 answers

Get next smallest Double number

As part of a unit test, I need to test some boundary conditions. One method accepts a System.Double argument. Is there a way to get the next-smallest double value? (i.e. decrement the mantissa by 1 unit-value)? I considered using Double.Epsilon but…
Dai
  • 110,988
  • 21
  • 188
  • 277
22
votes
4 answers

Why does adding double.epsilon to a value result in the same value, perfectly equal?

I have a unit test, testing boundaries: [TestMethod] [ExpectedException(typeof(ArgumentOutOfRangeException))] public void CreateExtent_InvalidTop_ShouldThrowArgumentOutOfRangeException() { var invalidTop = 90.0 + Double.Epsilon; new…
sprocket12
  • 5,040
  • 16
  • 56
  • 122
19
votes
2 answers

Java: Double machine epsilon is not the smallest x such that 1+x != 1?

I am trying to determine the double machine epsilon in Java, using the definition of it being the smallest representable double value x such that 1.0 + x != 1.0, just as in C/C++. According to wikipedia, this machine epsilon is equal to 2^-52 (with…
Franz D.
  • 929
  • 7
  • 21
18
votes
2 answers

Does "epsilon" really guarantees anything in floating-point computations?

To make the problem short let's say I want to compute the expression a / (b - c) on floats. To make sure the result is meaningful, I can check if b and c are in equal: float EPS = std::numeric_limits::epsilon(); if ((b - c) > EPS || (c - b) >…
Michal Czardybon
  • 2,685
  • 4
  • 27
  • 39
12
votes
1 answer

How does the epsilon hyperparameter affect tf.train.AdamOptimizer?

When I set epsilon=10e-8, AdamOptimizer doesn't work. When I set it to 1, it works just fine.
hhb1994
  • 131
  • 1
  • 5
12
votes
3 answers

How to calculate 32-bit floating-point epsilon?

In book Game Engine Architecture : "..., let’s say we use a floating-point variable to track absolute game time in seconds. How long can we run our game before the magnitude of our clock variable gets so large that adding 1/30th of a second to it no…
Xia Cuo
  • 123
  • 5
11
votes
3 answers

Why is "(2.5 < 2.5 + Number.EPSILON)" false in JavaScript?

I want to find values less than a certain value in the array. I tried to use Number.EPSILON because the input value is not a definite value (eg 1.5000000000001). I found something strange during the test: >> (1.5 < 1.5 + Number.EPSILON) <- true…
Wakeup
  • 145
  • 6
11
votes
4 answers

Is the use of machine epsilon appropriate for floating-point equality tests?

This is a follow-up to Testing for floating-point value equality: Is there a standard name for the “precision” constant?. There is a very similar question Double.Epsilon for equality, greater than, less than, less than or equal to, greater than or…
10
votes
2 answers

IEqualityComparer with a tolerance; how to implement GetHashCode?

I'm implementing a reusable DoubleEqualityComparer (with a custom tolerance: the "epsilon" constructor parameter) to ease the usage of LINQ with sequences of double. For example: bool myDoubleFound = doubles.Contains(myDouble, new…
Notoriousxl
  • 1,430
  • 1
  • 15
  • 27
10
votes
3 answers

calculating a function in matlab with very small values

I am making a function in matlab to compute the following function: for this function we have: This is my implementation in matlab of the function: function [b]= exponential(e) %b = ? b= (exp (e) -1)/e; When I test the function with very small…
franvergara66
  • 9,675
  • 17
  • 51
  • 98
1
2 3
9 10