Accord.Statistics.Links.LogLogLinkFunction.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)
        {
            // -(b+1) e^(b x-e^(b x+x)+x)

            double z = B * x + A;
            double w = z - Math.Exp(z);
            return -B * Math.Exp(w);
        }

Usage Example

        public void DerivativeTest2()
        {
            double beta = 2;
            double constant = 0.5;
            LogLogLinkFunction target = new LogLogLinkFunction(beta, constant);

            double[] expected =
            {
               -0.634084, -0.537619, -0.420439, -0.297894, -0.187093, -0.101414,
               -0.0459225, -0.0166933, -0.00464008, -0.000929341, -0.000124732
            };

            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));
            }
        }
All Usage Examples Of Accord.Statistics.Links.LogLogLinkFunction::Derivative