Accord.Statistics.Analysis.ProcrustesAnalysis.Compute C# (CSharp) Method

Compute() public method

Compute the Procrustes analysis to extract Procrustes distances and models
public Compute ( ) : ].double[
return ].double[
        public double[,] Compute(params double[][,] samples)
        {
            return Compute(-1, samples);
        }

Same methods

ProcrustesAnalysis::Compute ( int reference_sample_index ) : ].double[
ProcrustesAnalysis::Compute ( ) : void

Usage Example

        public void ProcrustesAnalysisConstructorTest()
        {
            // Define a square
            double[,] square = { { 100, 100 },
                                 { 300, 100 },
                                 { 300, 300 },
                                 { 100, 300 }
                               };
            // Define a diamond with different orientation and scale
            double[,] diamond = { { 170, 120 },
                                  { 220, 170 },
                                  { 270, 120 },
                                  { 220, 70 }
                                };

            // Create the Procrustes analysis object
            ProcrustesAnalysis pa = new ProcrustesAnalysis(square, diamond);

            // Compute the analysis on the square and the diamond
            pa.Compute();

            // Assert that the diamond is a square
            Assert.AreEqual(0.0, pa.ProcrustesDistances[0, 1], 1E-11);

            // Transform the diamond to a square
            double[,] diamond_to_a_square = pa.ProcrustedDatasets[1].Transform(pa.ProcrustedDatasets[0]);

            // Check that the diamond matches (quite) perfectly the square
            for (int i = 0; i < diamond_to_a_square.GetLength(0); i++)
            {
                for (int j = 0; j < diamond_to_a_square.GetLength(1); j++)
                {
                    Assert.AreEqual(diamond_to_a_square[i, j], square[i, j], 1E-11);
                }
            }
        }