eeesh that title isn’t very good.
Here is the situation.
I have a simulation that runs in real time, I’m trying to efficiently simulate a random count rate that has a known expectation value over a specific delta time and the probability distribution has a known standard deviation, variance etc etc…
I only want an integer number of counts, that is, for consecutive delta times I get results like 2, 1, 0, 3, 1, 2, 0, 1.
Currently I just multiply the number of counts per second by the delta time in seconds and add this to a running counts variable, and for displaying I round it down by casting to int from float. This won’t cut the mustard in the end =(
I’m running ~60 fps and don’t want to kill peoples processors if I can help it.
What would be a good way to accomplish this efficiently (I’m using Java)?
It sounds like an Exponential distribution / Poisson process may be appropriate. An exponential distribution models the time between occurrences of a discrete event. The lambda parameter represents the rate of arrival of events. The Poisson process provides an alternate representation of the same underlying process, giving you the count (integer, from 0 to +inf) of events that happened in a certain timeframe.
The Poisson distribution is fairly easy to simulate. The lambda of Poisson represents the expected number of events in a time interval, and can be simulated that way.
One way to validate whether this is an adequate way to represent/simulate your process is to verify that the mean, variance etc… satisfy what they should be, if it were to follow such a process.