Accord.Statistics.Links.CauchitLinkFunction.Derivative2 C# (CSharp) Method

Derivative2() public method

First derivative of the mean function expressed in terms of it's output.
The first derivative of the Cauchit link function in terms of y = f(x) is given by f'(y) = B / (tan((y - A) / B)² + 1)
public Derivative2 ( double y ) : double
y double The reverse transformed value.
return double
        public double Derivative2(double y)
        {
            double x = Math.Tan((y - A) / B);
            return B / (x * x + 1);
        }

Usage Example

Exemplo n.º 1
0
        public void DerivativeTest()
        {
            double[] expected =
            {
                0.31831, 0.315158, 0.306067, 0.292027, 0.274405, 0.254648,
                0.234051, 0.213631, 0.194091, 0.175862, 0.159155
            };

            CauchitLinkFunction target = new CauchitLinkFunction();

            for (int i = 0; i < 11; i++)
            {
                double x = i / 10.0;
                double y = target.Inverse(x);

                double d1 = target.Derivative(x);
                double d2 = target.Derivative2(y);

                Assert.AreEqual(expected[i], d1, 1e-6);
                Assert.AreEqual(expected[i], d2, 1e-6);

                Assert.IsFalse(Double.IsNaN(d1));
                Assert.IsFalse(Double.IsNaN(d2));
            }
        }