5 ms·
I worked on a system that performed a flaky test at run time and made it a condition that it had to succeed in order to run. Oh boy. Basically, it generated a
by kazinator 10y ago
I worked on a system that performed a flaky test at run time and made it a condition that it had to succeed in order to run. Oh boy.
Basically, it generated a sample of numbers from the RNG (not PRNG: real random source). Then it ran statistical tests of randomness to validate, "yes, we have good random-numbers for security and whatnot".
Of course, these tests can fail; there is a nonzero probability that some pattern emerges which looks non-random to the tests; that's a consequence of them being really random.
How lame.
- flukus 10y agoCan that be fixed with a larger sample size at startup? Of course the validation should be done long before startup.
- rcthompson 10y agoIf the RNG is truly random, then it must have a non-zero probability of failing any test for randomness that uses a finite sample of the RNG's output. For instance, the RNG could theoretically return a sequence of all the same number. You can't "fix" this.
- flukus 10y agoSure, but there is a big difference between flakey and non-zero. A 1 in a million chance would probably be more acceptable, a 1 in a hundred chance, not so much.
- pkolaczk 10y agoYou can often make the failure probability extremely low, like 1e-30. Then it is more likely the server performing the test would break than the test fails due to a chance.
- runeks 10y agoI don't think testing for randomness makes sense. Randomness is something we assume. There's always a non-zero probability that randomness will appear non-random. In fact, this whole comment is a random string of characters. I just got really lucky, and there's essentially no way to disprove that. Throwing a dice a trillion times and getting all 6's is not an invalid outcome, just very improbable. Randomness is about unpredictability. How can you assert that something is or is not predictable? It's always possible you just haven't observed it for long enough. An initial, randomly-appearing sequence may turn out to start repeating itself after some point in time; and an initial, self-repeating sequence can always be statistically cancelled out by later data. Randomness is not something we can have; it's something we don't have (the ability to predict).
- flukus 10y agoIs there an alternative? Can you mathematically prove randomness? (real question I'm not a mathemagician) If you can how do you verify that there is not an implementation bug in the code? I think it might be a case of perfect being the enemy of good, the best approach is to minimize the false negatives.
- rocqua 10y agoYou can disprove randomness (by prediction) but you can't prove randomness. You can prove that certain results are as one would expect for a random source, but that is neither guaranteed to be passed by uniform randomness, nor does passing guarantee true randomness. On a more philosophical level, as you get better measurements, entropy of a random source will always decrease. Time-stamp seeding, for example, can be weakened by timing. What can be done, on the theoretical level for PRNGs is to see how easy it is to predict the next iteration from the current iteration. An easy bound here is simply the period of the PRNG.
- misja111 10y agoOn the contrary, randomness is everywhere. Newtonian physics are nothing more than the statistical properties of quantum randomness with a large enough sample size. To test the randomness of the RNG you could make the sample size so large that the chance of a false positive would be smaller than the chance of some memory bit flipping as a result of the Heisenberg uncertainty principle.
- setr 10y agoWouldn't a statistical test presumably have some minimum number of trials to hit some confidence value I mean like the half the point of stats is to verify a result isn't due to chance, at least to an acceptable degree Wouldn't gaurantee the test won't misdiagnose, but enough trials should push that chance into oblivion
- psyc 10y agoThis is a good example of something that is virtually guaranteed, but I will still never, ever make it a condition for exiting unceremoniously, or worse, the condition for terminating a loop.
- JoachimSchipper 10y agoFor a true random number generator, that's simply a matter of tuning the probability of random failure to be acceptable; e.g. the old FIPS 140-2 randomness tests were calibrated to spuriously fail with probability of (IIRC) about one in a million. There are problems with testing a random source, but calibration can solve that one. (The bigger issue is that the "true" random going into your (PRNG) postprocessor should be whatever comes out of your best entropy-generating device, which typically isn't uniformly random; and that the data coming out of your postprocessor will look random to a black-box test even if the input contains basically no entropy.)