Tutorials › Multivariate Statistics (Graduate) › Finite-Sample Error for Gaussian Discriminant Rules

Discriminant Inference and Risk · Tutorial 608 of 975

Finite-Sample Error for Gaussian Discriminant Rules

Learn to calculate prediction error for a fitted Gaussian discriminant rule and to average it over the sampling uncertainty in its estimated means and covariance matrices.

Advanced 12 min read

What You'll Learn

  • Distinguish conditional predictive error from error averaged over training samples
  • Derive class-specific error probabilities for a fitted binary linear rule
  • Calculate an exact finite-sample error when class means are estimated
  • Evaluate quadratic-rule error using Gaussian probabilities
  • Approximate finite-sample error by repeated training-sample simulation
  • Recognize why evaluating a rule at average parameter estimates is not enough

Prediction Error Depends on the Training Sample

A fitted discriminant rule is random before training data are observed: a different training sample can produce different estimated means, covariance matrices, and classification boundaries. Once a particular training sample is in hand, however, the fitted rule is fixed. Its conditional predictive error is the probability that it misclassifies a new, independent observation. The finite-sample error averaged over training samples is a further average of that conditional probability.

This distinction matters because error for a rule fitted to one sample is not generally the same as error averaged over all possible training samples of the same size. The latter includes the uncertainty in estimating the rule. The calculations below concern prediction for a fresh observation, not the error on the data used to fit the classifier.

Definition: Let \(T\) denote the training sample and let \(\hat g_T(x)\) be the fitted classifier. Under 0–1 loss, its conditional predictive risk is $$ R(T)=P\{\hat g_T(X)\ne Y\mid T\}. $$ The finite-sample expected risk is \(E_T[R(T)]\), where the expectation is over repeated training samples from the specified class-conditional distributions. The test pair \((X,Y)\) is independent of \(T\).

For \(K\) classes with prior probabilities \(\pi_k=P(Y=k)\), let \(P_k\) denote the distribution of a new \(X\) given \(Y=k\). Conditional on \(T\), the rule is fixed, so $$ R(T)=\sum_{k=1}^K \pi_k P_k\{\hat g_T(X)\ne k\}. $$ This formula separates class-specific predictive errors from their prior-weighted total. The priors may be known or estimated; if estimated, their fitted values are part of \(T\).

Exact Predictive Error for a Fitted Linear Boundary

For two classes, write a fitted linear rule as assigning class 1 when \(w^T x+b\geq 0\), where \(w\) and \(b\) are fixed after observing \(T\). Suppose a new observation in class \(k\) has distribution \(N(\mu_k,\Sigma)\), with positive-definite \(\Sigma\). A linear combination of a multivariate normal vector is normal. Thus, conditional on class \(k\), the score has mean \(w^T\mu_k+b\) and variance \(w^T\Sigma w\).

Theorem: If \(w\ne 0\), the class-specific predictive errors of this fitted linear rule are $$ P_1\{\hat g_T(X)=0\} =\Phi\!\left(-\frac{w^T\mu_1+b}{\sqrt{w^T\Sigma w}}\right), \qquad P_0\{\hat g_T(X)=1\} =\Phi\!\left(\frac{w^T\mu_0+b}{\sqrt{w^T\Sigma w}}\right), $$ where \(\Phi\) is the standard normal cumulative distribution function. Therefore $$ R(T)=\pi_1\Phi\!\left(-\frac{w^T\mu_1+b}{\sqrt{w^T\Sigma w}}\right) +\pi_0\Phi\!\left(\frac{w^T\mu_0+b}{\sqrt{w^T\Sigma w}}\right). $$

Proof. Under class 1, \(S=w^TX+b\) is normal with mean \(m_1=w^T\mu_1+b\) and standard deviation \(s=\sqrt{w^T\Sigma w}\). Misclassification occurs when \(S<0\), so its probability is \(\Phi((0-m_1)/s)\). Under class 0, misclassification occurs when \(S\geq0\). If its mean is \(m_0=w^T\mu_0+b\), that probability is \(1-\Phi((0-m_0)/s)=\Phi(m_0/s)\), by symmetry of the standard normal distribution. Weighting these two probabilities by the class priors gives the stated risk. \(\square\)

For fitted LDA, the estimates determine \(w\) and \(b\), while the formula uses the true predictive covariance \(\Sigma\) and means \(\mu_k\). For example, with common fitted covariance \(\hat\Sigma\), known priors, and fitted means \(\hat\mu_k\), the binary LDA score difference has $$ w=\hat\Sigma^{-1}(\hat\mu_1-\hat\mu_0),\qquad b=\log(\pi_1/\pi_0)-\tfrac12(\hat\mu_1+\hat\mu_0)^T w. $$ The normal-tail formula is conditional on those fitted values. If the fitted covariance or means change across training samples, then \(w\) and \(b\) change too, and the finite-sample expected risk averages the resulting conditional risks.

