本文整理汇总了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));
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}