public void ExceptionTest()
{
double[,] data =
{
{ 1, 2 },
{ 5, 2 },
{ 2, 2 },
{ 4, 2 },
};
var pca = new PrincipalComponentAnalysis(data, AnalysisMethod.Standardize);
bool thrown = false;
try { pca.Compute(); }
catch (ArithmeticException ex)
{
ex.ToString();
thrown = true;
}
// Default behavior changed: now an exception is not thrown anymore.
// Instead, a small constant is added when computing standard deviations.
Assert.IsFalse(thrown);
var str1 = pca.SingularValues.ToCSharp();
var str2 = pca.ComponentVectors.ToCSharp();
Assert.IsTrue(pca.SingularValues.IsEqual(new double[] { 1.73205080756888, 0 }, 1e-7));
Assert.IsTrue(pca.ComponentVectors.IsEqual(new double[][] {
new double[] { 1, 0 },
new double[] { 0, -1 }
}, 1e-7));
}