Functions & Formulae

Each applied formula has its own function page, with a signature, implementations, and tests.

Arrival process count, gap and arrival-time function

S_n = X_1 + X_2 + ... + X_n; N(t) = max{n : S_n <= t}

Maps an arrival rate, constant or varying with time, to the number of patients or other entities that arrive in a window, the gaps between successive arrivals and the clock time of each arrival. The three descriptions carry the same information: S_n is the time of the nth arrival, X_i the gap before arrival i and N(t) the number of arrivals up to time t, in the notation of the Arrival Process article. The records cover Poisson counts, time-varying rates, sampling of gaps and arrival times in a discrete event simulation, and the single-server queueing result that links the arrival rate to waiting.

  • Poisson probability of n arrivals in a window

    P_n = (lambda * t)^n * exp(-lambda * t) / factorial(n)

    Gives the probability that exactly n arrivals occur in a window of length t when arrivals follow a homogeneous Poisson process with rate lambda. The expected number of arrivals is lambda times t. The function exp is the exponential function and factorial(n) is n!, the product of the whole numbers from 1 to n, with factorial(0) equal to 1.

  • Expected arrivals over a window with two arrival-rate periods

    m = lambda_1 * t_1 + lambda_2 * t_2

    Gives the expected number of arrivals in a non-homogeneous Poisson process whose rate is constant within each of two periods, such as day and night. In general the expected count is the area under the rate curve, the integral of lambda(u) from a to b; for a rate that is constant within periods the integral becomes the sum of rate times length over the periods. The count over the window is then Poisson with mean m, so the Poisson probability formula on this page applies with m in place of lambda times t.

  • Inter-arrival gap sampled by inverse transform

    X = -log(U) / lambda

    Samples the gap to the next arrival in a homogeneous Poisson process by inverting the exponential distribution function. The function log is the natural logarithm. In a discrete event simulation the sampled gap is added to the current arrival time, S_n equal to S_(n-1) plus X, and the next arrival is placed on the event queue.

  • Thinning acceptance probability for time-varying arrivals

    p_keep = lambda_t / lambda_star

    Gives the probability with which a candidate arrival at time t is kept when arrivals with rate lambda(t) are generated by thinning. Candidates are first generated from a homogeneous Poisson process at a constant rate lambda_star that is at least lambda(t) throughout the period, and the kept points form a non-homogeneous Poisson process with rate lambda(t). The method avoids integrating the rate function.

  • Expected wait before service in a single-server queue with Poisson arrivals

    rho = lambda / mu; W_q = rho / (mu - lambda)

    Gives the expected time a patient waits before service starts in a single-server queue with Poisson arrivals at rate lambda and exponential service at rate mu, in steady state with lambda below mu. The utilisation rho is computed first and then used in the wait. As rho approaches 1 the expected wait grows without limit, so a small rise in arrivals near full utilisation produces a large rise in waiting.