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


C# MultivariateNormalDistribution.Generate方法代码示例

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


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

示例1: MultivariateNormalGenerateTest

        public void MultivariateNormalGenerateTest()
        {
            // mean vector
            double[] mu = { 2.0, 6.0 };

            // covariance
            double[,] cov = 
            {
                { 2, 1 },
                { 1, 5 } 
            };

            // Create a multivariate Normal distribution
            var normal = new MultivariateNormalDistribution(mu, cov);

            // Generate 1000000 samples from it
            double[][] samples = normal.Generate(1000000);

            // Try to estimate a new Normal distribution from
            // generated samples to check if they indeed match
            var actual = MultivariateNormalDistribution.Estimate(samples);

            Assert.IsTrue(mu.IsEqual(actual.Mean, 0.1));
            Assert.IsTrue(cov.IsEqual(actual.Covariance, 0.1));
        }
开发者ID:amurshed,项目名称:statistics-workbench,代码行数:25,代码来源:ArticleExamplesTest.cs

示例2: btnGenerateRandom_Click

        private void btnGenerateRandom_Click(object sender, EventArgs e)
        {
            k = (int)numClusters.Value;

            // Generate data with n Gaussian distributions
            double[][][] data = new double[k][][];

            for (int i = 0; i < k; i++)
            {
                // Create random centroid to place the Gaussian distribution
                double[] mean = Matrix.Random(2, -6.0, +6.0);

                // Create random covariance matrix for the distribution
                double[,] covariance = Accord.Statistics.Tools.RandomCovariance(2, -5, 5);

                // Create the Gaussian distribution
                var gaussian = new MultivariateNormalDistribution(mean, covariance);

                int samples = Accord.Math.Tools.Random.Next(150, 250);
                data[i] = gaussian.Generate(samples);
            }

            // Join the generated data
            mixture = Matrix.Stack(data);

            // Update the scatterplot
            CreateScatterplot(graph, mixture, k);

            // Forget previous initialization
            kmeans = null;
        }
开发者ID:natepan,项目名称:framework,代码行数:31,代码来源:MainForm.cs

示例3: GenerateTest1

        public void GenerateTest1()
        {
            Accord.Math.Tools.SetupGenerator(0);

            double[] mean = { 2, 6 };

            double[,] cov = 
            {
                { 2, 1 },
                { 1, 5 } 
            };

            var normal = new MultivariateNormalDistribution(mean, cov);
            double[][] source = normal.Generate(10000000);

            var target = new MultivariateEmpiricalDistribution(source);

            Assert.IsTrue(mean.IsEqual(target.Mean, 0.001));
            Assert.IsTrue(cov.IsEqual(target.Covariance, 0.003));

            double[][] samples = target.Generate(10000000);

            double[] sampleMean = samples.Mean();
            double[,] sampleCov = samples.Covariance();

            Assert.AreEqual(2, sampleMean[0], 1e-2);
            Assert.AreEqual(6, sampleMean[1], 1e-2);
            Assert.AreEqual(2, sampleCov[0, 0], 1e-2);
            Assert.AreEqual(1, sampleCov[0, 1], 1e-2);
            Assert.AreEqual(1, sampleCov[1, 0], 1e-2);
            Assert.AreEqual(5, sampleCov[1, 1], 2e-2);
        }
开发者ID:RLaumeyer,项目名称:framework,代码行数:32,代码来源:MultivariateEmpiricalDistributionTest.cs

示例4: GenerateTest2

        public void GenerateTest2()
        {
            Accord.Math.Tools.SetupGenerator(0);

            var normal = new MultivariateNormalDistribution(
                new double[] { 2, 6 },
                new double[,] { { 2, 1 }, { 1, 5 } });

            double[][] sample = new double[1000000][];
            for (int i = 0; i < sample.Length; i++)
                sample[i] = normal.Generate();

            double[] mean = sample.Mean();
            double[,] cov = sample.Covariance();

            Assert.AreEqual(2, mean[0], 1e-2);
            Assert.AreEqual(6, mean[1], 1e-2);

            Assert.AreEqual(2, cov[0, 0], 1e-2);
            Assert.AreEqual(1, cov[0, 1], 1e-2);
            Assert.AreEqual(1, cov[1, 0], 1e-2);
            Assert.AreEqual(5, cov[1, 1], 2e-2);
        }
开发者ID:huanzl0503,项目名称:framework,代码行数:23,代码来源:MultivariateEmpiricalDistributionTest.cs

示例5: GenerateTest

        public void GenerateTest()
        {
            Accord.Math.Tools.SetupGenerator(0);

            var normal = new MultivariateNormalDistribution(
                new double[] { 2, 6 },
                new double[,] { { 2, 1 }, { 1, 5 } });

            double[][] sample = normal.Generate(1000000);

            double[] mean = sample.Mean(dimension: 0);
            double[][] cov = sample.Covariance(dimension: 0);

            Assert.AreEqual(2, mean[0], 1e-2);
            Assert.AreEqual(6, mean[1], 1e-2);

            Assert.AreEqual(2, cov[0][0], 1e-2);
            Assert.AreEqual(1, cov[0][1], 1e-2);
            Assert.AreEqual(1, cov[1][0], 1e-2);
            Assert.AreEqual(5, cov[1][1], 2e-2);
        }
开发者ID:accord-net,项目名称:framework,代码行数:21,代码来源:MultivariateNormalDistributionTest.cs


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