Example: Dissimilarities

The following example illustrates the use of Dissimilarities for computing the Euclidean distance between the rows of a matrix:

using System;
using Imsl.Math;
using Imsl.Stat;

public class DissimilaritiesEx1
{
	public static void  Main(String[] args)
	{
		double[,] x = {{1.0, 1.0}, {1.0, 0.0}, {1.0, - 1.0}, {1.0, 2.0}};
		int distanceMethod = 0;
		int distanceScale = 0;
		int iRow = 1;
		Dissimilarities dist = new Dissimilarities(x, distanceMethod,
         distanceScale, iRow);
                new PrintMatrix("Distance Matrix").Print(dist.DistanceMatrix);
	}
}

Output

Distance Matrix
   0  1  2  3  
0  0  1  2  1  
1  0  0  1  2  
2  0  0  0  3  
3  0  0  0  0  


Link to C# source.