Functions & Formulae

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

Event time sampling function

s(U,S) = T, where S(T) = U

Maps a uniform random number and a fitted time-to-event distribution to a sampled time to the next event for one simulated patient. The sampled time is the value at which the survival function equals the random number, so repeated draws reproduce the fitted distribution. The simulation clock then advances to the earliest scheduled event.

  • Weibull event time by inverse transform

    T = beta * (-log(U))^(1 / gamma)

    Samples a time to an event from a Weibull distribution with scale beta and shape gamma, whose survival function is S(t) = exp(-(t/beta)^gamma), from a uniform random number U. A shape above 1 gives a rising hazard and a shape below 1 a falling hazard.

  • Little's law check on a simulated queue

    L = lambda * W

    Relates the long-run average number of entities in a stable queueing system to their arrival rate and average time in the system. In a DES with constrained resources it is used as a validation check: the simulated average number in the system should match the arrival rate multiplied by the simulated average time in the system.