/// <summary> /// Calculates the euclidean distance between the Core Point for every given point /// </summary> /// <param name="allPoints">All points you want to know the distance of between the corePoint</param> /// <param name="corePoint">The point you are using to calculate the distances to</param> /// <param name="epsilon">The max amount of range around a point to still be considered to be part of a cluster (be a neighbour)</param> /// <returns></returns> private static DbscanPoint[] RegionQuery(DbscanPoint[] allPoints, DbscanPoint corePoint, double epsilon) { //If the length of Dimensions are not equal to eachother, return an empty array if (allPoints.Count(x => x.Coordinates.Count() != corePoint.Coordinates.Length) != 0) { return(new DbscanPoint[0]); } //Return all points where the euclidean distance is within the epsilon range return(allPoints.Where(point => SimilarityCalculations.CalculateEuclideanDistance(point.Coordinates, corePoint.Coordinates) < epsilon).ToArray()); }
private static void RunCalculationTestMethods() { var dataX = new[] { 5.0, 1.0, 3.0 }; var dataY = new[] { 2.0, 4.0, 3.0 }; var eDis = SimilarityCalculations.CalculateEculeanDistanceCoefficient(dataX, dataY); var mDis = SimilarityCalculations.CalculateManhattanDistanceCoefficient(dataX, dataY); var r = SimilarityCalculations.CalculatePearsonCoefficient(dataX, dataY); //Take into account values that haven't been rated by both users (which I skipped in the previous calculations (here 0.0)) var dataCosX = new[] { 5.0, 0.0, 1.0, 3.0, 5.0 }; var dataCosY = new[] { 2.0, 5.0, 4.0, 3.0, 0.0 }; var cosSim = SimilarityCalculations.CalculateCosineSimilarityCoefficient(dataCosX, dataCosY); }