1 #ifndef DNT_H_
2 #define DNT_H_
3 
4 #include <distribution/RScalarDist.h>
5 
6 namespace jags {
7     namespace bugs {
8 
9 	/**
10 	 * Non-central t-distribution on k degrees of freedom, with
11 	 * location/non-centrality parameter parameter mu, and
12 	 * precision parameter tau.
13 	 *
14 	 * The non-central t has no simple closed-form expression for
15 	 * its density but it can be defined constructively in terms
16 	 * of underlying normal and chi-squared distributions.
17 	 *
18 	 * <pre>
19          * X ~ dnt(mu, tau, k)
20 	 * X = U/sqrt(V/k))
21 	 * U ~ N(mu, tau)
22 	 * V ~ Chi2(k)
23 	 * </pre>
24 	 *
25 	 * The non-central t-distribution is normally only defined for
26 	 * tau=1, in which case mu is the non-centrality
27 	 * parameter. The 3-parameter form here is a scaled version of
28 	 * a standard non-central t with non-centrality parameter
29 	 * delta = mu * sqrt(tau).
30 	 *
31 	 * @short non-central t distribution
32 	 */
33 	class DNT : public RScalarDist {
34 	  public:
35 	    DNT();
36 	    double d(double x, PDFType type,
37 		     std::vector<double const *> const &parameters,
38 		     bool log) const;
39 	    double p(double x, std::vector<double const *> const &parameters,
40 		     bool lower, bool log) const;
41 	    double q(double x, std::vector<double const *> const &parameters,
42 		     bool lower, bool log) const;
43 	    double r(std::vector<double const *> const &parameters,
44 		     RNG *rng) const;
45 	    /**
46 	     * Check that tau > 0 and k > 0 also that the non-centrality
47 	     * parameter delta = mu * sqrt(tau) is no larger than 37.62
48 	     */
49 	    bool checkParameterValue(std::vector<double const *> const &
50 				     parameters) const;
51 	};
52     }
53 }
54 
55 #endif /* DNT_H_ */
56