Exemple #1
0
 private int GetTotalAnsweringFrequency(AnswerStatistic answerStatistic, AnsweredQuestion answeredQuestion)
 {
     if (!answerStatistic.AnsweredQuestionsById.ContainsKey(answeredQuestion.QuestionId))
         return answeringChoicesCount;
     return answerStatistic.AnsweredQuestionsById[answeredQuestion.QuestionId].ChoicesFrequenciesTotal;
 }
Exemple #2
0
 public string GetNextQuestionId(IList<AnsweredQuestion> answeredQuestions, IList<AnswerGuess> answerGuesses)
 {
     string nextQuestionId = null;
     double minQuestionEntropy = double.MaxValue;
     var answeredQuestionIds = new HashSet<string>(answeredQuestions.Select(q => q.QuestionId));
     foreach (var questionId in questionStatistics.Keys)
     {
         if (answeredQuestionIds.Contains(questionId))
             continue;
         double entropy = 0.0;
         for (int i = 0; i < answeringChoicesCount; i++)
         {
             var answeredQuestion = new AnsweredQuestion { Choise = i, QuestionId = questionId };
             var probabilities = answerGuesses.Select(ag => ag.Probability *
                                                            GetAnsweringFrequency(ag.AnswerStatistic,answeredQuestion) /
                                                            GetTotalAnsweringFrequency(ag.AnswerStatistic, answeredQuestion))
                                                            .ToList();
             var totalProbability = probabilities.Sum();
             var answeredQuestionProbability = (double)questionStatistics[questionId].ChoicesFrequencies[i] /
                                               questionStatistics[questionId].ChoicesFrequenciesTotal;
             foreach (var probability in probabilities)
             {
                 double correctedProbability = probability / totalProbability;
                 entropy += -correctedProbability * Math.Log(correctedProbability, 2.0) * answeredQuestionProbability;
             }
         }
         if (entropy < minQuestionEntropy)
         {
             minQuestionEntropy = entropy;
             nextQuestionId = questionId;
         }
     }
     return nextQuestionId;
 }
Exemple #3
0
 private int GetAnsweringFrequency(AnswerStatistic answerStatistic, AnsweredQuestion answeredQuestion)
 {
     if (!answerStatistic.AnsweredQuestionsById.ContainsKey(answeredQuestion.QuestionId))
         return 1;
     return answerStatistic.AnsweredQuestionsById[answeredQuestion.QuestionId].ChoicesFrequencies[answeredQuestion.Choise];
 }