本文整理汇总了C#中Beta.Sample方法的典型用法代码示例。如果您正苦于以下问题:C# Beta.Sample方法的具体用法?C# Beta.Sample怎么用?C# Beta.Sample使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Beta
的用法示例。
在下文中一共展示了Beta.Sample方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DinaSample
// Sample data from the DINA model
public static bool[][] DinaSample(int nStudents, int nSkills, int[][] skillsRequired, Beta slipPrior, Beta guessPrior,
out double[] pSkillOut, out double[] slip, out double[] guess, out bool[][] hasSkill)
{
int nQuestions = skillsRequired.Length;
double[] pSkill = Util.ArrayInit(nSkills, q => Rand.Double());
slip = Util.ArrayInit(nQuestions, q => slipPrior.Sample());
guess = Util.ArrayInit(nQuestions, q => guessPrior.Sample());
hasSkill = Util.ArrayInit(nStudents, t => Util.ArrayInit(nSkills, s => Rand.Double() < pSkill[s]));
bool[][] responses = new bool[nStudents][];
for (int t = 0; t < nStudents; t++) {
responses[t] = new bool[nQuestions];
for (int q = 0; q < nQuestions; q++) {
bool hasAllSkills = Factor.AllTrue(Factor.Subarray(hasSkill[t], skillsRequired[q]));
if (hasAllSkills) responses[t][q] = (Rand.Double() > slip[q]);
else responses[t][q] = (Rand.Double() < guess[q]);
}
}
pSkillOut = pSkill;
return responses;
}
示例2: CanSample
public void CanSample()
{
var n = new Beta(2.0, 3.0);
n.Sample();
}
示例3: NidaSample
// Sample data from the NIDA model
public static bool[][] NidaSample(int nStudents, int nSkills, int[][] skillsRequired, Beta slipPrior, Beta guessPrior,
out double[] pSkillOut, out double[] slip, out double[] guess, out bool[][] hasSkill)
{
int nQuestions = skillsRequired.Length;
double[] pSkill = Util.ArrayInit(nSkills, q => Rand.Double());
slip = Util.ArrayInit(nSkills, s => slipPrior.Sample());
guess = Util.ArrayInit(nSkills, s => guessPrior.Sample());
hasSkill = Util.ArrayInit(nStudents, t => Util.ArrayInit(nSkills, s => Rand.Double() < pSkill[s]));
bool[][] responses = new bool[nStudents][];
for (int t = 0; t < nStudents; t++) {
responses[t] = new bool[nQuestions];
for (int q = 0; q < nQuestions; q++) {
bool[] exhibitsSkill = new bool[skillsRequired[q].Length];
for (int s = 0; s < skillsRequired[q].Length; s++) {
int skill = skillsRequired[q][s];
if (hasSkill[t][skill]) exhibitsSkill[s] = (Rand.Double() > slip[skill]);
else exhibitsSkill[s] = (Rand.Double() < guess[skill]);
}
responses[t][q] = Factor.AllTrue(exhibitsSkill);
}
}
pSkillOut = pSkill;
return responses;
}