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 | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 150 |
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 :)