Accord.Statistics.Links.LogLinkFunction.Derivative C# (CSharp) Method

Derivative() public method

First derivative of the Inverse function.
public Derivative ( double x ) : double
x double The input value.
return double
        public double Derivative(double x)
        {
            return B * Math.Exp(B * x + A);
        }

Usage Example

Ejemplo n.º 1
0
        public void DerivativeTest()
        {
            double beta = 0.52;
            double constant = 2.42;

            double[] expected =
            {
               5.84785, 6.15998, 6.48877, 6.83512, 7.19995, 7.58425, 
               7.98906, 8.41549, 8.86467, 9.33783, 9.83624
            };

            LogLinkFunction target = new LogLinkFunction(beta, constant);

            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-5);
                Assert.AreEqual(expected[i], d2, 1e-5);

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