| Stan Math Library 2.11.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
9 namespace math {
10
20 template<typename T>
21 const Eigen::Array<T, Eigen::Dynamic, 1>
22 make_nu(const T eta, const size_t K) {
23 using Eigen::Array;
24 using Eigen::Dynamic;
25 using Eigen::Matrix;
26 using stan::math::index_type;
27 typedef typename index_type<Matrix<T, Dynamic, 1> >::type size_type;
28
29 Array<T, Dynamic, 1> nu(K * (K - 1) / 2);
30
31 T alpha = eta + (K - 2.0) / 2.0; // from Lewandowski et. al.
32
33 // Best (1978) implies nu = 2 * alpha for the dof in a t
34 // distribution that generates a beta variate on (-1, 1)
35 T alpha2 = 2.0 * alpha;
36 for (size_type j = 0; j < (K - 1); j++) {
37 nu(j) = alpha2;
38 }
39 size_t counter = K - 1;
40 for (size_type i = 1; i < (K - 1); i++) {
41 alpha -= 0.5;
42 alpha2 = 2.0 * alpha;
43 for (size_type j = i + 1; j < K; j++) {
44 nu(counter) = alpha2;
45 counter++;
46 }
47 }
48 return nu;
49 }
50
51 }
52
53 }
54
55 #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:22
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:19
index_type.hpp
Eigen.hpp

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