Stan Math Library  2.20.0
reverse mode automatic differentiation
make_nu.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_FUN_MAKE_NU_HPP
2 #define STAN_MATH_PRIM_MAT_FUN_MAKE_NU_HPP
3 
6 
7 namespace stan {
8 namespace math {
9 
17 template <typename T>
18 Eigen::Array<T, Eigen::Dynamic, 1> make_nu(const T& eta, size_t K) {
19  using Eigen::Array;
20  using Eigen::Dynamic;
21  using Eigen::Matrix;
22  typedef typename index_type<Matrix<T, Dynamic, 1> >::type size_type;
23 
24  // Best (1978) implies nu = 2 * alpha for the dof in a t
25  // distribution that generates a beta variate on (-1, 1)
26  Array<T, Dynamic, 1> nu(K * (K - 1) / 2);
27  T alpha = eta + 0.5 * (K - 2.0); // from Lewandowski et. al.
28  T alpha2 = 2.0 * alpha;
29  for (size_type j = 0; j < (K - 1); ++j)
30  nu(j) = alpha2;
31  size_t counter = K - 1;
32  for (size_type i = 1; i < (K - 1); ++i) {
33  alpha -= 0.5;
34  alpha2 = 2.0 * alpha;
35  for (size_type j = i + 1; j < K; ++j, ++counter)
36  nu(counter) = alpha2;
37  }
38  return nu;
39 }
40 
41 } // namespace math
42 } // namespace stan
43 #endif
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic >::Index size_type
Type for sizes and indexes in an Eigen matrix with double e.
Definition: typedefs.hpp:11
Primary template class for the metaprogram to compute the index type of a container.
Definition: index_type.hpp:18
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:18

     [ Stan Home Page ] © 2011–2018, Stan Development Team.