Worked Example: Conditional LDA Error With an Estimated Covariance

Suppose a fitted two-class LDA rule has \(\hat\mu_0=(0.1,-0.1)^T\), \(\hat\mu_1=(0.8,1.2)^T\), and pooled covariance estimate $$ \hat\Sigma=\begin{pmatrix}1&0.2\\0.2&1.5\end{pmatrix}. $$ The class priors are equal. For prediction, suppose the true distributions are \(X\mid Y=0\sim N((0,0)^T,I)\) and \(X\mid Y=1\sim N((1,1)^T,I)\). Calculate the fitted rule's conditional predictive error.

The determinant of \(\hat\Sigma\) is \(1.5-0.04=1.46\), so $$ \hat\Sigma^{-1}=\frac{1}{1.46}\begin{pmatrix}1.5&-0.2\\-0.2&1\end{pmatrix}. $$ Since \(\hat\mu_1-\hat\mu_0=(0.7,1.3)^T\), this gives \(w=(0.5411,0.7945)^T\). The midpoint of the fitted means is \((0.45,0.55)^T\), hence $$ b=-\tfrac12(\hat\mu_1+\hat\mu_0)^Tw =-\tfrac12\{0.45(0.5411)+0.55(0.7945)\} \approx -0.3402. $$

The true predictive covariance is \(I\), so the score standard deviation in either class is $$ s=\sqrt{w^Tw}=\sqrt{0.5411^2+0.7945^2}\approx0.9613. $$ The class-1 score mean is \(w^T(1,1)^T+b\approx0.9954\); the class-0 score mean is \(b\approx-0.3402\). The two class-specific error probabilities are therefore $$ P_1(\text{error})=\Phi(-0.9954/0.9613)\approx\Phi(-1.0355)\approx0.150, $$ $$ P_0(\text{error})=\Phi(-0.3402/0.9613)\approx\Phi(-0.3538)\approx0.362. $$ With equal priors, \(R(T)\approx(0.150+0.362)/2=0.256\). This is the predictive error for the particular fitted rule, not an average over possible training samples.

An Exact Finite-Sample Average in a One-Dimensional LDA Model

An especially useful calculation shows explicitly how uncertainty in estimated means affects prediction. Suppose \(X\mid Y=0\sim N(-a,\sigma^2)\), \(X\mid Y=1\sim N(a,\sigma^2)\), with \(a>0\), equal known priors, and known common variance. Estimate each mean using \(n\) independent training observations from its class. The LDA boundary is the midpoint \(t=(\bar X_0+\bar X_1)/2\); assign class 1 above \(t\).

Theorem: In this model, the finite-sample expected predictive error is $$ E_T[R(T)]=\Phi\!\left(-\frac{a}{\sqrt{\sigma^2+\sigma^2/(2n)}}\right) =\Phi\!\left(-\frac{a/\sigma}{\sqrt{1+1/(2n)}}\right). $$

Derivation. Conditional on \(t\), the error in class 1 is \(\Phi((t-a)/\sigma)\), and the error in class 0 is \(\Phi((-t-a)/\sigma)\). The estimated means are independent, each with variance \(\sigma^2/n\), so \(t\sim N(0,v)\), where \(v=\sigma^2/(2n)\). By symmetry of this distribution, the two errors have the same expectation. To evaluate the first, introduce an independent \(Z\sim N(0,1)\). Conditional on \(t\), \(P\{Z\leq(t-a)/\sigma\}=\Phi((t-a)/\sigma)\). Consequently, $$ E_T\!\left[\Phi\!\left(\frac{t-a}{\sigma}\right)\right] =P\{\sigma Z-t\leq-a\} =\Phi\!\left(\frac{-a}{\sqrt{\sigma^2+v}}\right), $$ because \(\sigma Z-t\) is normal with mean zero and variance \(\sigma^2+v\). This is the expected error for either class, and hence for their equal-prior average as well. \(\square\)

Worked Example: Mean Estimation Adds Finite-Sample Error

In the preceding model, take \(a=1\), \(\sigma=1\), and \(n=4\) observations per class. The boundary has training-sample variance \(1/(2n)=1/8\). Thus $$ E_T[R(T)]=\Phi\!\left(-\frac{1}{\sqrt{1+1/8}}\right) =\Phi(-0.9428)\approx0.173. $$

If the true means were known, the boundary would be zero and the error in either class would be \(\Phi(-1)\approx0.159\). The difference, about \(0.014\), is the increase in expected error here from estimating the means with only four observations per class. It is a model-specific finite-sample calculation, not a general correction that can be applied to every fitted LDA rule.

Quadratic Rules and Numerical Evaluation

