当前位置: 首页>>代码示例>>C#>>正文


C# MultivariateNormalDistribution.ComplementaryDistributionFunction方法代码示例

本文整理汇总了C#中Accord.Statistics.Distributions.Multivariate.MultivariateNormalDistribution.ComplementaryDistributionFunction方法的典型用法代码示例。如果您正苦于以下问题:C# MultivariateNormalDistribution.ComplementaryDistributionFunction方法的具体用法?C# MultivariateNormalDistribution.ComplementaryDistributionFunction怎么用?C# MultivariateNormalDistribution.ComplementaryDistributionFunction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Accord.Statistics.Distributions.Multivariate.MultivariateNormalDistribution的用法示例。


在下文中一共展示了MultivariateNormalDistribution.ComplementaryDistributionFunction方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConstructorTest1

        public void ConstructorTest1()
        {

            NormalDistribution normal = new NormalDistribution(4.2, 1.2);
            MultivariateNormalDistribution target = new MultivariateNormalDistribution(new[] { 4.2 }, new[,] { { 1.2 * 1.2 } });

            double[] mean = target.Mean;
            double[] median = target.Median;
            double[] var = target.Variance;
            double[,] cov = target.Covariance;

            double apdf1 = target.ProbabilityDensityFunction(new double[] { 2 });
            double apdf2 = target.ProbabilityDensityFunction(new double[] { 4 });
            double apdf3 = target.ProbabilityDensityFunction(new double[] { 3 });
            double alpdf = target.LogProbabilityDensityFunction(new double[] { 3 });
            double acdf = target.DistributionFunction(new double[] { 3 });
            double accdf = target.ComplementaryDistributionFunction(new double[] { 3 });

            double epdf1 = target.ProbabilityDensityFunction(new double[] { 2 });
            double epdf2 = target.ProbabilityDensityFunction(new double[] { 4 });
            double epdf3 = target.ProbabilityDensityFunction(new double[] { 3 });
            double elpdf = target.LogProbabilityDensityFunction(new double[] { 3 });
            double ecdf = target.DistributionFunction(new double[] { 3 });
            double eccdf = target.ComplementaryDistributionFunction(new double[] { 3 });


            Assert.AreEqual(normal.Mean, target.Mean[0]);
            Assert.AreEqual(normal.Median, target.Median[0]);
            Assert.AreEqual(normal.Variance, target.Variance[0]);
            Assert.AreEqual(normal.Variance, target.Covariance[0, 0]);

            Assert.AreEqual(epdf1, apdf1);
            Assert.AreEqual(epdf2, apdf2);
            Assert.AreEqual(epdf3, apdf3);
            Assert.AreEqual(elpdf, alpdf);
            Assert.AreEqual(ecdf, acdf);
            Assert.AreEqual(eccdf, accdf);
            Assert.AreEqual(1.0 - ecdf, eccdf);
        }
开发者ID:KommuSoft,项目名称:accord_framework,代码行数:39,代码来源:MultivariateNormalDistributionTest.cs

示例2: ConstructorTest4

        public void ConstructorTest4()
        {
            // Create a multivariate Gaussian distribution 
            var dist = new MultivariateNormalDistribution
            (
                // mean vector mu
                mean: new double[] { 4, 2 },

                // covariance matrix sigma
                covariance: new double[,] 
                {
                    { 0.3, 0.1 },
                    { 0.1, 0.7 }
                }
            );

            // Common measures
            double[] mean = dist.Mean;       // { 4, 2 }
            double[] median = dist.Median;   // { 4, 2 }
            double[] mode = dist.Mode;       // { 4, 2 }
            double[,] cov = dist.Covariance; // { { 0.3, 0.1 }, { 0.1, 0.7 } }
            double[] var = dist.Variance;    // { 0.3, 0.7 } (diagonal from cov)
            int dimensions = dist.Dimension; // 2

            // Probability density functions
            double pdf1 = dist.ProbabilityDensityFunction(2, 5);    // 0.000000018917884164743237
            double pdf2 = dist.ProbabilityDensityFunction(4, 2);    // 0.35588127170858852
            double pdf3 = dist.ProbabilityDensityFunction(3, 7);    // 0.000000000036520107734505265
            double lpdf = dist.LogProbabilityDensityFunction(3, 7); // -24.033158110192296

            // Cumulative distribution function (for up to two dimensions)
            double cdf = dist.DistributionFunction(3, 5); // 0.033944035782101534
            double ccdf = dist.ComplementaryDistributionFunction(3, 5); // 0.00016755510356109232


            // compared against R package mnormt: install.packages("mnormt")
            // pmnorm(c(3,5), mean=c(4,2), varcov=matrix(c(0.3,0.1,0.1,0.7), 2,2))


            Assert.AreEqual(4, mean[0]);
            Assert.AreEqual(2, mean[1]);
            Assert.AreEqual(4, mode[0]);
            Assert.AreEqual(2, mode[1]);
            Assert.AreEqual(4, median[0]);
            Assert.AreEqual(2, median[1]);
            Assert.AreEqual(0.3, var[0]);
            Assert.AreEqual(0.7, var[1]);
            Assert.AreEqual(0.3, cov[0, 0]);
            Assert.AreEqual(0.1, cov[0, 1]);
            Assert.AreEqual(0.1, cov[1, 0]);
            Assert.AreEqual(0.7, cov[1, 1]);
            Assert.AreEqual(0.000000018917884164743237, pdf1);
            Assert.AreEqual(0.35588127170858852, pdf2);
            Assert.AreEqual(0.000000000036520107734505265, pdf3);
            Assert.AreEqual(-24.033158110192296, lpdf);
            Assert.AreEqual(0.033944035782101534, cdf);
        }
