make_nu.hpp
Go to the documentation of this file.
#ifndef STAN_MATH_PRIM_MAT_FUN_MAKE_NU_HPP
#define STAN_MATH_PRIM_MAT_FUN_MAKE_NU_HPP
#include <stan/math/prim/mat/fun/Eigen.hpp>
#include <stan/math/prim/mat/meta/index_type.hpp>
namespace stan {
namespace math {
template<typename T>
const Eigen::Array<T, Eigen::Dynamic, 1>
make_nu(const T eta, size_t K) {
using Eigen::Array;
using Eigen::Dynamic;
using Eigen::Matrix;
typedef typename index_type<Matrix<T, Dynamic, 1> >::type size_type;
Array<T, Dynamic, 1> nu(K * (K - 1) / 2);
T alpha = eta + (K - 2.0) / 2.0; // from Lewandowski et. al.
// Best (1978) implies nu = 2 * alpha for the dof in a t
// distribution that generates a beta variate on (-1, 1)
T alpha2 = 2.0 * alpha;
for (size_type j = 0; j < (K - 1); j++) {
nu(j) = alpha2;
}
size_t counter = K - 1;
for (size_type i = 1; i < (K - 1); i++) {
alpha -= 0.5;
alpha2 = 2.0 * alpha;
for (size_type j = i + 1; j < K; j++) {
nu(counter) = alpha2;
counter++;
}
}
return nu;
}
}
}
#endif
stan
Definition: log_sum_exp.hpp:8
stan::math::make_nu
const Eigen::Array< T, Eigen::Dynamic, 1 > make_nu(const T eta, 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.