def generateTimeHeadways(meanTimeHeadway, simulationTime):
    """Generates the time headways between arrivals 
    given the meanTimeHeadway and the negative exponential distribution
    over a time interval of length simulationTime (assumed to be in same time unit as headway"""
    from random import expovariate
    headways = []
    totalTime = 0
    flow = 1 / meanTimeHeadway
    while totalTime < simulationTime:
        h = expovariate(flow)
        headways.append(h)
        totalTime += h
    return headways