With class-specific fitted covariance matrices, QDA compares quadratic discriminant scores. Conditional on the training sample, subtracting one class score from another gives a quadratic function of \(x\). Under a Gaussian test distribution, the score difference is a quadratic form in normal variables; it is generally not normally distributed. Therefore the linear normal-tail formula cannot simply be reused. For two classes, the conditional error is the probability that this quadratic score difference has the wrong sign under each class distribution. Such probabilities can be evaluated using numerical methods for Gaussian quadratic forms or estimated by simulation of fresh test observations.

Worked Example: Exact One-Dimensional QDA Predictive Error

Suppose the fitted, equal-prior QDA model uses class densities \(N(0,1)\) and \(N(2,4)\), and suppose these are also the true predictive distributions. Find its decision regions and error.

Class 1 is selected when its fitted density exceeds the class-0 density. Taking the log density ratio, this condition is $$ -\tfrac12\log 4-\frac{(x-2)^2}{8}+\frac{x^2}{2}>0, $$ or, after multiplying by 8, $$ 3x^2+4x-4-4\log 4>0. $$ The roots are $$ r_-=\frac{-4-\sqrt{64+48\log4}}{6}\approx-2.571,\qquad r_+=\frac{-4+\sqrt{64+48\log4}}{6}\approx1.238. $$ The quadratic opens upward, so class 1 is selected for \(x<r_-\) or \(x>r_+\).

Under class 0, the error probability is $$ \Phi(r_-)+1-\Phi(r_+)\approx\Phi(-2.571)+1-\Phi(1.238)\approx0.113. $$ Under class 1, standardizing with mean 2 and standard deviation 2 gives $$ P_1(r_-<X<r_+) =\Phi((r_+-2)/2)-\Phi((r_--2)/2) \approx\Phi(-0.381)-\Phi(-2.286)\approx0.340. $$ The equal-prior predictive risk is about \((0.113+0.340)/2=0.227\). This is conditional error for the displayed fitted parameters. If those means and variances were estimated, finite-sample expected error would additionally average this conditional risk over their joint training-sample distribution.

Averaging Over Fitted Parameters

For fitted LDA or QDA, the general finite-sample target is \(E_T[R(T)]\). Under a specified Gaussian model, a direct calculation is often available for the conditional risk of a linear rule, as shown above. For QDA, or for a rule with several classes, the required Gaussian-region probabilities may need numerical evaluation. A transparent computational approach is to simulate the training process and evaluate prediction error separately for each simulated fit.

1
Generate a training sample.
Draw the specified number of observations from each class under the assumed Gaussian model.
2
Fit the discriminant rule.
Estimate the means and covariance matrices using the intended fitting procedure, then form the LDA or QDA scores.
3
Evaluate predictive error for that fit.
Use normal-tail or Gaussian-region probabilities when available; otherwise simulate independent test observations from the known class distributions.
4
Average across fits.
Repeat the training-and-evaluation calculation and average the conditional risks. The variation among the fitted risks also describes how much the risk changes across training samples.

For a \(K\)-class rule, the class-\(k\) error is the probability that at least one competing score defeats the class-\(k\) score. These competing events can overlap, so adding pairwise probabilities generally double-counts some errors. Evaluate the probability of the full decision region, or simulate the rule's final class assignment directly.

Common Pitfall

A tempting shortcut is to replace every estimated parameter by its expectation and calculate the risk of that single rule. This does not generally give \(E_T[R(T)]\): the risk is a nonlinear function of the fitted boundary and covariance estimates. The one-dimensional result makes the distinction explicit. Averaging over the random midpoint gives \(\Phi(-a/\sqrt{\sigma^2+\sigma^2/(2n)})\), whereas the known-mean rule has risk \(\Phi(-a/\sigma)\). Treating the random midpoint as its expectation, zero, misses the additional finite-sample error.

The formulas also require a clear separation between the true predictive distribution and the fitted rule. In the conditional LDA calculation, the estimated covariance determines the fitted direction \(w\), but the true covariance determines the distribution of the new observation's score. Substituting the estimated covariance for the true one changes the target unless the calculation explicitly assumes that fitted model is the predictive truth.

Key takeaway: First compute the probability of misclassification for a new observation conditional on the fitted rule. Then average that risk over the sampling distribution of the fitted parameters to account for finite-sample uncertainty. Linear Gaussian scores yield normal-tail probabilities; quadratic scores generally require Gaussian quadratic-form calculations or numerical evaluation.

Check Your Understanding

Answer each question by distinguishing the fitted rule from the process that produced it.

  1. What is the difference between \(R(T)\) and \(E_T[R(T)]\)?
  2. For a fitted binary linear rule, why does the class-specific score have a normal distribution under a Gaussian test model?
  3. In the one-dimensional equal-prior model, how does the variance of the estimated midpoint depend on \(n\)?
  4. Why is a QDA score difference not generally normal, even when the test observation is multivariate normal?
  5. Why can pairwise class-score error probabilities not usually be added to obtain a multiclass error probability?
Clinical Biostats