Skip to content

How do I model repair times with a long tail?

Repair and lifetime data often have a heavier tail than a lognormal. LogLogistic and the two Pearson types cover that. The script sets each to a 3-minute mean and runs the same bay.

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


def wait_with(repair):
    m = nb.Model(time_limit=2000, warmup=0)
    m.add_resource(name="Bay")
    m.create(distribution=nb.Exponential(rate=1 / 5)) >> m.process(
        resource_name="Bay", distribution=repair) >> m.dispose()
    return m.run(replications=10, seed=1).kpi("resource/Bay/Time in Queue Avg")


# Three right-skewed families, each set to a 3-minute mean. They differ in how long the tail is.
candidates = {
    "LogLogistic":   {"c": 4, "scale": 2.7},
    "PearsonTypeV":  {"a": 5, "scale": 12},
    "PearsonTypeVI": {"a": 3, "b": 8, "scale": 7},
}
for name, params in candidates.items():
    mean = distribution_mean(name, params)
    print(f"{name:<14} mean {mean:.2f}  mean wait {wait_with(nb.Distribution(name, params)):.2f} minutes")

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

LogLogistic    mean 3.00  mean wait 2.72 minutes
PearsonTypeV   mean 3.00  mean wait 2.81 minutes
PearsonTypeVI  mean 3.00  mean wait 3.54 minutes

How it works

  1. LogLogistic(c, scale), PearsonTypeV(a, scale) and PearsonTypeVI(a, b, scale) are right-skewed and never negative.
  2. distribution_mean returns the mean of each, so you can set the parameters to a mean you know before you compare tails.
  3. At the same mean the Pearson VI queue waits longest here, which shows why you should not pick a family by its mean alone.

Elements used

Back to all recipes.