public void Calculate_FileWithDuplicates_ReturnsCorrectKendall() { // Create lists to feed into test IEnumerable <decimal> listA = new List <decimal>(); IEnumerable <decimal> listB = new List <decimal>(); for (int i = 1; i <= 10; i++) { listA = listA.Append(i); listB = listB.Append(11 - i); } // Add some duplicated numbers to the list listA = listA.Append(2); listB = listB.Append(5); listA = listA.Append(7); listB = listB.Append(3); listA = listA.Append(1); listB = listB.Append(11); listA = listA.Append(11); listB = listB.Append(6); // Calculate using CorrelationCalculator Correlations.Calculate("A", listA.ToList(), "B", listB.ToList()); // Use Extreme.Statistics Kendall method to test result against double kendallActual = Stats.KendallTau(listA.ToList(), listB.ToList()); // Check answer Assert.AreEqual(Math.Round(kendallActual, numberOfDpAccuracy), Math.Round((double)Correlations.kendall, numberOfDpAccuracy)); }
public void Calculate_RandomFile_ReturnsCorrectKendall() { // Create random lists to feed into test IEnumerable <decimal> listA = CreateRandomList(numberOfDataPoints); IEnumerable <decimal> listB = CreateRandomList(numberOfDataPoints); // Use Extreme.Statistics Kendall method to test result against double kendallActual = Stats.KendallTau(listA.ToList(), listB.ToList()); // Calculate using CorrelationCalculator Correlations.Calculate("A", listA.ToList(), "B", listB.ToList()); // Check answer Assert.AreEqual(Math.Round(kendallActual, numberOfDpAccuracy), Math.Round((double)Correlations.kendall, numberOfDpAccuracy)); }
public void Calculate_PerfectlyCorrelatedFile_ReturnsCorrectSpearman() { // Create lists to feed into test IEnumerable <decimal> listA = new List <decimal>(); IEnumerable <decimal> listB = new List <decimal>(); for (int i = 1; i <= 10; i++) { listA = listA.Append(i); listB = listB.Append(i); } // Calculate using CorrelationCalculator Correlations.Calculate("A", listA.ToList(), "B", listB.ToList()); // Check answer Assert.AreEqual(1, Math.Round((double)Correlations.spearman, numberOfDpAccuracy)); }
public void Calculate_RandomFile_ReturnsCorrectSpearman() { // Create random lists to feed into test IEnumerable <decimal> listA = CreateRandomList(numberOfDataPoints); IEnumerable <decimal> listB = CreateRandomList(numberOfDataPoints); double[] arrayA = listA.Select(dec => (double)dec).ToArray(); double[] arrayB = listB.Select(dec => (double)dec).ToArray(); // Use Extreme.Statistics RankCorrelation method to test result against double spearmanActual = Stats.RankCorrelation(arrayA, arrayB); // Calculate using CorrelationCalculator Correlations.Calculate("A", listA.ToList(), "B", listB.ToList()); // Check answer Assert.AreEqual(Math.Round(spearmanActual, numberOfDpAccuracy), Math.Round((double)Correlations.spearman, numberOfDpAccuracy)); }