Automatic Differentiation
 
Loading...
Searching...
No Matches
make_nu.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_MAKE_NU_HPP
2#define STAN_MATH_PRIM_FUN_MAKE_NU_HPP
3
6
7namespace stan {
8namespace math {
9
18template <typename T>
19Eigen::Array<T, Eigen::Dynamic, 1> make_nu(const T& eta, size_t K) {
21
22 // Best (1978) implies nu = 2 * alpha for the dof in a t
23 // distribution that generates a beta variate on (-1, 1)
24 Eigen::Array<T, Eigen::Dynamic, 1> nu(K * (K - 1) / 2);
25 T alpha = eta + 0.5 * (K - 2.0); // from Lewandowski et. al.
26 T alpha2 = 2.0 * alpha;
27 for (size_type j = 0; j < (K - 1); ++j) {
28 nu(j) = alpha2;
29 }
30 size_t counter = K - 1;
31 for (size_type i = 1; i < (K - 1); ++i) {
32 alpha -= 0.5;
33 alpha2 = 2.0 * alpha;
34 for (size_type j = i + 1; j < K; ++j, ++counter) {
35 nu(counter) = alpha2;
36 }
37 }
38 return nu;
39}
40
41} // namespace math
42} // namespace stan
43
44#endif
typename index_type< T >::type index_type_t
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic >::Index size_type
Type for sizes and indexes in an Eigen matrix with double elements.
Definition typedefs.hpp:11
Eigen::Array< T, Eigen::Dynamic, 1 > make_nu(const T &eta, size_t K)
Return the degrees of freedom for the t distribution that corresponds to the shape parameter in the L...
Definition make_nu.hpp:19
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...