本文整理汇总了C#中Bernoulli.Sample方法的典型用法代码示例。如果您正苦于以下问题:C# Bernoulli.Sample方法的具体用法?C# Bernoulli.Sample怎么用?C# Bernoulli.Sample使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bernoulli
的用法示例。
在下文中一共展示了Bernoulli.Sample方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateData
/// <summary>
/// Generates a data set from a particular true model.
/// </summary>
public Vector[] GenerateData(int nData)
{
Vector trueM1 = Vector.FromArray(2.0, 3.0);
Vector trueM2 = Vector.FromArray(7.0, 5.0);
PositiveDefiniteMatrix trueP1 = new PositiveDefiniteMatrix(
new double[,] { { 3.0, 0.2 }, { 0.2, 2.0 } });
PositiveDefiniteMatrix trueP2 = new PositiveDefiniteMatrix(
new double[,] { { 2.0, 0.4 }, { 0.4, 4.0 } });
VectorGaussian trueVG1 = VectorGaussian.FromMeanAndPrecision(trueM1, trueP1);
VectorGaussian trueVG2 = VectorGaussian.FromMeanAndPrecision(trueM2, trueP2);
double truePi = 0.6;
Bernoulli trueB = new Bernoulli(truePi);
// Restart the infer.NET random number generator
Rand.Restart(12347);
Vector[] data = new Vector[nData];
for (int j = 0; j < nData; j++) {
bool bSamp = trueB.Sample();
data[j] = bSamp ? trueVG1.Sample() : trueVG2.Sample();
}
return data;
}
示例2: CanSample
public void CanSample()
{
var n = new Bernoulli(0.3);
var d = n.Sample();
}