Nonlinear Iterative Partial Least Squares
- firstPC :: Matrix Double -> (Vector Double, Vector Double, Matrix Double)
- firstPCFromScores :: Matrix Double -> Vector Double -> (Vector Double, Vector Double, Matrix Double)
- firstPCFromScoresM :: Monad m => m [Vector Double] -> Vector Double -> m (Vector Double, Vector Double)
- residual :: [Vector Double] -> Vector Double -> Vector Double -> [Vector Double]
Calculate the first principal component of a set of samples.
let (pc,scores,residuals) = firstPC $ fromRows samples
This is calculated by providing a default estimate of the scores to
Calculate the first principal component of a set of samples given a starting estimate of the scores.
The second argument is a starting guess for the score vector. If this is close to the actual score vector, then this will cause the algorthm to converge much faster.
let (pc,scores,residuals) = firstPCFromScores (fromRows samples) scoresGuess
Calculate the first principal component -- calculating the samples fresh on every pass.
This function calculates the exact same results as
firstPCFromScores (minus the residual), but instead of an input
Matrix, it takes a monad action that yields the list of samples,
and it guarantees that the list returned by the action will be
consumed in a single pass. However the action may be demanded many
There is no corresponding
firstPCM that guesses the initial score
vector for you because if you need to use this function instead of
firstPC, then you really should come up with a reasonable
starting point or it will take forever.
|:: [Vector Double]|
|-> Vector Double|
The component (also called the loading)
|-> Vector Double|
|-> [Vector Double]|
The residuals for each sample
Calculate the residuals of a series of samples given a component and score vector.
(p,t) <- firstPCFromScoresM samplesM (randomVector 0 Gaussian numSamples) samples <- samplesM let r = residual samples p t