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

Derivative2() public method

First derivative of the Inverse function expressed in terms of it's output.
public Derivative2 ( double y ) : double
y double The reverse transformed value.
return double
        public double Derivative2(double y)
        {
            return Math.Cos((Math.Sin(y) - A) / B) / B;
        }

Usage Example

        public void DerivativeTest()
        {
            double[] expected =
            {
                0.5, 0.497502, 0.490033, 0.477668, 0.46053, 0.438791,
                0.412668, 0.382421, 0.348353, 0.310805, 0.270151
            };

            SinLinkFunction target = new SinLinkFunction();

            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));
            }
        }