Accord.Statistics.Kernels.TaylorGaussian.Distance C# (CSharp) Method

Distance() public method

Computes the distance d(x,y) between points x and y.
public Distance ( double x, double y ) : double
x double The first point x.
y double The second point y.
return double
        public double Distance(double[] x, double[] y)
        {
            return linear.Distance(Transform(x), Transform(y));
        }

Usage Example

        public void ExpandDistanceTest()
        {
            for (int i = 1; i <= 3; i++)
            {
                TaylorGaussian kernel = new TaylorGaussian(i);

                kernel.Degree = 64000;

                var x = new double[] { 0.5, 2.0 };
                var y = new double[] { 1.3, -0.2 };

                var phi_x = kernel.Transform(x);
                var phi_y = kernel.Transform(y);

                double d1 = Distance.SquareEuclidean(phi_x, phi_y);
                double d2 = kernel.Distance(x, y);
                double d3 = Accord.Statistics.Tools.Distance(kernel, x, y);

                Assert.AreEqual(d1, d2, 1e-4);
                Assert.AreEqual(d1, d3, 1e-4);
                Assert.IsFalse(double.IsNaN(d1));
                Assert.IsFalse(double.IsNaN(d2));
                Assert.IsFalse(double.IsNaN(d3));
            }
        }