Quiz Study Guide — Chapter 2
This deck is a checklist, not a summary. Every slide is phrased as something you should be able to state, derive, or compute without looking it up.
Where this material lives
Chapter 2 of the book. Chapter 2 is the KSL view; Appendix A is the theory behind it and Appendix B is the input-modeling side. The three overlap on purpose.
Random numbers in the KSL
Random variates in the KSL
PDFModelerYou should be able to:
You should be able to:
DEmpiricalRV and MixtureRV are constructedrvariable classes from the mutable Distribution classesPDFModeler scoring models and describe eachBased on L’Ecuyer et al. (2002) — the combination of two multiple recursive generators (MRGs).
| Property | Value |
|---|---|
| Period | \(\approx 3.1 \times 10^{57}\) |
| Number of streams | \(\approx 1.8 \times 10^{19}\) |
| Sub-stream length | \(\approx 7.6 \times 10^{22}\) |
Know these as powers of ten: the quiz asks for the exponent alone (57, 19, 22).
RNStreamProvider instances use the same default underlying seeds, so they produce identical sequences of streams.crnInstance() is a clone; it is not managed by the provider and does not count as one of the provider’s streams.| Method | Effect |
|---|---|
resetStartStream() |
Position at the beginning of the sequence assigned when the stream was created |
resetStartSubstream() |
Position at the start of the current substream |
advanceToNextSubStream() |
Move to the beginning of the next substream |
crnInstance() |
Clone the stream with the same underlying state, for CRN |
antitheticInstance() |
New stream instance configured to produce antithetic variates |
KSLRandom and the ProviderKSLRandom is the convenient single entry point. It wraps a default RNStreamProvider and offers a wide range of random-variate-generation methods.KSLRandom.nextRNStream() calls the underlying default provider to create a new random number stream.Trap
nextRNStream() does not return the next pseudo-random number \(U\), and it does not advance the default stream to its next substream. It makes a new stream.
| Class | Parameters |
|---|---|
NormalRV, LognormalRV |
mean, variance |
TriangularRV |
min, mode, max |
UniformRV |
min, max |
GammaRV |
shape, scale |
BinomialRV |
probability of success, number of trials |
| Class | Description |
|---|---|
BernoulliRV |
0/1 outcomes from a probability of success |
PoissonRV |
Counts of events in an interval given a mean rate |
DUniformRV |
Discrete uniform over an integer range, min to max |
ShiftedGeometricRV |
Trials until the first success — range starts at 1 |
GeometricRV |
Range starts at 0 |
NegativeBinomialRV |
Failures before the \(r\)th success — range starts at 0 |
ConstantRV — a degenerate mass on a single value that cannot be changed after construction.VConstantRV — the same, but the value can be changed after construction.DEmpiricalRV is constructed from an array of values plus an array of cumulative distribution probabilities, with the last element equal to 1.0.MixtureRV’s second argument is likewise an array representing the CDF over the component random variables, last element 1.0.Trap
Both take CDF arrays, not probability-mass arrays.
| Class | What it does |
|---|---|
TruncatedRV |
Restricts a distribution to a sub-interval of its support |
ShiftedRV |
Wraps an RVariable and adds a constant \(\delta\) to each observation |
AcceptanceRejectionRV |
Generates from a target PDF given a proposal distribution and a majorizing constant |
For almost all distributions the KSL generates variates by the inverse transform method, using exact inverses where available and numerical approximations otherwise.
Truncation to \([a,b]\). Generate \(U \sim U(0,1)\), then
\[W = F(a) + \bigl(F(b) - F(a)\bigr)\,U, \qquad X = F^{-1}(W)\]
Shift by \(\delta\). If \(X\) has CDF \(F\) and density \(f\), then \(X + \delta\) has density
\[g(x) = f(x - \delta)\]
Generate \(X\) by any preferred method and add \(\delta\).
The algorithm requires three inputs: the target PDF \(f(x)\), the proposal distribution \(w(x)\), and the majorizing constant \(c\).
Chapter example. \(f(x) = \tfrac34 (1 - x^2)\) on \([-1,1]\) with majorizing function \(g(x) = 3/4\):
\[c = \int_{-1}^{1} \tfrac34\,dx\]
Be able to evaluate that integral and state the resulting acceptance probability.
ksl.utilities.random.rvariable create immutable random variables — their parameters cannot be changed after construction.Distribution classes (e.g. Binomial, Normal) do permit parameter changes, and can create random variables from their current parameter values.value property returns a newly generated random value each time it is accessed.sample() on SampleIfc returns an array of a specified number of generated values.PDFModelerThe four default scoring models for continuous distribution recommendation are BIC, AD, CVM, and QQC.
Two things get asked about them:
| Metric | Description |
|---|---|
| BIC | Log-likelihood with a penalty for the number of parameters; lower is better |
| AD | Anderson-Darling — sensitive to discrepancies in the tails |
| CVM | Cramer-von Mises — distance between theoretical and empirical CDFs |
| KS | Kolmogorov-Smirnov — largest vertical distance between the two CDFs |
| QQC | Pearson correlation of empirical and theoretical quantiles in a Q-Q plot |
| Class or interface | Role |
|---|---|
PDFModeler |
Encapsulates continuous distribution estimation and scoring |
PMFModeler |
Estimates parameters for a set of discrete distributions |
ParameterEstimatorIfc |
Implemented by classes that estimate distribution parameters |
ContinuousCDFGoodnessOfFit |
Computes chi-squared, K-S, AD, and CVM statistics for a continuous CDF |
PDFScoringModel |
Abstract base class for a metric that scores how well a distribution fits |
For chi-squared goodness-of-fit testing the KSL uses equal-probability break points rather than arbitrary histogram bins.
Reason: each interval then has approximately the same expected number of observations, which reduces the test’s sensitivity to the choice of intervals.
Work these by hand. Answers follow at the end of the deck.
KSLRandom.nextRNStream() creates a new stream; it does not return the next \(U\).crnInstance() clone is not one of the provider’s managed streams.resetStartSubstream() returns to the start of the current substream; advanceToNextSubStream() moves to the next one. Do not swap them.NormalRV and LognormalRV take mean and variance, not mean and standard deviation.DEmpiricalRV and MixtureRV take CDF arrays ending at 1.0, not PMF arrays.ConstantRV is the immutable one; VConstantRV is the mutable one.rvariable classes are immutable; the Distribution classes are mutable.