Class SimRunlength
THE QUANTITY THAT MATTERS is not the variance of the process but its ASYMPTOTIC VARIANCE sigma^2 = lim t Var(time-average over [0,t]), twice the integral of the autocovariance: a time average of a positively correlated process converges at rate sigma^2/t, not Var(X)/t. Then t* = (z/eps)^2 sigma^2/mean^2 is the run needed for relative precision eps.
For M/M/1, sigma^2 = 2 rho(1+rho)/(mu (1-rho)^4) in closed form. The FOURTH power is the whole story; divided by the squared mean it leaves a run length growing like (1-rho)^-2, so a queue at rho = 0.9 needs about 100 times the run of one at rho = 0.
Port of MATLAB sim_runlength.m, sim_asymvar_mm1.m and sim_asymvar_ctmc.m.
Reference: W. Whitt (1989). Planning queueing simulations. Management Science 35(11), 1341-1366.
- Since:
- LINE 3.1.0
-
Method Summary
Modifier and TypeMethodDescriptionsim_asymvar_ctmc(Matrix A, double[] f) Asymptotic variance of a reward on a CTMC: 2 sum_x pi(x)g(x)d(x) with g = f - E_pi[f] and A d = -g.sim_asymvar_mm1(double lambda, double mu) Asymptotic variance of the M/M/1 number-in-system process.sim_runlength(double mean, double asymVar, double relPrecision, double confidence, double runLength) Run length for a steady-state estimate of a given relative precision.sim_runlength_plan(Matrix means, Matrix ciHalfWidth, double samplesUsed, double relPrecision, double confidence) How long a simulation run should have been, from the one it already did.
-
Method Details
-
sim_asymvar_mm1
Asymptotic variance of the M/M/1 number-in-system process.- Parameters:
lambda- arrival ratemu- service rate- Returns:
- map with mean, variance, asymptoticVariance and relaxationTime
-
sim_asymvar_ctmc
Asymptotic variance of a reward on a CTMC: 2 sum_x pi(x)g(x)d(x) with g = f - E_pi[f] and A d = -g.A d = -g pins d only up to a constant, so one equation of A is redundant and one normalization replaces it. WHICH equation is dropped matters: the rows of A are related by pi A = 0, so a row whose pi is tiny is only nominally redundant, and dropping it loses real information -- on a queue truncated where pi has underflowed, that alone puts sigma^2 out by orders of magnitude. Dropping the row with the LARGEST pi is the well-conditioned choice.
- Parameters:
A- the generator, rows summing to zerof- the reward attached to each state- Returns:
- map with mean, variance and asymptoticVariance
-
sim_runlength
public static Map<String,Double> sim_runlength(double mean, double asymVar, double relPrecision, double confidence, double runLength) Run length for a steady-state estimate of a given relative precision.- Parameters:
mean- the steady-state mean being estimatedasymVar- sigma^2 of that estimatorrelPrecision- the target half-width as a fraction of the meanconfidence- the confidence levelrunLength- an actual run length, or 0 to skip the report- Returns:
- map with requiredRunLength, z and, when runLength is positive, halfWidth and achievedRelPrecision
-
sim_runlength_plan
public static Map<String,Object> sim_runlength_plan(Matrix means, Matrix ciHalfWidth, double samplesUsed, double relPrecision, double confidence) How long a simulation run should have been, from the one it already did.A batch-means half-width H at confidence 1-alpha over a run of N samples pins the ASYMPTOTIC variance of the estimator, sigma^2 = (H/z)^2 N, and that is the quantity a run length is planned from -- NOT the stationary variance, which on M/M/1 differs from it by a factor blowing up like (1-rho)^-2.
sim_runlength(double, double, double, double, double)then turns it into the sample count that reaches a requested RELATIVE precision.An entry with a non-positive mean or half-width is left NaN, since there is nothing to plan from there.
- Parameters:
means- one mean per (station, class)ciHalfWidth- the confidence-interval half-width of the same entriessamplesUsed- the run length those half-widths came fromrelPrecision- the relative precision to plan forconfidence- the level the half-widths were computed at- Returns:
- map with asymptoticVariance and requiredSamples (matrices), and relprecision, confidence and samplesUsed (scalars)
-