TODO: Complete the data-specific numerical results and diagnostics when the original Iris_data.csv is available.
The identity
shows that the likelihood function is a bell-shaped curve in , maximized at the sample mean, with width . Its actual vertical scale also depends on the within-sample sum of squares.
Continue the R script with:
sse <- sum((x - xbar)^2)
loglik <- function(mu) {
  -n/2 * log(2*pi) - 0.5 * (sse + n * (mu - xbar)^2)
}
grid <- seq(3, 6, length.out = 2001L)
ell <- loglik(grid)
png("q2-likelihood.png", width = 900, height = 600)
par(mar = c(4.5, 4.5, 4, 1))
if (max(ell) > log(.Machine$double.xmin)) {
  plot(grid, exp(ell), type = "l", xlab = expression(mu),
       ylab = expression(L(mu)), main = "Likelihood on [3,6]")
} else {
  # Explicitly label a proportional likelihood if the true scale underflows.
  plot(grid, exp(ell - max(ell)), type = "l", xlab = expression(mu),
       ylab = "Likelihood relative to maximum on plotted grid",
       main = "Likelihood on [3,6] (rescaled)")
}
abline(v = xbar, col = "steelblue", lty = 2)
dev.off()
Working first with the log-likelihood avoids premature numerical underflow. The fallback preserves the shape on the requested interval and labels the altered scale. A data-specific plot requires the missing CSV file; no fabricated observation set is used here.
TODO: Complete the data-specific numerical results and diagnostics when the original Iris_data.csv is available.
The estimate requested is the sample mean, . The named electronic file Iris_data.csv is not present in the supplied source archive or this repository, and its measurements are not printed in the paper. Consequently its numerical sample mean cannot be recovered from the paper alone. The familiar built-in iris data must not be silently substituted: the question does not identify those observations as its sample.
The following R code reads the actual file and prints its sample mean. The later code blocks in Question 2 continue this same script and use the resulting x, n and xbar.
dat <- read.csv("Iris_data.csv", check.names = FALSE)
# Recognize common labels, or a single measurement column.
keys <- tolower(gsub("[^[:alnum:]]", "", names(dat)))
j <- which(keys %in% c("sepallength", "sepallengthcm", "x"))
if (length(j) == 0L && ncol(dat) == 1L) j <- 1L
if (length(j) != 1L) {
  stop("Select the sepal-length column explicitly after inspecting names(dat).")
}
x <- dat[[j]]
stopifnot(is.numeric(x), length(x) > 0L, all(is.finite(x)))
n <- length(x)
xbar <- mean(x)
cat("n =", n, " sample mean =", format(xbar, digits = 12), "\n")
This reader assumes a header row and one observation per row. An alternative layout should be identified explicitly rather than dropping measurements or treating an identifier column as a length.
TODO: Complete the data-specific numerical results and diagnostics when the original Iris_data.csv is available.
Estimate the posterior mean by averaging the retained states:
The exact truncated normal distribution reference is
For a posterior well separated from zero, the truncation correction is tiny and the posterior mean is approximately , slightly below the sample mean.
The R continuation prints the Monte Carlo estimator, its approximate batch-based Monte Carlo standard error, and the exact value for comparison:
posterior_mean_mc <- mean(post)
posterior_mean_exact <- m + s * exp(dnorm(m/s, log = TRUE) -
                                    pnorm(m/s, log.p = TRUE))
# Nonoverlapping batches account approximately for serial dependence.
batch_length <- floor(sqrt(length(post)))
number_batches <- floor(length(post)/batch_length)
used <- post[seq_len(batch_length * number_batches)]
batch_averages <- colMeans(matrix(used, nrow = batch_length))
mcse <- sd(batch_averages)/sqrt(number_batches)
cat("Posterior mean, MCMC =", posterior_mean_mc,
    " approximate MCSE =", mcse, "\n")
