My colleague, David, had an interesting problem:
“I want to simulate exceptional events (e.g. I/O errors) at predictable rates.
For example, if an error should occur 33% of the time, it should be predictable like: ERROR, ok, ok, ERROR, ok, ok, ...
Or at 50% error rate: ERROR, ok, ERROR, ok, ...
“
devdriven:
“Pseudo-random function
p(t)
in range [0,1)
at time t
and P
is the probability of the event (e.g. I/O error) then: event?(t) = p(t) < P
.
Pseudo-random numbers are predictable if you know the seed."
David:
"Not really what I had in mind. There's got to be a better way..."