How this calculation works
Classify query observations using Gaussian linear or quadratic discriminant analysis fitted to labeled numeric rows. The tool estimates class means, empirical class priors and covariance matrices, then normalizes Gaussian discriminant scores into posterior model probabilities. LDA uses a shared pooled covariance; QDA uses one covariance per class. The covariance denominators are stated explicitly so results can be compared meaningfully with other software.
score_k=log prior_k−(log det Σ_k+(x−μ_k)ᵀΣ_k⁻¹(x−μ_k))/2; normalize exp scores.A worked example
Classes have observations (−2,−1,0) and (2,3,4), means −1 and 3, and unbiased within-class variance one. Equal priors give equal posterior probabilities at query x=1. LDA shares the pooled covariance, while QDA estimates one covariance for each class.
Good to know
6–200 rows, 1–3 features, 2–4 consecutive class labels. Each class needs more records than features; full-rank positive-definite covariance required. Empirical class priors. Unbiased covariance denominators n_k−1 and n−K are explicit; no automatic regularization, calibration or accuracy estimate.
Aligning features and class labels
Each observation row must use the same feature order and units, with one class label zero through K minus one. Query rows follow that same layout. Every class needs more observations than features and a nonsingular within-class covariance estimate.
Repeated or redundant predictor columns can cause singularity even when row counts are sufficient. The calculator rejects that situation rather than silently adding a covariance ridge. Missing-value imputation and categorical encoding are not performed automatically.
Fits class-conditional Gaussian distributions rather than directly fitting conditional logistic probabilities. The Ordinal logistic regression calculator from ordered categories offers a complementary calculation under its own stated assumptions.
Choosing between LDA and QDA
LDA assumes all classes share one covariance matrix, creating linear pairwise decision boundaries in feature space. QDA permits different covariances and therefore curved boundaries.
That extra flexibility requires more information and can overfit small class samples. A changing class covariance can alter both the distance penalty and the Gaussian normalization term. Choosing QDA solely because it fits the training labels better ignores the additional estimation variability introduced by those extra covariance parameters.
Worked example and mathematical rule
Classes have observations (−2,−1,0) and (2,3,4), means −1 and 3, and unbiased within-class variance one. Equal priors give equal posterior probabilities at query x=1. LDA shares the pooled covariance, while QDA estimates one covariance for each class.
score_k=log prior_k−(log det Σ_k+(x−μ_k)ᵀΣ_k⁻¹(x−μ_k))/2; normalize exp scores.
Covariance conventions affect comparisons
Within each class, this tool divides centered cross-products by class size minus one. LDA pools those matrices with class-size-minus-one weights and divides by total sample size minus the number of classes.
Some libraries use maximum likelihood denominators instead. Identical data can therefore produce slightly different posterior probabilities without a coding error. When reproducing a result, compare covariance conventions, empirical priors and any regularization settings before comparing only the final predicted label.
What posterior probabilities depend on
The score combines a Gaussian distance term, covariance volume and the empirical prior frequency of each class. The resulting probabilities sum to one over the modeled classes.
They are conditional on the Gaussian model and entered sample proportions. If the training sample deliberately balances rare and common classes, those empirical priors may not describe deployment prevalence. A probability is also not evidence that a query resembles the training data: an extreme outlier can still receive a confident normalized class assignment.
Validation beyond fitting the sample
Assess classification on held-out observations, keeping preprocessing and model fitting inside the training portion. Inspect confusion patterns and probability calibration rather than accuracy alone, especially for imbalanced classes.
Gaussian assumptions can be poor for skewed, bounded or multimodal features. A successful covariance inversion verifies numerical feasibility, not distributional suitability. LDA and QDA here are educational statistical classifiers; they do not establish a medical diagnosis, eligibility decision or other high-stakes conclusion.
A useful geometric check
For two classes with equal covariance and equal prior, a point on the appropriate separating boundary should receive equal posterior probabilities. Rescaling a feature and refitting both means and covariances should preserve classifications up to numerical effects.
Switching from LDA to QDA changes the covariance assumption while retaining the same entered labels. Investigate large changes in predicted probabilities through the class spreads and sample sizes, rather than assuming the more confident model must be more accurate.
A few questions, answered
Does LDA fit a logistic regression?
No. It estimates Gaussian class distributions with a shared covariance and applies Bayes normalization.
Why does a covariance matrix become singular?
Too few observations, constant features or linear dependence can make covariance inversion impossible.
Which class priors are used?
The empirical proportions in the entered training observations.
Why do another library’s probabilities differ?
Check covariance denominators, priors, preprocessing and regularization before assuming the implementations disagree.