dstats.pca

This module contains a basic implementation of principal component analysis, based on the NIPALS algorithm. This is fast when you only need the first few components (which is usually the case since PCA's main uses are visualization and dimensionality reduction). However, convergence slows drastically after the first few components have been removed and most of the matrix is just noise.

References:

en.wikipedia.org/wiki/Principal_component_analysis#Computing_principal_components_iteratively

Members

Enums

Transposed
enum Transposed

Used for removeComponent().

Functions

doubleTempdup
double[] doubleTempdup(R range, RegionAllocator alloc)
Undocumented in source. Be warned that the author may not have intended to support it.
firstComponent
PrincipalComponent firstComponent(Ror data, PrinCompOptions opts, PrincipalComponent buf)

Uses expectation-maximization to compute the first principal component of mat. Since there are a lot of options, they are controlled by a PrinCompOptions struct. (See above. PrinCompOptions.init contains the default values.) To have the results returned in a pre-allocated space, pass an explicit value for buf.

firstNComponents
PrincipalComponent[] firstNComponents(Ror data, uint n, PrinCompOptions opts, PrincipalComponent[] buf)

Computes the first N principal components of the matrix. More efficient than calling firstComponent and removeComponent repeatedly because copying and transposing, if enabled, only happen once.

plusMinusAe
bool plusMinusAe(T lhs, U rhs)
Undocumented in source. Be warned that the author may not have intended to support it.
removeComponent
void removeComponent(Ror data, R rotation, Transposed transposed)

Remove the principal component specified by the given rotation vector from data. data must have assignable elements. Transposed controls whether rotation is considered a loading for the transposed matrix or the matrix as-is.

Structs

PrinCompOptions
struct PrinCompOptions

Sets options for principal component analysis. The default options are also the values in PrinCompOptions.init.

PrincipalComponent
struct PrincipalComponent

Result holder

Meta

Authors

David Simcha