KarhunenLoeveDecomposition[{a1,a2,…}]
gives the Karhunen–Loeve transform {{b1,b2,…},m} of the numerical arrays {a1,a2,…}, where m.aibi.
KarhunenLoeveDecomposition[{b1,b2,…},m]
uses the inverse of the matrix m for transforming bi to ai.
KarhunenLoeveDecomposition
KarhunenLoeveDecomposition[{a1,a2,…}]
gives the Karhunen–Loeve transform {{b1,b2,…},m} of the numerical arrays {a1,a2,…}, where m.aibi.
KarhunenLoeveDecomposition[{b1,b2,…},m]
uses the inverse of the matrix m for transforming bi to ai.
Details and Options
- Karhunen–Loeve decomposition is typically used to reduce the dimensionality of data and capture the most important variation in the first few components.
- The ai can be arbitrary rank arrays or images of the same dimensions.
- The inner product of m and {a1,a2,…} gives {b1,b2,…}.
- In KarhunenLoeveDecomposition[{a1,…}], rows of the transformation matrix m are the eigenvectors of the covariance matrix formed from the arrays ai.
- The matrix m is a linear transformation of ai. The transformed arrays bi are uncorrelated, are given in order of decreasing variance, and have the same total variance as ai.
- KarhunenLoeveDecomposition[{b1,b2,…},m] effectively computes the inverse Karhunen–Loeve transformation. If the length of {b1,b2,…} is less than the size of m, missing components are assumed to be zero.
- With an option setting StandardizedTrue, datasets ai are shifted so that their means are zero.
Examples
open all close allBasic Examples (2)
Scope (5)
Principal components of two grayscale images:
KarhunenLoeveDecomposition[ {[image], [image]}]Karhunen–Loeve decomposition of three matrix-valued datasets:
a = {{{7, 3}, {0, 1}}, {{6, 8}, {10, 6}}, {{3, 8}, {3, 1}}};
{b, m} = KarhunenLoeveDecomposition[a]m.a == bPrincipal components of a list of color images:
First@KarhunenLoeveDecomposition[{[image], [image], [image]}]Specify the transformation matrix:
KarhunenLoeveDecomposition[{{0, 0, 1}, {0, 1, 1}}, RotationMatrix[45 Degree]]Use a transformation matrix and lesser datasets:
KarhunenLoeveDecomposition[{{0, 0, 1}}, RotationMatrix[45 Degree]]Options (1)
Applications (3)
Enhance the color contrast of an RGB image:
{b, m} = KarhunenLoeveDecomposition[ColorSeparate@[image]];
ColorCombine[First@KarhunenLoeveDecomposition[ImageAdjust /@ b, m]]//ImageAdjustReconstruct a multichannel image from 1, 2, or 3 components:
{b, m} = KarhunenLoeveDecomposition[ColorSeparate@[image]];
Table[ColorCombine[First@KarhunenLoeveDecomposition[Take[b, i], m]], {i, 3}]Transform a list of pictorial faces:
{b, m} = KarhunenLoeveDecomposition[faces = {[image], [image], [image], [image], [image], [image], [image], [image], [image], [image]}];
ImageAdjust /@ bShow the residual images when using only the first three components:
MapThread[ImageDifference, {faces,
First@KarhunenLoeveDecomposition[b[[ ;; 3]], m]}]Properties & Relations (7)
The Karhunen–Loeve decomposition preserves the total variance:
Variance /@ {{1, 2, 3}, {4, 6, 8}}Variance /@ First@KarhunenLoeveDecomposition[{{1, 2, 3}, {4, 6, 8}}]The Karhunen–Loeve decomposition yields uncorrelated sets:
a = RandomReal[1, {2, 5}];
b = First@KarhunenLoeveDecomposition[a];Covariance[Transpose[b]]//ChopThe Karhunen–Loeve decomposition yields an orthogonal transformation matrix:
a = RandomReal[1, {2, 5}];
m = Last@KarhunenLoeveDecomposition[a];OrthogonalMatrixQ[m]Relation to PrincipalComponents:
KarhunenLoeveDecomposition[ Transpose[{{1, 2}, {2, 3}, {4, 10}}], Standardized -> True ] [[1]] // TransposePrincipalComponents[{{1, 2}, {2, 3}, {4, 10}}] // NA setting Standardized->True is equivalent to subtracting the mean from the input data:
KarhunenLoeveDecomposition[Standardize[#, Mean, 1&] & /@ Transpose[{{1, 2}, {2, 3}, {4, 10}}] ]KarhunenLoeveDecomposition[Transpose[{{1, 2}, {2, 3}, {4, 10}}], Standardized -> True]Normalizing by the square root of the number of datasets better preserves the input dynamics:
KarhunenLoeveDecomposition[{{1, 2, 3, 4}, {1, 2, 3, 4}}] [[1]] / Sqrt[2]KarhunenLoeveDecomposition normally returns images of a real type:
Map[ImageType, {#, First@KarhunenLoeveDecomposition[#]}&@ {[image], [image]}, {2}]Related Guides
Text
Wolfram Research (2010), KarhunenLoeveDecomposition, Wolfram Language function, https://reference.wolfram.com/language/ref/KarhunenLoeveDecomposition.html (updated 2015).
CMS
Wolfram Language. 2010. "KarhunenLoeveDecomposition." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/KarhunenLoeveDecomposition.html.
APA
Wolfram Language. (2010). KarhunenLoeveDecomposition. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/KarhunenLoeveDecomposition.html
BibTeX
@misc{reference.wolfram_2026_karhunenloevedecomposition, author="Wolfram Research", title="{KarhunenLoeveDecomposition}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/KarhunenLoeveDecomposition.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_karhunenloevedecomposition, organization={Wolfram Research}, title={KarhunenLoeveDecomposition}, year={2015}, url={https://reference.wolfram.com/language/ref/KarhunenLoeveDecomposition.html}, note=[Accessed: 12-June-2026]}