0
$\begingroup$

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.

$\endgroup$
8
  • $\begingroup$ If it's a Poisson process, the inter-arrival times are not bounded. Why do you want the next arrival time less than $T$? $\endgroup$ Apr 1, 2016 at 6:49
  • $\begingroup$ I must satisfy arrTime <= T requirement! I can choose any distribution (of course my use case needs to adhere to its assumptions). $\endgroup$ Apr 1, 2016 at 6:55
  • $\begingroup$ If you assume that the event must happen by time $T$ then you must have some sort of non-memoryless process going on, which will create a bias from one moment to the next. One way to define this process is to simply condition on the exponential variable lying in $[0,T]$, that is, to take a random variable with $P(Y \in [a,b])=\frac{P(X \in [a,b] \cap [0,T])}{P(X \in [0,T])}$ and in particular $P(Y \leq y)=\frac{P(X \leq \min \{ y,T \})}{P(X \leq T)}$. This is not exactly the same as your approach, in particular this r.v. is continuous, so $P(Y=T)=0$. $\endgroup$
    – Ian
    Apr 1, 2016 at 17:43
  • $\begingroup$ But it is not necessarily the correct approach, once you drop the memoryless assumption you open up the possibility of other modeling assumptions that lead to other distributions. $\endgroup$
    – Ian
    Apr 1, 2016 at 17:46
  • $\begingroup$ To see how it would arise in simulation, note that (assume $X$ has rate $1$ for simplicity) $P(Y \leq y)=\frac{\int_0^{\min \{ y,T \}} e^{-s} ds}{\int_0^T e^{-s} ds}=\frac{1-e^{-\min \{ y,T \}}}{1-e^{-T}}$. You then need to set that equal to a number $u \in (0,1)$ and solve the equation for $y$ in order to make a simulation. So $y=-\ln(-(-1+(1-e^{-T})u))=-\ln(1-u+e^{-T}u)$. $\endgroup$
    – Ian
    Apr 1, 2016 at 17:52

1 Answer 1

1
$\begingroup$

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):

u = random.random()

K = (1-math.exp(-1))

rval = (-1/rate)*math.log(1-(K*u))


return (rval)

def truncNext(rate):

u = random.uniform(0,(1-math.exp(-1)))

rval = -math.log(1.0-u)/rate

return (rval)

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.