Exemple #1
0
        public void TestException()
        {
            var fn = new IdentityLinkFunction();

            double[] x = { 1, 2 };
            fn.Evaluate(x);
        }
        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);
        }
Exemple #3
0
        public void TestEvaluate()
        {
            var fn = new IdentityLinkFunction();

            double[] x = { 2 };
            double   y = fn.Evaluate(x);

            Assert.AreEqual(2, y, AIFH.DefaultPrecision);
        }
Exemple #4
0
        public void IdentityLinkFunctionConstructorTest()
        {
            IdentityLinkFunction target = new IdentityLinkFunction();

            Assert.AreEqual(0, target.A);
            Assert.AreEqual(1, target.B);

            for (int i = 0; i < 10; i++)
            {
                Assert.AreEqual(i, target.Function(i));
                Assert.AreEqual(i, target.Inverse(i));
                Assert.AreEqual(1, target.Derivative(i));
                Assert.AreEqual(1, target.Derivative(i));
            }
        }
Exemple #5
0
        public void IdentityLinkFunctionConstructorTest1()
        {
            double mean                 = 3.14;
            double variance             = 2.91;
            IdentityLinkFunction target = new IdentityLinkFunction(variance, mean);

            Assert.AreEqual(mean, target.A);
            Assert.AreEqual(variance, target.B);

            for (int i = 0; i < 10; i++)
            {
                Assert.AreEqual((i - mean) / variance, target.Function(i), 1e-10);
                Assert.AreEqual(i, target.Inverse((i - mean) / variance), 1e-10);
                Assert.AreEqual(variance, target.Derivative(i));
                Assert.AreEqual(variance, target.Derivative(i));
            }
        }