private static Question GetNextQuestion(string line)
        {
            string[] words          = line.Split(' ');
            string   questionNumber = Convert.ToString(words[0]);

            IModelParameters modelParameters;

            if (words.Length == 4)
            {
                double alpha = Convert.ToDouble(words[1]);
                double delta = Convert.ToDouble(words[2]);
                double chi   = Convert.ToDouble(words[3]);
                modelParameters = new ThreeParamModelParameters(alpha, delta, chi);
            }
            else if (words.Length == 3)
            {
                double alpha = Convert.ToDouble(words[1]);
                double delta = Convert.ToDouble(words[2]);
                modelParameters = new TwoParamModelParameters(alpha, delta);
            }
            else
            {
                throw new NotImplementedException();
            }

            Question question = new Question()
            {
                ModelParameters = modelParameters,
                QuestionLabel   = questionNumber
            };

            return(question);
        }
Example #2
0
        // In this case the exponent is zero
        public void ProbabilityOfCorrectReponse_DeltaEqualsTheta_ReturnsOneHalf()
        {
            double alpha = .2;
            double delta = .3;
            TwoParamModelParameters     parameters          = new TwoParamModelParameters(alpha, delta);
            TwoParamProbabilityFunction probabilityFunction = new TwoParamProbabilityFunction(parameters);

            double theta = delta;
            double p     = probabilityFunction.ProbabilityOfCorrectResponse(theta);

            Assert.AreEqual(.5, p);
        }
        // Second line of the table on page 379 of Ayala.
        public void GetInformation_SecondValueLineFromAyala_ReturnsCorrectInfo()
        {
            TwoParamModelParameters modelParameters = new TwoParamModelParameters(2.954, .560);

            TwoParamItemInformationFunction informationFunction = new TwoParamItemInformationFunction(modelParameters);
            const double theta = .3;
            var          calculatedInformation = informationFunction.GetInformation(theta);

            const double expectedInfo = 1.889;

            Assert.AreEqual(expectedInfo, calculatedInformation, Tolerance);
        }
Example #4
0
        public void SecondThetaDerivative_NonTrivialInput_CloseToFiniteDifferenceValue()
        {
            double alpha = .2;
            double delta = .3;
            TwoParamModelParameters     parameters          = new TwoParamModelParameters(alpha, delta);
            TwoParamProbabilityFunction probabilityFunction = new TwoParamProbabilityFunction(parameters);
            FiniteDifferencer           finiteDifferencer   = new FiniteDifferencer(x => probabilityFunction.FirstThetaDerivative(x));

            double theta                  = .1;
            double secondDerivative       = probabilityFunction.SecondThetaDerivative(theta);
            double approxSecondDerivative = finiteDifferencer.ApproximateDerivative(theta);

            Assert.IsTrue(Math.Abs(secondDerivative - approxSecondDerivative) < Tolerance);
        }
Example #5
0
        public void ProbabilityOfCorrectReponse_DeltaNotEqualToTheta_ReturnsCorrectValue()
        {
            double alpha = .2;
            double delta = .3;
            TwoParamModelParameters     parameters          = new TwoParamModelParameters(alpha, delta);
            TwoParamProbabilityFunction probabilityFunction = new TwoParamProbabilityFunction(parameters);

            double theta = .1;
            double p     = probabilityFunction.ProbabilityOfCorrectResponse(theta);

            double expectedValue = Math.Exp(alpha * (theta - delta)) / (1 + Math.Exp(alpha * (theta - delta)));

            Assert.IsTrue(Math.Abs(expectedValue - p) < Tolerance);
        }
 public TwoParamProbabilityFunction(TwoParamModelParameters parameters)
 {
     _alpha = parameters.Alpha;
     _delta = parameters.Delta;
 }
Example #7
0
 public TwoParamItemInformationFunction(TwoParamModelParameters modelParameters)
 {
     _alpha = modelParameters.Alpha;
     _twoParamProbabilityFunction = new TwoParamProbabilityFunction(modelParameters);
 }