| Stan Math Library 2.12.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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
4 #include <stan/math/prim/mat/fun/Eigen.hpp>
5 #include <stan/math/prim/mat/meta/index_type.hpp>
6
7 namespace stan {
8 namespace math {
9
19 template<typename T>
20 const Eigen::Array<T, Eigen::Dynamic, 1>
21 make_nu(const T eta, const size_t K) {
22 using Eigen::Array;
23 using Eigen::Dynamic;
24 using Eigen::Matrix;
25 typedef typename index_type<Matrix<T, Dynamic, 1> >::type size_type;
26
27 Array<T, Dynamic, 1> nu(K * (K - 1) / 2);
28
29 T alpha = eta + (K - 2.0) / 2.0; // from Lewandowski et. al.
30
31 // Best (1978) implies nu = 2 * alpha for the dof in a t
32 // distribution that generates a beta variate on (-1, 1)
33 T alpha2 = 2.0 * alpha;
34 for (size_type j = 0; j < (K - 1); j++) {
35 nu(j) = alpha2;
36 }
37 size_t counter = K - 1;
38 for (size_type i = 1; i < (K - 1); i++) {
39 alpha -= 0.5;
40 alpha2 = 2.0 * alpha;
41 for (size_type j = i + 1; j < K; j++) {
42 nu(counter) = alpha2;
43 counter++;
44 }
45 }
46 return nu;
47 }
48
49 }
50
51 }
52
53 #endif
stan
Definition: log_sum_exp.hpp:8
stan::math::make_nu
const Eigen::Array< T, Eigen::Dynamic, 1 > make_nu(const T eta, const size_t K)
This function calculates the degrees of freedom for the t distribution that corresponds to the shape ...
Definition: make_nu.hpp:21
stan::math::size_type
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:13
stan::math::index_type
Primary template class for the metaprogram to compute the index type of a container.
Definition: index_type.hpp:18
index_type.hpp
Eigen.hpp

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