cat("Posterior mean, exact =", posterior_mean_exact, "\n")
The batch length must be long enough relative to the chain's dependence for this uncertainty estimate to be reliable. No numerical data-specific posterior mean is determined by the supplied paper alone.
Principal component score 2026-10-14
A score is an observation's coordinate along a principal component direction. Center an observation by the fitted sample mean, apply the fitted variable scaling when using principal component analysis on a correlation matrix, then take its inner product with the unit principal component loading vector. New observations must use the training center and scaling. The score variance equals the corresponding eigenvalue when the covariance normalization is consistent.
Q-Q plot 2026-10-13
A Q-Q plot is a scatter plot pairing quantiles at the same probability levels. For a statistical sample of size , sort the observations into order statistics . Choose plotting positions and a reference quantile function , then plot
Here the horizontal coordinate is a reference value, and the vertical coordinate is an observed value; neither axis is the probability . The displayed plotting positions are our chosen convention, placing every level strictly between zero and one. They are not a claim that the th order statistic equals that population quantile. For two statistical samples, use sample quantiles at matching levels, with a stated interpolation convention when their sizes differ. [ref]
As a computed example, take and the standard normal quantiles , where is the standard normal cumulative distribution function. Construct the ordered values . At ranks , the plotting positions are , the reference quantiles are approximately , and the constructed values are approximately . Every point lies on by construction. These 19 values are deliberately chosen, not random draws or real measurements.
Figure 1.
An exact constructed Q-Q line encodes location and scale
. Left: all 19 pairs lie on , with plotting positions . Right: subtracting the specified location 10 and dividing by the specified scale 2 puts the same points on the identity line. These parameters are construction constants, not sample mean and sample standard deviation estimates. The 19 values are deterministic examples, not random draws. Details.
The usefulness of a Q-Q plot is that it turns a comparison of probability distributions into geometry: if a reference random variable is transformed into with , its quantile function satisfies . This follows because a positive scaling preserves ordering. Thus the location-scale family produces a straight population Q-Q plot, and an approximate sample line suggests a compatible shape over the observed range. Its intercept describes location and its slope describes scale. The identity line requires the same location, scale and units on both axes; even then its displayed angle is 45 degrees only with equal axis scales. Curvature is often more informative than a histogram because it shows which quantiles depart from the reference. [ref]
Rao-Blackwell estimator after interim selection Created 2026-10-06 Updated 2026-10-07
For two independent stage means and continuation , let and . The second-stage mean is conditionally unbiased. The Rao-Blackwell theorem gives , using and truncation. This is a conditionally unbiased estimator using both stages through their combined sample mean.
For simple pendulum oscillation period in the small-angle approximation, . If the length measurement and identically precise timing measurements have independent errors, the timing sample mean has standard error . Propagation of uncertainty gives the title formula. A target fractional standard uncertainty requires , rounded upward to an integer. No amount of repeated timing can beat the floor without improving the length measurement; correlated errors or a timing systematic error require a different model.
Ridge regression Created 2026-09-24 Updated 2026-10-14
Ridge regression fits a linear regression model while penalizing the size of its slope regression coefficients. For a fixed design matrix containing the slope predictors, observed responses , and an unpenalized regression intercept , the objective is
Here is the all-ones vector, and is the squared Euclidean norm of the slopes alone. The first term is the residual sum of squares; the second implements regularization. No random-error assumption is needed to define this fit. The convention is a summed squared-error loss: writing the objective as gives the same fit when .[ref]
For an exact example, reuse the constructed pairs from linear regression. Their sample means are and , and the centered cross-products are and . Thus
The ordinary least squares line has slope and residual sum of squares . At , ridge regression has slope , regression intercept , and residual sum of squares ; at these become , , and . Every line passes through : the penalty reduces the slope while retaining the response sample mean.
Figure 1.
Exact synthetic ridge fits flatten around the sample mean as training RSS increases
. Details.
The computational benefit is visible after predictor centering. Write for the design matrix with each column's sample mean subtracted, and . The unpenalized intercept in ridge regression gives , and the closed-form ridge regression estimator solves
For any nonzero vector and , . This positive-definite matrix is therefore invertible even when lacks full column rank, including repeated columns or . The unique penalized slopes resolve the ambiguity of rank-deficient ordinary least squares; they do not supply evidence about slope directions absent from the data. This makes ridge regression useful for multicollinearity.[ref]
Predictor centering and scaling serve different purposes. Centering handles the free regression intercept. Scaling determines what counts as a large slope: replacing by changes its coefficient to for the same predictions, changing its contribution to an unweighted penalty. A common convention forms standard scores using each nonconstant predictor's sample standard deviation , then penalizes slopes in those coordinates. Since , this is the weighted penalty in the original units. Constant columns have and must be removed before this scaling. Scaling is a modelling choice; equal penalties in original units and in standardized units define different fits.[ref]
The singular value decomposition explains the shrinkage. If is the compact decomposition using the positive singular values , with columns of , then
The principal-component shrinkage by ridge regression factors are between and : directions with small singular values are damped most. As , the fitted values approach ; the vanishing-penalty ridge limit recovers the ordinary least squares fitted vector as , even if the slope estimates at zero penalty are nonunique. The covariance and bias of a ridge regression estimator describes the resulting bias-variance tradeoff. A penalty can reduce variance of an estimator while introducing bias of an estimator; the unbounded directional risk of fixed ridge shrinkage rules out a uniform improvement for a fixed positive penalty over all possible signals.[ref]
For a second exact construction, choose a centered orthonormal set of three vectors,
and set and . The squared singular values are and . At , the fitted coordinates along are , retaining and of their ordinary least squares values . At they become , retaining and . The unfittable component contributes to every residual sum of squares, giving total values , , and at penalties . These are constructed fits, not measured prediction results.
Figure 2.
Exact synthetic ridge shrinkage retains the strong singular direction longer than the weak one
. Details.
The penalty is a hyperparameter, so fitting slopes at a fixed value and selecting that value are separate tasks. Use a validation set or K-fold cross-validation to compare candidate penalties by held-out squared-error loss. In each split, compute predictor sample means and scales from that split's training data, apply the same transformation to its validation set, and refit the slopes; using held-out information in preprocessing introduces data leakage. Minimum training residual sum of squares cannot select useful shrinkage: ordinary least squares already attains the smallest possible value.[ref] After model selection, refit on all training data with the selected penalty. A separate test set or nested cross-validation assesses the entire selection procedure; a low selected validation score alone is no performance guarantee.[ref]
For a regular two-parameter exponential family, condition on the sample mean of the nuisance canonical statistic. Exponential tilting to its observed value and the saddlepoint density approximation give a nuisance-statistic density proportional to times its large-deviation exponential. Dividing the joint likelihood by this density gives the profile log-likelihood plus the displayed adjustment, up to a data-only constant. The sign is positive. This construction assumes an interior saddle with positive curvature and a sufficiently regular nonlattice density; conditioning on a lattice statistic requires the corresponding mass approximation.
For independent unit-scale Laplace distributions, the cumulant-generating function is for . The saddlepoint density approximation solves , giving . At this tilt, and , giving the displayed probability density function approximation for the sample mean. Its value at zero is ; it need not integrate to one before normalization.
Sample correlation coefficient Created 2026-10-06 Updated 2026-10-14
For paired observations , the sample correlation coefficient is
It is the normalized inner product of the centered data vectors, or the sample covariance divided by the product of the corresponding sample standard deviations. The choice of divisor or cancels when used consistently in all three quantities. It is undefined if either centered data vector is zero, which occurs when that variable is constant in the observed statistical sample.
For and , both sample means are . The sum of centered products is , and each sum of centered squares is , hence the sample correlation coefficient is . This is a summary of these four observed pairs; it is not automatically the population Pearson correlation coefficient. Philip Stark, Computing the correlation coefficient explains the centered and standardized calculation.
For independent and identically distributed Bernoulli random variables with success probability , the sum has a binomial distribution. Every length- pattern with successes has probability , and the binomial coefficient counts its possible success positions. Therefore
The usual endpoint convention includes and as deterministic cases. For and , the five probability masses are divided by . The sample mean takes values , with variance and standard deviation . At , its variance is and its standard deviation is .
Figure 1.
Exact sample-mean distributions distinguish fresh IID draws from a copied common coin
. Original exact binomial distribution probabilities for sample sizes . Blue marks give the mass at each possible mean under independent fair draws. Orange marks give the masses for the same fair draw copied times: at zero and at one for every . These are discrete probability masses, not density values or measured histograms. Details.
For the normal sample sum with known variance, assume independent and identically distributed with fixed known variance . The joint probability density factors as
The Fisher-Neyman factorization theorem proves that the sum, and hence the sample mean, is a sufficient statistic for . Its remaining deviations have a joint Gaussian law independent of and are independent of . If both and are unknown, the sample mean alone loses information about variance; the pair is sufficient for the full statistical parameter.
A discrete counterexample shows why a sample mean is not automatically sufficient for arbitrary statistical models. Let be independent and identically distributed on with
Each observation has mean one. The arrangements all give sample mean one, yet
This conditional probability is at and at . The conditional distribution therefore still depends on the unknown statistical parameter: this sample mean is not a sufficient statistic. The useful reduction depends on the family of full-data laws, even when its mean stays fixed.
Fix real population values . Define the finite population mean and two normalizations of the finite population variance by
The values are fixed; only the selected subset is random. For its sample mean , the exact design expectation and variance are
The sample mean is an unbiased estimator of the finite population mean. At , every unit is observed and exactly, so the variance is zero. The case is deterministic and is handled directly, since is undefined then.[ref]
The finite population correction depends on the baseline. With the normalization it is multiplying . With the normalization it is multiplying , the exact variance for independent uniform sampling with replacement. The standard error uses the square root of the relevant variance factor. Mixing the two normalizations gives a wrong answer even at , when replacement cannot matter. For the six-value example, , , and , reproducing without replacement and with replacement.
A short proof exposes the statistical dependence. Let be the value at position in uniform sequential sampling without replacement, so each has expected value and variance . Write . Every ordered pair of distinct labels is equally likely, and , hence for ,
Linearity of expectation proves unbiasedness without requiring independence. The variance of a sum includes all ordered covariance terms, giving
For the original population, each pair of distinct draw positions has covariance . Drawing a high value leaves a lower mean among the remaining values, balancing subsequent draws. Equal marginal probability distributions therefore coexist with negative covariance.
When , the sample variance is an unbiased estimator of . To check this independently, use : its expected value is . Thus unbiasedly estimates the variance of the sample mean; its square root estimates the standard error, but need not be unbiased.[ref]
Figure 1.
Exact mean variance and expected distinct-unit coverage as sample size grows in the six-value population
. Details.
The diagram compares variance with the expected fraction of distinct population labels observed. Without replacement this fraction is exactly ; with independent uniform sampling with replacement, a label is missed with probability , so linearity of expectation gives expected fraction . At six draws, replacement covers only about of labels on average and retains sample mean variance ; sampling all six distinct labels covers the population completely and removes selection uncertainty. This population coverage is distinct from confidence interval coverage probability.
The correction matters when the sampling fraction is appreciable. It calibrates uncertainty about this fixed population under the specified selection mechanism. It does not correct unequal selection weights, missing observations or measurement errors; observing every label also does not eliminate uncertainty about a larger unobserved population. Moreover, an exact variance alone does not guarantee the coverage probability of a proposed confidence interval: a small discrete sampling distribution can make a normal approximation inaccurate.
Sample median Created 2026-09-28 Updated 2026-10-14
The sample median is a central value of an ordered statistical sample. The usual numerical convention selects the middle order statistic for odd sample size and the arithmetic mean of the two central order statistics for even sample size:
NIST uses this convention. [ref]. For , the sample median is ; for , it is , which need not be an observed value.
More generally, every value between the two central order statistics in an even statistical sample is a median of its empirical distribution function. The generalized-inverse sample quantile at selects the lower central order statistic in that case, so it can differ from the midpoint convention. Ties are allowed in all these definitions.
The sample median measures the center using sorted positions. Changing the largest observation from to in the five-value example leaves the sample median at , while the sample mean rises from to . Its sampling distribution still depends on the population probability distribution: the mean found for five observations from a uniform distribution is a special calculation, and a sample median's expected value need not equal the population median in general.
For a concrete counterexample, three independent and identically distributed random variables with rate-one exponential distribution have sample median with expected value , by independent exponential order-statistic spacings. The population median instead solves , giving . Thus even the middle order statistic can have mean different from the population median.
Sampling without replacement Created 2026-10-14 Updated 2026-10-14
Sampling without replacement selects distinct labelled units: after a unit is selected it is unavailable for the remaining draws. Distinct labels can carry equal numerical values, so repeated values do not necessarily imply a repeated unit. The rule alone does not specify selection probabilities; a procedure favoring particular units is still sampling without replacement but need not be simple random sampling.
In uniform sequential sampling without replacement, the next label is chosen uniformly among those remaining. For a population of labels, any ordered sequence of distinct labels has probability . Each size- subset has possible orders, so its probability is . This gives the fixed-size simple random sampling design. Equivalently, take the first labels of a uniformly random permutation. Restricting a uniformly random permutation to a specified label set preserves uniformity; biased modulo mappings should not replace uniform selection.
The draw positions have identical marginal probability distributions, but exhibit statistical dependence. If the first label is , the conditional probability that the second label is is zero, whereas its marginal probability is . Thus these draws are not independent and identically distributed when and . For a marked subset of labels, counting size- subsets with binomial coefficients gives the hypergeometric distribution. The resulting negative covariance explains the finite population correction for both counts and sample means.
Select units with first reading , keep that membership fixed, and measure the same units again. The first reading now has a truncated normal distribution. For a general finite threshold , write for the standard normal density and for the standard normal distribution function. Since ,
The tower property of conditional expectation lets us average the line over the selected group.[ref] At this gives
The average second reading is below the selection threshold even though every selected first reading exceeded it. This is a group expectation; any finite generated group's sample mean fluctuates around it. Selecting again on would define a different group and answer a different question.
The latent variable decomposition makes the apparent drop especially clear. Gaussian conditioning gives and . Thus
The first measurement error has zero unconditional mean, but positive selected mean. The second measurement error stays centered because it is independent of selection on . The persistent signal never changed.
Figure 1.
Selection captures an extreme first error while the persistent signal stays fixed
. Original synthetic repeated measurements, not actual measurements. Left: 40 generated units selected by ; orange trajectories move farther from zero. Right: analytic selected-group expectations decompose the first and second readings into persistent latent variable and measurement error. Black dots give generated group sample means after selecting from 60,000 synthetic units; their small departures from the bar totals reflect sampling variation. All selections use the first reading only. Details.
Shrinking a sample mean with variance proportional to mean squared Created 2026-10-06 Updated 2026-10-14
If independent observations have mean and variance , the scaled sample mean has
For , it improves on the unbiased sample mean precisely when . The optimal scale is and its risk is . At all risks vanish and strict improvement is impossible.
Simple random sampling Created 2026-10-07 Updated 2026-10-14
Here simple random sampling means a random unordered subset of exactly distinct labels from , with every size- subset equally likely. The sample size is fixed in advance, , and sampling without replacement prevents duplicate units. This is SRSWOR; some texts also use "simple random sampling" for independent uniform draws with replacement, which is a different design.[ref]
Every label has inclusion probability , but equal inclusion probabilities alone are insufficient. For example, from six labels choose either or with probability . Each label is included with probability , yet eighteen of the twenty size-three subsets are impossible: this is a two-group cluster sampling design. Unequal probability sampling deliberately changes inclusion probabilities, often to improve precision for a particular estimand, and generally requires an appropriately weighted estimator rather than the plain sample mean.
Consider the original mathematical population with labelled values , and let . The fifteen equiprobable subsets, followed by their sample means, are
Their sample means sum to , giving expected value . Their squared deviations from sum to , giving variance . This is an enumeration over hypothetical selections from six stipulated numbers, not measured survey data.
Figure 1.
All fifteen size-two subsets and all thirty-six ordered replacement outcomes from six labelled values
. Details.
With independent uniform sampling with replacement, the ordered outcomes each have probability . The two orders and are distinct outcomes, and is now possible. Forgetting order does not make the resulting unordered multisets equiprobable: has probability but has probability . The thirty-six sample means still have expected value , but their squared deviations sum to , giving variance . Avoiding duplicate labels improves precision for this fixed population.
For independent -variate multivariate normal observations with unknown mean and unrestricted positive-definite covariance matrix, the centered scatter has rank at most . If it is singular, choose the mean to be the sample mean and shrink the covariance on a null direction of the scatter. The quadratic likelihood term stays fixed while the determinant tends to zero, so the density likelihood tends to infinity. Thus a nonsingular covariance maximum likelihood estimate exists only when the centered scatter is positive definite; for a nonsingular Gaussian population this occurs almost surely exactly when .