Applied vignette · built-in distributions
Plan a response-time service level
Suppose response time in seconds is log-normal with log-scale mean 1.6 and standard deviation 0.45. We will translate that model into operational questions, simulation, and an honest goodness-of-fit check.
1 · State the model
Keep units and parameters explicit
LogNormal(meanlog, sdlog) describes the natural logarithm of response time. The parameters are not the ordinary mean and standard deviation in seconds.
import jdistlib.LogNormal;
LogNormal responseTime = new LogNormal(1.6, 0.45);2 · Ask operational questions
Probability, service target, and percentile
// Fraction expected to finish within 8 seconds.
double withinEight = responseTime.cumulative(8.0, true, false);
// Fraction expected to exceed 10 seconds.
double overTen = responseTime.cumulative(10.0, false, false);
// Response-time target that covers 95% of requests.
double p95 = responseTime.quantile(0.95, true, false);3 · Explore variability
Simulate with a reproducible stream
import jdistlib.rng.MersenneTwister;
MersenneTwister random = new MersenneTwister(20260826L);
double[] scenarios = LogNormal.random(
10_000, 1.6, 0.45, random);
int slow = 0;
for (double seconds : scenarios) {
if (seconds > 10.0) slow++;
}
double simulatedSlowRate = slow / (double) scenarios.length;The simulated rate should be close to the analytical upper-tail probability, but not identical. That sampling variation is the point of the exercise.
4 · Check the model
Compare observations with the full CDF
JDistlib 0.7.0 adds general Anderson–Darling and Cramér–von Mises checks to jdistlib.disttest.DistributionTest. Their default p-values use a deterministic 999-replicate parametric bootstrap.
import jdistlib.disttest.DistributionTest;
double[] observedSeconds = {
3.8, 4.2, 4.7, 5.1, 5.6, 6.0, 6.8, 7.4, 8.5, 9.7
};
double[] ad = DistributionTest.anderson_darling_test(
observedSeconds, responseTime);
double statistic = ad[0];
double bootstrapPValue = ad[1];5 · Interpret, do not automate judgment
A p-value is one diagnostic
A small value is evidence that the fully specified model misses some aspect of the observed distribution. A large value does not prove the model is true, especially with a short sample. Inspect percentiles, tail behavior, data quality, and operational consequences alongside the test.
For categorical counts and tables, the same class now provides chi_square_goodness_of_fit_test and chi_square_independence_test. For two numeric samples, use the seeded two-sample cramer_von_mises_test.
Next
Adapt the pattern
Choose another model from the distribution catalog, revisit the beginner tutorial, or define a domain-specific law in the custom-distribution vignette.