Hi all,
I would like to know if there is a mathematical way to choose the appropriate value of epsilon given the maximum/minimum value of the x and y coordinates?
And will choosing a very small value of epsilon cause any sort of problems?
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 164 |
1 | maomao90 | 164 |
3 | Um_nik | 163 |
4 | atcoder_official | 160 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
8 | Dominater069 | 154 |
8 | nor | 154 |
Hi all,
I would like to know if there is a mathematical way to choose the appropriate value of epsilon given the maximum/minimum value of the x and y coordinates?
And will choosing a very small value of epsilon cause any sort of problems?
Name |
---|
That doesn't depend on the max or min value in a direct way. Say, your algorithm doesn't add any error. Then the only source of error is the round off error. Now, Let, The final value is a summation of 1000 values which have the probable error in them, then, maximum error can be roundOfErrorForOneNumber*1000.
Now, adding that much value should keep the other bits unchanged, if the error doesn't influence the result. And adding that number to result have a good chance that the result will be corrected at a certain number of places.
Write your algorithm in such a way that, it minimizes the error, and you need to add a very small number, if you need less accuracy than you can allow your algorithm to add more error, but you have to add a bigger epsilon.
Doubles can store the 53 most significant bits of a number. As 2^53 is slightly less than 10^16, this means that you'll get the 15 most significant decimal digits. A good rule of thumb is to say that the last few of those digits can become garbage due to rounding errors. So, for example, if you are working with numbers up to 10^6, a good choice of epsilon can be 10^{-6}.
Many competition problems use the phrase "10^{-9} relative or absolute error". This essentially means that just the first 9 most significant digits of your final result have to be correct. This precision requirement is intentionally lower than the precision you want to be using internally during your computation.
You can get a better estimate of a suitable epsilon if you also take into account the type and number of operations you do with your numbers. Still, using epsilons for floating-point comparison will always be a hack, and as such it is sometimes best not to overcomplicate it -- just close your eyes and hope that you guesstimated it correctly :)