Version 0.62.1

pca::pca

Performs principal component analysis (PCA) on a set of 3D points.

Signatures

  •   void pca( vector& vecA[], vector& pc1, vector& pc2, vector& pc3 )

Details

The function computes the principal components of a given set of 3D points. It returns three orthogonal vectors representing the directions of maximum variance in the data. These vectors are the principal components, ordered by the amount of variance they explain, with pc1 being the direction of the greatest variance.

Example

 #import( "std/pca.sps" )

 vector points[] = [ <[1,2,3]>, <[4,5,6]>, <[7,8,9]> ]
 vector pc1, pc2, pc3
 pca::pca( points, pc1, pc2, pc3 )
 echo( "Principal Component 1: " + pc1 )
 echo( "Principal Component 2: " + pc2 )
 echo( "Principal Component 3: " + pc3 )

 

Return value

This function does not return a value. The principal components are returned through the output parameters pc1, pc2, and pc3.

Parameters

vecA

An array of vectors representing the set of 3D points to be analyzed.

pc1

A reference to a vector that will store the first principal component, which corresponds to the direction of maximum variance.

pc2

A reference to a vector that will store the second principal component, orthogonal to pc1.

pc3

A reference to a vector that will store the third principal component, orthogonal to both pc1 and pc2.

See also

🗙

Search results for