#include <ItemParamPriorLogNormal.h>
Public Member Functions | |
ItemParamPriorLogNormal () | |
Default constructor - assigns uniform distribution. | |
ItemParamPriorLogNormal (RealVector ¶m) | |
Constructor taking vector of parameters. | |
ItemParamPriorLogNormal (Real mean, Real sd) | |
Constructor taking prior mean and standard deviation as arguments. | |
virtual int | NumParameters () |
Returns number of prior logNormal distribution parameters for the IRT parameter. | |
virtual bool | ZeroDensity (Real p) |
Returns true if density at p is zero. | |
virtual Real | NearestNonZero (Real x) |
If density of x is zero (x <= 0) then this function returns a small value slightly greater than zero that has a non-zero density. | |
virtual Real | LogDensity (Real p) |
Returns log-density of p. | |
virtual Real | DerivLogDensity1 (Real p) |
Returns first derivative of log density. | |
virtual Real | DerivLogDensity2 (Real p) |
Returns second derivative of log density. | |
virtual std::string | DistributionName () const |
Returns string containing name of distribution used for prior. | |
Private Attributes | |
Real | variance |
Variance of log-Normal distribution. |
Definition at line 40 of file ItemParamPriorLogNormal.h.
etirm::ItemParamPriorLogNormal::ItemParamPriorLogNormal | ( | ) |
Default constructor - assigns uniform distribution.
Definition at line 80 of file ItemParamPriorLogNormal.cpp.
References etirm::ItemParamPrior::mParameters, and variance.
00080 : 00081 ItemParamPrior(2) 00082 { 00083 mParameters[0] = 0.0; 00084 mParameters[1] = 1.0; 00085 00086 variance = 1.0; 00087 }
etirm::ItemParamPriorLogNormal::ItemParamPriorLogNormal | ( | RealVector & | param | ) |
Constructor taking vector of parameters.
[in] | ¶m | Parameter vector describing log-Normal prior: param[0] - prior mean, param[1] - prior standard deviation. |
Definition at line 48 of file ItemParamPriorLogNormal.cpp.
References variance.
00048 : 00049 ItemParamPrior(param) 00050 { 00051 variance = param(2) * param(2); 00052 }
Constructor taking prior mean and standard deviation as arguments.
[in] | mean | Prior mean |
[in] | sd | Prior standard deviation |
Definition at line 63 of file ItemParamPriorLogNormal.cpp.
References etirm::ItemParamPrior::mParameters, and variance.
00063 : 00064 ItemParamPrior(2) 00065 { 00066 if (sd <= 0.0) 00067 throw RuntimeError("Invalid s.d. for lognormal prior", 00068 "ItemParamPriorLogNormal::ItemParamPriorLogNormal"); 00069 00070 mParameters[0] = mean; 00071 mParameters[1] = sd; 00072 00073 variance = sd * sd; 00074 }
virtual int etirm::ItemParamPriorLogNormal::NumParameters | ( | ) | [inline, virtual] |
Returns number of prior logNormal distribution parameters for the IRT parameter.
Implements etirm::ItemParamPrior.
Definition at line 49 of file ItemParamPriorLogNormal.h.
virtual bool etirm::ItemParamPriorLogNormal::ZeroDensity | ( | Real | p | ) | [inline, virtual] |
Returns true if density at p is zero.
Reimplemented from etirm::ItemParamPrior.
Definition at line 54 of file ItemParamPriorLogNormal.h.
Referenced by DerivLogDensity1(), DerivLogDensity2(), and LogDensity().
If density of x is zero (x <= 0) then this function returns a small value slightly greater than zero that has a non-zero density.
Reimplemented from etirm::ItemParamPrior.
Definition at line 65 of file ItemParamPriorLogNormal.h.
Returns log-density of p.
[in] | p | Argument of log density function (an item parameter value). |
Implements etirm::ItemParamPrior.
Definition at line 97 of file ItemParamPriorLogNormal.cpp.
References etirm::ItemParamPrior::mParameters, variance, and ZeroDensity().
00098 { 00099 /* Check for value outside limits of distribution */ 00100 if (ItemParamPriorLogNormal::ZeroDensity(p)) 00101 { 00102 return std::log(0.0); 00103 } 00104 00105 Real value = std::log(p) - mParameters[0]; 00106 value *= value; 00107 value /= -2.0 * variance; 00108 value -= std::log(p); 00109 00110 return value; 00111 }
Returns first derivative of log density.
[in] | p | Argument of log density function (an item parameter value). |
Implements etirm::ItemParamPrior.
Definition at line 121 of file ItemParamPriorLogNormal.cpp.
References etirm::ItemParamPrior::mParameters, variance, and ZeroDensity().
00122 { 00123 /* Outside limits of distribution density does not change, 00124 so derivative is zero */ 00125 if (ItemParamPriorLogNormal::ZeroDensity(p)) 00126 return 0.0; 00127 00128 Real value = std::log(p) - mParameters[0] + variance; 00129 value /= variance * p; 00130 00131 return -value; 00132 }
Returns second derivative of log density.
[in] | p | Argument of log density function (an item parameter value). |
Implements etirm::ItemParamPrior.
Definition at line 142 of file ItemParamPriorLogNormal.cpp.
References etirm::ItemParamPrior::mParameters, variance, and ZeroDensity().
00143 { 00144 /* Outside limits of distribution density does not change, 00145 so derivative is zero */ 00146 if (ItemParamPriorLogNormal::ZeroDensity(p)) 00147 return 0.0; 00148 00149 Real value = std::log(p) - mParameters[0] + variance - 1.0; 00150 value /= p * p * variance; 00151 00152 return value; 00153 }
virtual std::string etirm::ItemParamPriorLogNormal::DistributionName | ( | ) | const [inline, virtual] |
Returns string containing name of distribution used for prior.
Implements etirm::ItemParamPrior.
Definition at line 79 of file ItemParamPriorLogNormal.h.
Real etirm::ItemParamPriorLogNormal::variance [private] |
Variance of log-Normal distribution.
Definition at line 89 of file ItemParamPriorLogNormal.h.
Referenced by DerivLogDensity1(), DerivLogDensity2(), ItemParamPriorLogNormal(), and LogDensity().