0

I'm making an app that needs to generate deterministic random events. They need to be deterministic so I can compute which events happened when the app was closed. Basically, my events are points scattered along a line and I need a function f(a,b) that tells me the number of points between the locations a and b. I could discretize my line and randomly decide whether there is a point at every location using the location to seed my generator, but that seems like cheating. I would like to know if there is a more elegant way to do this that uses real numbers.

I believe this problem may have some connections with the Poisson distribution.

Nathan Breit
  • 1,661
  • 13
  • 33
  • If a library function is satisfactory, generally one gets "deterministic" (repeatable) behavior by setting the "seed" for the random number generator (RNG). However it seems your requirement is perhaps to be able to tie the "random" sequence to some "time line" of events, in a functional way, so the application can do "post hoc" processing for the interval of time "when the app was closed". – hardmath Oct 27 '13 at 17:27
  • A usable answer will probably hinge on the details of what represents an event, "points between the locations a and b". Your description of using real numbers seems to open a Pandora's Box of rounding errors. – hardmath Oct 27 '13 at 17:30
  • possible duplicate of [How do I sum intervals in a deterministic Poisson Process?](http://stackoverflow.com/questions/19626844/how-do-i-sum-intervals-in-a-deterministic-poisson-process) – Nathan Breit Oct 28 '13 at 03:43

1 Answers1

0

Pseudo-random number generators are deterministic functions, they will produce exactly the same sequence given the same initial seed. If you use a PRNG and record the seed value you should be able to re-use the sequence for post-processing.

Alternatively, make the random sequence part of your output.

pjs
  • 18,696
  • 4
  • 27
  • 56
  • 1
    This doesn't address my question. I want to generate randomly spaced points along a line, not a sequence of random numbers. – Nathan Breit Oct 28 '13 at 02:44
  • Those are actually equivalent problems. For instance, you could accumulate the sum of the random numbers and scale by the desired `interval-length / total`, or you could generate values between zero and the interval length and sort them to get randomly spaced points on the line. Both of these can be trivially reproduced on demand by retaining the seed or writing the values for later use. – pjs Oct 28 '13 at 02:52
  • I see a couple problems with this approach. 1: The events are not scattered "randomly" enough. For example, points will never be more than the fixed constant used by the RNG apart. Like in a poisson distribution, I want my events to occur independently of the time since the last event. 2: I would need to generate all the points since a fixed epoch every time I start my app, and the more time that passes, the longer this takes to do. – Nathan Breit Oct 28 '13 at 03:03