Skip to content

How do I model an approval or reaction time that is never negative?

A person's reaction or an approval step takes time that is positive and skewed to the right. The inverse Gaussian is the time a drifting quantity needs to reach a level. The script uses it as the approver's time and checks its mean first.

from nagasim import build as nb
from nagasim.core.distributions import distribution_mean

# Approval time: right-skewed, never below zero. mu is the mean (3 minutes); lambda is the shape,
# and a larger lambda makes the times less spread out.
approval = nb.InverseGaussian(mu=3, lambda_=6)
print("mean approval time:", round(distribution_mean("InverseGaussian", {"mu": 3, "lambda": 6}), 2), "minutes")

m = nb.Model(time_limit=4000, warmup=0)
m.add_resource(name="Approver")
requests = m.create(distribution=nb.Exponential(rate=1 / 5))
requests >> m.process(resource_name="Approver", distribution=approval) >> m.dispose()

results = m.run(replications=10, seed=1)
print(f"approver busy {results.kpi('resource/Approver/Usage % (snapshot)'):.0f}% (3 minutes in 5 is 60%)")

Save it as recipe-decision-delay.py and run it with python. The script seeds itself, so the numbers below are the same on your machine.

mean approval time: 3.0 minutes
approver busy 60% (3 minutes in 5 is 60%)

How it works

  1. InverseGaussian(mu, lambda) is the textbook form: mu is the mean and lambda the shape.
  2. A larger lambda gives less spread around the mean; distribution_mean reads the mean back.
  3. The approver is busy 60% of the time because a 3-minute mean arrives every 5 minutes.

Elements used

Back to all recipes.