本文整理汇总了C#中NormalGamma类的典型用法代码示例。如果您正苦于以下问题:C# NormalGamma类的具体用法?C# NormalGamma怎么用?C# NormalGamma使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NormalGamma类属于命名空间,在下文中一共展示了NormalGamma类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanGetMean
public void CanGetMean(double meanLocation, double meanScale, double precShape, double precInvScale,
double meanMean, double meanPrecision)
{
NormalGamma ng = new NormalGamma(meanLocation, meanScale, precShape, precInvScale);
Assert.AreEqual<double>(meanMean, ng.Mean.Mean);
Assert.AreEqual<double>(meanPrecision, ng.Mean.Precision);
}
示例2: CanCreateNormalGamma
public void CanCreateNormalGamma(double meanLocation, double meanScale, double precShape, double precInvScale)
{
var ng = new NormalGamma(meanLocation, meanScale, precShape, precInvScale);
Assert.AreEqual(meanLocation, ng.MeanLocation);
Assert.AreEqual(meanScale, ng.MeanScale);
Assert.AreEqual(precShape, ng.PrecisionShape);
Assert.AreEqual(precInvScale, ng.PrecisionInverseScale);
}
示例3: ValidateVariance
public void ValidateVariance(double meanLocation, double meanScale, double precShape, double precInvScale)
{
var ng = new NormalGamma(meanLocation, meanScale, precShape, precInvScale);
var x = precInvScale / (meanScale * (precShape - 1));
var t = precShape / Math.Sqrt(precInvScale);
Assert.AreEqual(x, ng.Variance.Mean);
Assert.AreEqual(t, ng.Variance.Precision);
}
示例4: SampleFollowsCorrectDistribution
public void SampleFollowsCorrectDistribution()
{
var cd = new NormalGamma(1.0, 4.0, 7.0, 3.5);
// Sample from the distribution.
var samples = new MeanPrecisionPair[CommonDistributionTests.NumberOfTestSamples];
for (var i = 0; i < CommonDistributionTests.NumberOfTestSamples; i++)
{
samples[i] = cd.Sample();
}
// Extract the mean and precisions.
var means = samples.Select(mp => mp.Mean);
var precs = samples.Select(mp => mp.Precision);
var meanMarginal = cd.MeanMarginal();
var precMarginal = cd.PrecisionMarginal();
// Check the precision distribution.
CommonDistributionTests.VapnikChervonenkisTest(
CommonDistributionTests.Error,
CommonDistributionTests.ErrorProbability,
precs,
precMarginal);
// Check the mean distribution.
CommonDistributionTests.VapnikChervonenkisTest(
CommonDistributionTests.Error,
CommonDistributionTests.ErrorProbability,
means,
meanMarginal);
}
示例5: CanGetPrecisionMarginal
public void CanGetPrecisionMarginal(double meanLocation, double meanScale, double precShape, double precInvScale)
{
var ng = new NormalGamma(meanLocation, meanScale, precShape, precInvScale);
var pm = ng.PrecisionMarginal();
Assert.AreEqual(precShape, pm.Shape);
Assert.AreEqual(precInvScale, pm.InvScale);
}
示例6: HasRandomSource
public void HasRandomSource()
{
var ng = new NormalGamma(0.0, 1.0, 1.0, 1.0);
Assert.IsNotNull(ng.RandomSource);
}
示例7: CanGetPrecisionShape
public void CanGetPrecisionShape(double meanLocation, double meanScale, double precShape, double precInvScale)
{
var ng = new NormalGamma(meanLocation, meanScale, precShape, precInvScale);
Assert.AreEqual(precShape, ng.PrecisionShape);
}
示例8: CanGetMeanMarginal
public void CanGetMeanMarginal(double meanLocation, double meanScale, double precShape, double precInvScale, double meanMarginalMean, double meanMarginalScale, double meanMarginalDoF)
{
var ng = new NormalGamma(meanLocation, meanScale, precShape, precInvScale);
var mm = ng.MeanMarginal();
Assert.AreEqual(meanMarginalMean, mm.Location);
Assert.AreEqual(meanMarginalScale, mm.Scale);
Assert.AreEqual(meanMarginalDoF, mm.DegreesOfFreedom);
}
示例9: CanGetDensityAndDensityLn
public void CanGetDensityAndDensityLn(double meanLocation, double meanScale, double precShape, double precInvScale)
{
var ng = new NormalGamma(meanLocation, meanScale, precShape, precInvScale);
Assert.AreEqual(ng.DensityLn(meanLocation, precShape), Math.Log(ng.Density(meanLocation, precShape)), 1e-14);
}
示例10: CanGetMean
public void CanGetMean([Values(0.0, 10.0, 10.0)] double meanLocation, [Values(1.0, 1.0, 1.0)] double meanScale, [Values(1.0, 2.0, 2.0)] double precShape, [Values(1.0, 2.0, Double.PositiveInfinity)] double precInvScale, [Values(0.0, 10.0, 10.0)] double meanMean, [Values(1.0, 1.0, 2.0)] double meanPrecision)
{
var ng = new NormalGamma(meanLocation, meanScale, precShape, precInvScale);
Assert.AreEqual(meanMean, ng.Mean.Mean);
Assert.AreEqual(meanPrecision, ng.Mean.Precision);
}
示例11: CanSetPrecisionShape
public void CanSetPrecisionShape(double meanLocation, double meanScale, double precShape, double precInvScale)
{
NormalGamma ng = new NormalGamma(meanLocation, meanScale, precShape, precInvScale);
ng.PrecisionShape = 5.0;
Assert.AreEqual<double>(meanLocation, ng.MeanLocation);
Assert.AreEqual<double>(meanScale, ng.MeanScale);
Assert.AreEqual<double>(5.0, ng.PrecisionShape);
Assert.AreEqual<double>(precInvScale, ng.PrecisionInverseScale);
}
示例12: CanSetRandomSource
public void CanSetRandomSource()
{
NormalGamma ng = new NormalGamma(0.0, 1.0, 1.0, 1.0);
ng.RandomSource = new Random();
}
示例13: CanGetMeanScale
public void CanGetMeanScale(double meanLocation, double meanScale, double precShape, double precInvScale)
{
NormalGamma ng = new NormalGamma(meanLocation, meanScale, precShape, precInvScale);
AssertEx.AreEqual<double>(meanScale, ng.MeanScale);
}
示例14: CanGetMeanLocation
public void CanGetMeanLocation([Values(0.0, 10.0)] double meanLocation, [Values(1.0, 2.0)] double meanScale, [Values(1.0, 2.0)] double precShape, [Values(1.0, 2.0)] double precInvScale)
{
var ng = new NormalGamma(meanLocation, meanScale, precShape, precInvScale);
Assert.AreEqual(meanLocation, ng.MeanLocation);
}
示例15: ValidateVariance
public void ValidateVariance([Values(0.0, 10.0)] double meanLocation, [Values(1.0, 2.0)] double meanScale, [Values(1.0, 2.0)] double precShape, [Values(1.0, 2.0, Double.PositiveInfinity)] double precInvScale)
{
var ng = new NormalGamma(meanLocation, meanScale, precShape, precInvScale);
var x = precInvScale / (meanScale * (precShape - 1));
var t = precShape / Math.Sqrt(precInvScale);
Assert.AreEqual(x, ng.Variance.Mean);
Assert.AreEqual(t, ng.Variance.Precision);
}