Main Content


Log unconditional probability density for discriminant analysis classifier



lp = logp(mdl,X) returns the log of the unconditional probability density of each row of the predictor data, computed using the discriminant analysis classifier mdl.


collapse all

Construct a discriminant analysis classifier for Fisher's iris data, and examine its prediction for an average measurement.

Load Fisher's iris data and construct a default discriminant analysis classifier.

load fisheriris
Mdl = fitcdiscr(meas,species);

Find the log probability of the discriminant model applied to an average iris.

logpAverage = logp(Mdl,mean(meas))
logpAverage = -1.7254

Input Arguments

collapse all

Trained discriminant analysis classifier, specified as a ClassificationDiscriminant or CompactClassificationDiscriminant model object trained with fitcdiscr.

Predictor data to classify, specified as a matrix. Each row of the matrix represents an observation, and each column represents a predictor. The number of columns in X must equal the number of predictors in mdl.

Output Arguments

collapse all

Logarithms of unconditional probability densities, specified as a column vector with the same number of rows as X. Each entry is the logarithm of the unconditional probability density of the corresponding row of X.

More About

collapse all

Unconditional Probability Density

The unconditional probability density of a point x of a discriminant analysis model is


where P(k) is the prior probability of class k, P(x|k) is the conditional density of x given class k, and K is the total number of classes. The conditional density function of the multivariate normal with 1-by-d mean μk and d-by-d covariance Σk at a 1-by-d point x is


where |Σk| is the determinant of Σk, and Σk1 is the inverse matrix.

Version History

Introduced in R2011b