5 ms·
Well, technically the probability of getting exactly 1 should be 0. Thanks to rounding, it isn't literally a 0 probability, but for any practical purposes the
by powera 12y ago
Well, technically the probability of getting exactly 1 should be 0. Thanks to rounding, it isn't literally a 0 probability, but for any practical purposes the open and closed sets should be equivalent.
- forrestthewoods 12y agoNo. No no. No no no! Stop that. Stop that right now. You are a bad person and should feel bad. I've dealt with more than a few crashes that came from open vs closed set differences. Yeah, the odds of it happening on a given roll of the dice is low. About one in 8 million for a 32-bit float. But if you have 100,000 users and they each roll that dice even a single time per use of your application then it soon becomes less about the odds of it happening and more about how many times it happens per day. And if it happening can cause a crash, well you're gonna have a bad time. And since you're dealing with floating point numbers they're interacting with gods know what so all it takes to cause a crash is "oh this operation can never result in a divide by zero because this other value can never be exactly one". Oops.
- Dylan16807 12y agoHeh. You're very right about the generation of 1. Even 2^54ish is not rare enough to ignore. Put it in GPU code and you could find it breaking in seconds. But would you be comfortable ignoring double precision 0, with a proper algorithm that makes the probability somewhere around 2^-1070 or 2^-1020?
- forrestthewoods 12y agoI'd always prefer an algorithm to be correct 100% of the time than any rate than 100%. This is the type of thing for which there is no fundamental reason why you can't simply do it right. The more things you can do right the less you have to worry about! It's much simpler. That said, I'd certainly listen to the tradeoffs of being correct 100% of the time vs being wrong a mere 1 in 2^1020 times. I wonder if 2^-1020 is greater than or less than the chance of a cosmic ray flipping a bit...
- Dylan16807 12y agoIt's far far far smaller of a chance than a memory error. Unimaginably smaller. Now that I think about it, smaller enough that the execution time difference makes it more dangerous to check. :)
- forrestthewoods 12y agoSince I was curious, it appears that IBM did research in the 90s and came up with 1 per 256mb RAM per month. That's 3.7 × 10-9 per byte per month or 1.4 × 10-15 per byte per second. http://stackoverflow.com/questions/2580933/cosmic-rays-what-is-the-probability-they-will-affect-a-program http://stackoverflow.com/questions/2580933/cosmic-rays-what-...
- cma 12y agoThe surface area of 256MB of ram has shrunk a lot since then.
- Dylan16807 12y agoThough the bits have gotten more fragile.
- bhickey 12y agoI can promise you that powera knows something about reliable software. Any indication to the contrary is just loose talk. :)
- forrestthewoods 12y agoI'm sure he does. But I wouldn't want anyone less experienced to read his comment and get the wrong idea. Young minds are impressionable after all! :)
- octatoan 12y agoI don't know any measure theory or whatever, but someone who's good at probability needs to chime in here.
- mikeash 12y agoConfusing floats with reals is a mortal sin. The probability of a random real in [0, 1] being 1 is zero, but the probability for a float definitely is not.