public void Test() { var distanceCalculator = new DistributionDistanceCalculator(); Assert.That( distanceCalculator.CalculateDistance( new Distribution<string>(new Bag<string> {{"1", 1}, {"2", 1}, {"3", 1}}), new Distribution<string>(new Bag<string> { { "A", 1 }, { "B", 1 }, { "C", 1 } })), Is.EqualTo(1.0).Within(0.000000000000001)); Assert.That( distanceCalculator.CalculateDistance( new Distribution<string>(new Bag<string> { { "1", 1 }, { "2", 1 }, { "3", 1 } }), new Distribution<string>(new Bag<string> { { "1", 1 }, { "2", 1 }, { "3", 1 } })), Is.EqualTo(0.0)); Assert.That( distanceCalculator.CalculateDistance( new Distribution<string>(new Bag<string> {{"1", 1}, {"2", 2}}), new Distribution<string>(new Bag<string> {{"2", 3}, {"4", 5}})), Is.EqualTo(0.625).Within(0.000000000000001)); Assert.That( distanceCalculator.CalculateDistance( new Distribution<string>(new Bag<string> { { "1", 1 }, { "2", 5 }, { "3", 2 } }), new Distribution<string>(new Bag<string> { { "1", 1 }, { "2", 5 }, { "4", 2 } })), Is.EqualTo(0.25).Within(0.000000000000001)); }
public void Test() { var distanceCalculator = new DistributionDistanceCalculator(); Assert.Equal( 1.0, distanceCalculator.CalculateDistance( new Distribution <string>(new Bag <string> { { "1", 1 }, { "2", 1 }, { "3", 1 } }), new Distribution <string>(new Bag <string> { { "A", 1 }, { "B", 1 }, { "C", 1 } }))); Assert.Equal( 0.0, distanceCalculator.CalculateDistance( new Distribution <string>(new Bag <string> { { "1", 1 }, { "2", 1 }, { "3", 1 } }), new Distribution <string>(new Bag <string> { { "1", 1 }, { "2", 1 }, { "3", 1 } }))); Assert.Equal( 0.625, distanceCalculator.CalculateDistance( new Distribution <string>(new Bag <string> { { "1", 1 }, { "2", 2 } }), new Distribution <string>(new Bag <string> { { "2", 3 }, { "4", 5 } }))); Assert.Equal( 0.25, distanceCalculator.CalculateDistance( new Distribution <string>(new Bag <string> { { "1", 1 }, { "2", 5 }, { "3", 2 } }), new Distribution <string>(new Bag <string> { { "1", 1 }, { "2", 5 }, { "4", 2 } }))); }
public void Test() { var distanceCalculator = new DistributionDistanceCalculator(); Assert.That( distanceCalculator.CalculateDistance( new Distribution <string>(new Bag <string> { { "1", 1 }, { "2", 1 }, { "3", 1 } }), new Distribution <string>(new Bag <string> { { "A", 1 }, { "B", 1 }, { "C", 1 } })), Is.EqualTo(1.0).Within(0.000000000000001)); Assert.That( distanceCalculator.CalculateDistance( new Distribution <string>(new Bag <string> { { "1", 1 }, { "2", 1 }, { "3", 1 } }), new Distribution <string>(new Bag <string> { { "1", 1 }, { "2", 1 }, { "3", 1 } })), Is.EqualTo(0.0)); Assert.That( distanceCalculator.CalculateDistance( new Distribution <string>(new Bag <string> { { "1", 1 }, { "2", 2 } }), new Distribution <string>(new Bag <string> { { "2", 3 }, { "4", 5 } })), Is.EqualTo(0.625).Within(0.000000000000001)); Assert.That( distanceCalculator.CalculateDistance( new Distribution <string>(new Bag <string> { { "1", 1 }, { "2", 5 }, { "3", 2 } }), new Distribution <string>(new Bag <string> { { "1", 1 }, { "2", 5 }, { "4", 2 } })), Is.EqualTo(0.25).Within(0.000000000000001)); }