1 #ifndef STAN_MATH_PRIM_FUN_PROB_FREE_HPP 2 #define STAN_MATH_PRIM_FUN_PROB_FREE_HPP 3 4 #include <stan/math/prim/meta.hpp> 5 #include <stan/math/prim/err.hpp> 6 #include <stan/math/prim/fun/logit.hpp> 7 8 namespace stan { 9 namespace math { 10 11 /** 12 * Return the free scalar that when transformed to a probability 13 * produces the specified scalar. 14 * 15 * <p>The function that reverses the constraining transform 16 * specified in <code>prob_constrain(T)</code> is the logit 17 * function, 18 * 19 * <p>\f$f^{-1}(y) = \mbox{logit}(y) = \frac{1 - y}{y}\f$. 20 * 21 * @tparam T type of constrained value 22 * @param y constrained value 23 * @return corresponding unconstrained value 24 * @throw std::domain_error if y is not in (0, 1) 25 */ 26 template <typename T> prob_free(const T & y)27inline T prob_free(const T& y) { 28 check_bounded<T, double, double>("prob_free", "Probability variable", y, 0, 29 1); 30 return logit(y); 31 } 32 33 } // namespace math 34 } // namespace stan 35 #endif 36