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 } }; Dissimilarities dist = new Dissimilarities(x); dist.Compute(); new PrintMatrix("Distance Matrix").Print(dist.DistanceMatrix); } }
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 0Link to C# source.