public void TestDistanceDecrease2() { var dimension = 5; var entropySketch = new EntropySketchFunction(dimension); var befVector = ArrayUtils.Init(-1.0, -2.0, -3.0, -4.0, -5.0).ToVector(); var afVector = ArrayUtils.Init(-0.5, -2.0, -3.0, -4.0, -5.0).ToVector(); var befEntropySketchValue = entropySketch.ComputeEntropySketch(befVector); var afEntropySketchValue = entropySketch.ComputeEntropySketch(afVector); var distL1 = (afVector - befVector).L1Norm(); var distance = DecreaseEntropySketch.l1DecreaseEntropySketchTo(befVector, dimension, afEntropySketchValue, Approximations.ApproximationEpsilon); var resultMSE = Math.Pow(distance - distL1, 2); Assert.AreEqual(resultMSE, 0.0, 0.00001); }
public ConvexBound LowerBound(Vector reducedVector, double threshold) { Either <Vector, double> DistanceL1(Vector point, int node) { var functionValue = ComputeEntropySketch(point); if (functionValue > threshold) { return(DecreaseEntropySketch.l1DecreaseEntropySketchTo(point, Dimension, threshold, Approximations.ApproximationEpsilon)); } if (functionValue < threshold) { return(IncreaseEntropySketch.l1IncreaseEntropySketchTo(point, Dimension, threshold, Approximations.ApproximationEpsilon)); } return(point); } return(ConvexBoundBuilder.Create(MonitoredFunction.Function, ComputeEntropySketch, ConvexBound.Type.LoweBound, threshold) .WithDistanceNorm(1, DistanceL1) .ToConvexBound()); }