math::PCA(3tcl)
π NAME π
math::PCA β the Package for Principal Component Analysis, bestie. That's it, that's the name. Short, iconic, does what it says. β¨
πΈ SYNOPSIS πΈ
package require Tcl ?8.6 9?
package require math::linearalgebra 1.1
::math::PCA::createPCA data ?args?
$pca using ?number?|?-minproportion value?
$pca eigenvectors ?option?
$pca eigenvalues ?option?
$pca proportions ?option?
$pca approximate observation
$pca approximatOriginal
$pca scores observation
$pca distance observation
$pca qstatistic observation ?option?
π¦ DESCRIPTION π¦
okay so the PCA package gives you a whole way to do principal components analysis right in Tcl, using an object-oriented technique as facilitated by TclOO. It literally defines just one single public method, ::math::PCA::createPCA, which constructs an object based on the data you hand it, and that object is what actually does the analysis. main character energy fr fr. π
The methods on the PCA objects you get from that command let you peek at the principal components, approximate (new) observations using all of the components or only a selected number of them, and also check out the properties of the components plus the statistics of the approximations. it's giving full control, no cap.
And a lil lore drop: this package has been modelled after the PCA example provided by the original linear algebra package by Ed Hume. respect the ancestors. π«Ά
π COMMANDS π
The math::PCA package provides one public command, and it's the moment:
::math::PCA::createPCAdata?args?β Create a new object, based on the data that are passed via thedataargument. The principal components may be based on either correlations or covariances. All observations will be normalised according to the mean and standard deviation of the original data.data(list) β A list of observations (see the example below).args(list) β A list of key-value pairs defining the options. Currently there is only one key:-covariances. This indicates if covariances are to be used (if the value is1) or instead correlations (value is0). The default is to use correlations.
The PCA object that is created has the following methods:
$pca using?number?|?-minproportion value?β Set the number of components to be used in the analysis (the number of retained components). Returns the number of components, also if no argument is given.number(int) β The number of components to be retained.value(double) β Select the number of components based on the minimum proportion of variation that is retained by them. Should be a value between0and1.
$pca eigenvectors?option?β Return the eigenvectors as a list of lists.option(string) β By default only the retained components are returned. If all eigenvectors are required, use the option-all.
$pca eigenvalues?option?β Return the eigenvalues as a list of lists.option(string) β By default only the eigenvalues of the retained components are returned. If all eigenvalues are required, use the option-all.
$pca proportions?option?β Return the proportions for all components, that is, the amount of variations that each components can explain.$pca approximateobservationβ Return an approximation of the observation based on the retained components.observation(list) β The values for the observation.
$pca approximatOriginalβ Return an approximation of the original data, using the retained components. It is a convenience method that works on the complete set of original data. (yes bestie, that spelling is the real method name, don't come for me π)$pca scoresobservationβ Return the scores per retained component for the given observation.observation(list) β The values for the observation.
$pca distanceobservationβ Return the distance between the given observation and its approximation. (Note: this distance is based on the normalised vectors.)observation(list) β The values for the observation.
$pca qstatisticobservation?option?β Return the Q statistic, basically the square of the distance, for the given observation.observation(list) β The values for the observation.option(string) β If the observation is part of the original data, you may want to use the corrected Q statistic. This is achieved with the option-original.
π EXAMPLE π
TODO: NIST example
not me leaving you a TODO, that's literally what the page says π
π BUGS, IDEAS, FEEDBACK π
This document, and the package it describes, will undoubtedly contain bugs and other problems. lowkey inevitable, highkey fixable. Please report such in the category PCA of the Tcllib Trackers at http://core.tcl.tk/tcllib/reportlist. Please also report any ideas for enhancements you may have for either package and/or documentation β we want the feedback, fr fr. π
When proposing code changes, please provide unified diffs, i.e the output of diff -u.
Note further that attachments are strongly preferred over inlined patches. Attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar. periodt.
π KEYWORDS π
PCA, math, statistics, tcl
π CATEGORY π
Mathematics
and that's the whole page bestie!! this one's from tcllib, version 1.1, and the manual section is 3tcl β so if anyone asks, you know exactly where you are. slay, go do some principal components analysis. πβ¨π¦
π¦ where this page comes from
- debian trixie: tcllib 2.0+dfsg-4 Β· Tcl
- ubuntu questing: tcllib 2.0+dfsg-4
- ubuntu resolute: tcllib 2.0+dfsg-5 Β· Tcl
- ubuntu stonking: tcllib 2.0+dfsg-6 Β· Tcl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms