本文整理汇总了C#中Gamma.Sample方法的典型用法代码示例。如果您正苦于以下问题:C# Gamma.Sample方法的具体用法?C# Gamma.Sample怎么用?C# Gamma.Sample使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gamma
的用法示例。
在下文中一共展示了Gamma.Sample方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Sample
public int[][] Sample(int nSubjects, int nQuestions, int nChoices, Gaussian abilityPrior, Gaussian difficultyPrior, Gamma discriminationPrior,
out double[] ability, out double[] difficulty, out double[] discrimination, out int[] trueAnswer)
{
ability = Util.ArrayInit(nSubjects, s => abilityPrior.Sample());
difficulty = Util.ArrayInit(nQuestions, q => difficultyPrior.Sample());
discrimination = Util.ArrayInit(nQuestions, q => discriminationPrior.Sample());
trueAnswer = Util.ArrayInit(nQuestions, q => Rand.Int(nChoices));
int[][] response = new int[nSubjects][];
for (int s = 0; s < nSubjects; s++) {
response[s] = new int[nQuestions];
for (int q = 0; q < nQuestions; q++) {
double advantage = ability[s] - difficulty[q];
double noise = Gaussian.Sample(0, discrimination[q]);
bool correct = (advantage > noise);
if (correct) response[s][q] = trueAnswer[q];
else response[s][q] = Rand.Int(nChoices);
}
}
return response;
}