I model a phenomenon such that events occur strictly in adherence to Poisson with mean T (no need for two events happening at the same time, events are independent, and all intervals are alike).
Now, based on this, I need to generate "time to next event" - so i take the help of exponential distribution and model inter arrival times, at mean = 1/T. To achieve this, I follow Donald Knuth's algorithm to generate a uniform random number in [0,1) and pick corresponding x value representing next arrival.
This doesn't work for me well as I want my next arrival to be strictly within T (as is, P(X>T) = e^-1). So, I generate a uniform random number within [ 0, (1-(e^-1)) ) = [0,0.632) for example and pick corresponding arrivals and guarantee P(X>T) = 0.
Questions
1. Is there anything wrong with my approach?
2. Is there a more optimal approach to bound inter arrival times? Is there any other distribution that I should go after instead of Poisson/Exponential?
3. What're advantages and disadvantages of stubbing (i.e. I set inter arrival time to T if I get arrTime > T)?
Obviously, 36.8% (e^-1 %) values drawn from this distribution are exactly T, which is not that desirable, as resulting distribution appears less random to an external observer.
Thanks so much - I only started looking into Poisson/Exponential distributions recently so be gentle.
Thanks a lot Ian. After a bit of thought (& simulation, see results below) your method actually normalizes CDF with P(X<=T, lambda=1/T) and has the exact same effect as my original approach. ** So, I'm back to my original questions.** Pls let me know if I should try any other distributions ( Renewal? ) or if this math has no issues given it violates Poisson's memoryless property.
There were slight changes needed on your math, primarily because Exponential "rate" corresponds to Poisson 1/"mean/lambda". Thus, P(Y<=y) = (1-exp(min(y,T))/(1-exp(-((1/T)*T)) = (1-exp(min(y,T))/(1-exp(-1)) (this is exactly same as normalizing otherwise [0,1) to [0,1-exp(-1)).
CODE:
%matplotlib inline
import pandas as pd
import random
import numpy as np
import math
import matplotlib.pyplot as plt
def next(rate):
def truncNext(rate):
n = [next(1/100.0) for x in np.arange(1e6)]
trunc_n = [truncNext(1/100.0) for x in np.arange(1e6)]
f = pd.DataFrame({'cond-Exp': n, 'trunc-Exp': trunc_n})
f.describe()
RESULTS:
result