public void ProbitLinkFunctionConstructorTest()
        {
            ProbitLinkFunction target = new ProbitLinkFunction();

            double[] expected =
            {
                Double.NegativeInfinity, -1.28155, -0.841621, -0.524401, -0.253347,
                0,                       0.253347,  0.524401,  0.841621,   1.28155, Double.PositiveInfinity
            };

            for (int i = 0; i < 11; i++)
            {
                double x = i / 10.0;
                double y = expected[i];

                double fx = target.Function(x);
                double iy = target.Inverse(y);

                Assert.AreEqual(y, fx, 1e-5);
                Assert.AreEqual(x, iy, 1e-5);

                Assert.IsFalse(Double.IsNaN(fx));
                Assert.IsFalse(Double.IsNaN(iy));
            }
        }
        public void DerivativeTest()
        {
            ProbitLinkFunction target = new ProbitLinkFunction();

            double[] expected =
            {
                0.398942, 0.396953, 0.391043, 0.381388, 0.36827, 0.352065,
                0.333225, 0.312254, 0.289692, 0.266085, 0.241971
            };

            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));
            }
        }
        public static ILinkFunction Get(LinkFunctionType link)
        {
            ILinkFunction result = null;

            switch (link)
            {
            case LinkFunctionType.Absolute: result = new AbsoluteLinkFunction(); break;

            case LinkFunctionType.Cauchit: result = new CauchitLinkFunction(); break;

            case LinkFunctionType.Identity: result = new IdentityLinkFunction(); break;

            case LinkFunctionType.Inverse: result = new InverseLinkFunction(); break;

            case LinkFunctionType.InverseSquared: result = new InverseSquaredLinkFunction(); break;

            case LinkFunctionType.Logit: result = new LogitLinkFunction(); break;

            case LinkFunctionType.Log: result = new LogLinkFunction(); break;

            case LinkFunctionType.LogLog: result = new LogLogLinkFunction(); break;

            case LinkFunctionType.Probit: result = new ProbitLinkFunction(); break;

            case LinkFunctionType.Sin: result = new SinLinkFunction(); break;

            case LinkFunctionType.Threshold: result = new ThresholdLinkFunction(); break;
            }

            return(result);
        }