开发者ID:RLaumeyer,项目名称:framework,代码行数:57,代码来源:MultivariateNormalDistributionTest.cs

示例3: checkDegenerate

        private static void checkDegenerate(MultivariateNormalDistribution target)
        {
            Assert.AreEqual(1, target.Mean[0]);
            Assert.AreEqual(2, target.Mean[1]);
            Assert.AreEqual(0, target.Covariance[0, 0]);
            Assert.AreEqual(0, target.Covariance[0, 1]);
            Assert.AreEqual(0, target.Covariance[1, 0]);
            Assert.AreEqual(0, target.Covariance[1, 1]);


            // Common measures
            double[] mean = target.Mean; // { 1, 2 }
            double[] median = target.Median; // { 4, 2 }
            double[] var = target.Variance; // { 0.0, 0.0 } (diagonal from cov)
            double[,] cov = target.Covariance; // { { 0.0, 0.0 }, { 0.0, 0.0 } }

            // Probability mass functions
            double pdf1 = target.ProbabilityDensityFunction(new double[] { 1, 2 });
            double pdf2 = target.ProbabilityDensityFunction(new double[] { 4, 2 });
            double pdf3 = target.ProbabilityDensityFunction(new double[] { 3, 7 });
            double lpdf = target.LogProbabilityDensityFunction(new double[] { 3, 7 });

            // Cumulative distribution function (for up to two dimensions)
            double cdf1 = target.DistributionFunction(new double[] { 1, 2 });
            double cdf2 = target.DistributionFunction(new double[] { 3, 5 });

            double ccdf1 = target.ComplementaryDistributionFunction(new double[] { 1, 2 });
            double ccdf2 = target.ComplementaryDistributionFunction(new double[] { 3, 5 });


            Assert.AreEqual(1, mean[0]);
            Assert.AreEqual(2, mean[1]);
            Assert.AreEqual(1, median[0]);
            Assert.AreEqual(2, median[1]);
            Assert.AreEqual(0.0, var[0]);
            Assert.AreEqual(0.0, var[1]);
            Assert.AreEqual(0.0, cov[0, 0]);
            Assert.AreEqual(0.0, cov[0, 1]);
            Assert.AreEqual(0.0, cov[1, 0]);
            Assert.AreEqual(0.0, cov[1, 1]);
            Assert.AreEqual(0.15915494309189532, pdf1);
            Assert.AreEqual(0.15915494309189532, pdf2);
            Assert.AreEqual(0.15915494309189532, pdf3);
            Assert.AreEqual(-1.8378770664093456, lpdf);
            Assert.AreEqual(1.0, cdf1);
            Assert.AreEqual(0.0, cdf2);
            Assert.AreEqual(0.0, ccdf1);
            Assert.AreEqual(1.0, ccdf2);
        }
开发者ID:RLaumeyer,项目名称:framework,代码行数:49,代码来源:MultivariateNormalDistributionTest.cs

示例4: CumulativeFunctionTest2

        public void CumulativeFunctionTest2()
        {
            double[] mean = { 4.2 };

            double[,] covariance = { { 1.4 } };

            var baseline = new NormalDistribution(4.2, System.Math.Sqrt(covariance[0, 0]));
            var target = new MultivariateNormalDistribution(mean, covariance);

            for (int i = 0; i < 10; i++)
            {
                double x = (i - 2) / 10.0;

                {
                    double actual = target.ProbabilityDensityFunction(x);
                    double expected = baseline.ProbabilityDensityFunction(x);
                    Assert.AreEqual(expected, actual, 1e-10);
                }

                {
                    double actual = target.DistributionFunction(x);
                    double expected = baseline.DistributionFunction(x);
                    Assert.AreEqual(expected, actual);
                }

                {
                    double actual = target.ComplementaryDistributionFunction(x);
                    double expected = baseline.ComplementaryDistributionFunction(x);
                    Assert.AreEqual(expected, actual);
                }
            }
        }
开发者ID:RLaumeyer,项目名称:framework,代码行数:32,代码来源:MultivariateNormalDistributionTest.cs

示例5: CumulativeFunctionTest1

        public void CumulativeFunctionTest1()
        {
            // Comparison against dmvnorm from the mvtnorm R package

            double[] mean = { 1, -1 };

            double[,] covariance = 
            {
                { 0.9, 0.4 },
                { 0.4, 0.3 },
            };

            var target = new MultivariateNormalDistribution(mean, covariance);

            double[] x = { 1.2, -0.8 };

            // dmvnorm(x=c(1.2, -0.8), mean=c(1, -1), sigma=matrix(c(0.9, 0.4, 0.4, 0.3), 2, 2))
            double pdf = target.ProbabilityDensityFunction(x);

            // pmvnorm(upper=c(1.2, -0.8), mean=c(1, -1), sigma=matrix(c(0.9, 0.4, 0.4, 0.3), 2, 2))
            double cdf = target.DistributionFunction(x);

            // pmvnorm(lower=c(1.2, -0.8), mean=c(1, -1), sigma=matrix(c(0.9, 0.4, 0.4, 0.3), 2, 2))
            double ccdf = target.ComplementaryDistributionFunction(x);

            Assert.AreEqual(0.44620942136345987, pdf);
            Assert.AreEqual(0.5049523013014460826, cdf, 1e-10);
            Assert.AreEqual(0.27896707550525140507, ccdf, 1e-10);
        }
开发者ID:RLaumeyer,项目名称:framework,代码行数:29,代码来源:MultivariateNormalDistributionTest.cs


注:本文中的Accord.Statistics.Distributions.Multivariate.MultivariateNormalDistribution.ComplementaryDistributionFunction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。