Esempio n. 1
0
        public void TestDistanceIncrease2()
        {
            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(-3.0, -3.0, -3.0, -4.0, -5.0).ToVector();
            var befEntropySketchValue = entropySketch.ComputeEntropySketch(befVector);
            var afEntropySketchValue  = entropySketch.ComputeEntropySketch(afVector);
            var closestVector         =
                IncreaseEntropySketch.l1IncreaseEntropySketchTo(befVector, dimension, afEntropySketchValue,
                                                                Approximations.ApproximationEpsilon);
            var resultMSE = closestVector.DistL2FromVector()(afVector);

            Assert.AreEqual(resultMSE, 0.0, 0.00001);
        }
Esempio n. 2
0
        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());
        }