Accord.Tests.Statistics.EmpiricalHazardDistributionTest.KaplanMeierTest1 C# (CSharp) Méthode

KaplanMeierTest1() private méthode

private KaplanMeierTest1 ( ) : void
Résultat void
        public void KaplanMeierTest1()
        {
            // Example from
            // http://sas-and-r.blogspot.fr/2010/05/example-738-kaplan-meier-survival.html

            double[] times;
            SurvivalOutcome[] censor;
            CreateExample1(out times, out censor);

            var distribution = new EmpiricalHazardDistribution(SurvivalEstimator.KaplanMeier);

            Assert.AreEqual(SurvivalEstimator.KaplanMeier, distribution.Estimator);

            distribution.Fit(times, new EmpiricalHazardOptions(HazardEstimator.KaplanMeier, censor));

            int[] t = { 1, 2, 3, 4, 6, 8, 9, 12, 14, 20 };
            double[] e = { 0.889, 0.833, 0.774, 0.714, 0.649, 0.577, 0.505, 0.421, 0.337, 0.168 };

            double[] actual = t.ToDouble().Apply(distribution.ComplementaryDistributionFunction);

            for (int i = 0; i < e.Length; i++)
                Assert.AreEqual(e[i], actual[i], 1e-3);

            // Assert.AreEqual(11.177, distribution.Mean);
            Assert.AreEqual(12, distribution.Median, 1e-5);
        }