本文整理汇总了C#中Accord.Statistics.Distributions.Multivariate.MultivariateNormalDistribution.Fit方法的典型用法代码示例。如果您正苦于以下问题:C# MultivariateNormalDistribution.Fit方法的具体用法?C# MultivariateNormalDistribution.Fit怎么用?C# MultivariateNormalDistribution.Fit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Accord.Statistics.Distributions.Multivariate.MultivariateNormalDistribution
的用法示例。
在下文中一共展示了MultivariateNormalDistribution.Fit方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FitTest2
public void FitTest2()
{
double[][] observations =
{
new double[] { 1, 2 },
new double[] { 1, 2 },
new double[] { 1, 2 },
new double[] { 1, 2 }
};
var target = new MultivariateNormalDistribution(2);
bool thrown = false;
try { target.Fit(observations); }
catch (NonPositiveDefiniteMatrixException) { thrown = true; }
Assert.IsTrue(thrown);
NormalOptions options = new NormalOptions() { Regularization = double.Epsilon };
// No exception thrown
target.Fit(observations, options);
}
示例2: FitTest
public void FitTest()
{
double[][] observations =
{
new double[] { 0.1000, -0.2000 },
new double[] { 0.4000, 0.6000 },
new double[] { 2.0000, 0.2000 },
new double[] { 2.0000, 0.3000 }
};
double[] mean = Accord.Statistics.Tools.Mean(observations);
double[,] cov = Accord.Statistics.Tools.Covariance(observations);
var target = new MultivariateNormalDistribution(2);
double[] weigths = { 0.25, 0.25, 0.25, 0.25 };
target.Fit(observations, weigths);
Assert.IsTrue(Matrix.IsEqual(mean, target.Mean));
Assert.IsTrue(Matrix.IsEqual(cov, target.Covariance));
}
示例3: FitTest3
public void FitTest3()
{
double[][] observations =
{
new double[] { 1, 2 },
new double[] { 2, 4 },
new double[] { 3, 6 },
new double[] { 4, 8 }
};
var target = new MultivariateNormalDistribution(2);
NormalOptions options = new NormalOptions()
{
Robust = true
};
target.Fit(observations, options);
double pdf = target.ProbabilityDensityFunction(4, 2);
double cdf = target.DistributionFunction(4, 2);
bool psd = target.Covariance.IsPositiveDefinite();
Assert.AreEqual(0.043239154739844896, pdf);
Assert.AreEqual(0.12263905840338646, cdf);
Assert.IsFalse(psd);
}
示例4: FitTest5
public void FitTest5()
{
double[][] observations =
{
new double[] { 1, 2 },
new double[] { 1, 2 },
new double[] { 0, 1 },
new double[] { 5, 7 }
};
double[] weights = { 1, 1, 0, 0 };
var target = new MultivariateNormalDistribution(2);
bool thrown = false;
try { target.Fit(observations, weights); }
catch (NonPositiveDefiniteMatrixException) { thrown = true; }
Assert.IsTrue(thrown);
NormalOptions options = new NormalOptions() { Robust = true };
// No exception thrown
target.Fit(observations, weights, options);
checkDegenerate(target);
}
示例5: Estimate
/// <summary>
/// Estimates a new Normal distribution from a given set of observations.
/// </summary>
///
public static MultivariateNormalDistribution Estimate(double[][] observations, double[] weights, NormalOptions options)
{
MultivariateNormalDistribution n = new MultivariateNormalDistribution(observations[0].Length);
n.Fit(observations, weights, options);
return n;
}
示例6: FitTest
public void FitTest()
{
double[][] observations =
{
new double[] { 0.1000, -0.2000 },
new double[] { 0.4000, 0.6000 },
new double[] { 2.0000, 0.2000 },
new double[] { 2.0000, 0.3000 }
};
double[] mean = Measures.Mean(observations, dimension: 0);
double[][] cov = Measures.Covariance(observations);
{
var target = new MultivariateNormalDistribution(2);
double[] weigths = { 0.25, 0.25, 0.25, 0.25 };
target.Fit(observations, weigths);
Assert.IsTrue(Matrix.IsEqual(mean, target.Mean));
Assert.IsTrue(Matrix.IsEqual(cov, target.Covariance, 1e-10));
}
{
var target = new MultivariateNormalDistribution(2);
double[] weigths = { 1, 1, 1, 1 };
target.Fit(observations, weigths);
Assert.IsTrue(Matrix.IsEqual(mean, target.Mean));
Assert.IsTrue(Matrix.IsEqual(cov, target.Covariance, 1e-10));
}
}