1 #ifndef STAN_MATH_PRIM_FUN_UNIFORM_SIMPLEX_HPP 2 #define STAN_MATH_PRIM_FUN_UNIFORM_SIMPLEX_HPP 3 4 #include <stan/math/prim/err.hpp> 5 #include <stan/math/prim/fun/Eigen.hpp> 6 7 namespace stan { 8 namespace math { 9 10 /** 11 * Return a uniform simplex of size K 12 * 13 * @param K size of the simplex 14 * @return A vector of size K with all elements initialised to 1 / K, 15 * so that their sum is equal to 1. 16 * @throw std::domain_error if K is not positive. 17 */ uniform_simplex(int K)18inline auto uniform_simplex(int K) { 19 check_positive("uniform_simplex", "size", K); 20 return Eigen::VectorXd::Constant(K, 1.0 / K); 21 } 22 23 } // namespace math 24 } // namespace stan 25 26 #endif 27