1#ifndef STAN_MATH_PRIM_PROB_LOGISTIC_CDF_HPP
2#define STAN_MATH_PRIM_PROB_LOGISTIC_CDF_HPP
22template <
typename T_y,
typename T_loc,
typename T_scale,
24 T_y, T_loc, T_scale>* =
nullptr>
26 const T_scale& sigma) {
32 static constexpr const char* function =
"logistic_cdf";
34 mu,
"Scale parameter", sigma);
37 T_sigma_ref sigma_ref = sigma;
46 T_partials_return P(1.0);
58 return ops_partials.build(0.0);
62 for (
size_t n = 0; n < N; n++) {
65 if (y_vec.val(n) ==
INFTY) {
69 const T_partials_return y_dbl = y_vec.val(n);
70 const T_partials_return mu_dbl = mu_vec.val(n);
71 const T_partials_return sigma_dbl = sigma_vec.val(n);
72 const T_partials_return sigma_inv_vec = 1.0 / sigma_vec.val(n);
75 const T_partials_return Pn =
inv_logit((y_dbl - mu_dbl) * sigma_inv_vec);
80 partials<0>(ops_partials)[n]
84 partials<1>(ops_partials)[n]
88 partials<2>(ops_partials)[n]
89 += -(y_dbl - mu_dbl) * sigma_inv_vec
96 partials<0>(ops_partials)[n] *= P;
101 partials<1>(ops_partials)[n] *= P;
106 partials<2>(ops_partials)[n] *= P;
109 return ops_partials.build(P);
scalar_seq_view provides a uniform sequence-like wrapper around either a scalar or a sequence of scal...
require_all_not_t< is_nonscalar_prim_or_rev_kernel_expression< std::decay_t< Types > >... > require_all_not_nonscalar_prim_or_rev_kernel_expression_t
Require none of the types satisfy is_nonscalar_prim_or_rev_kernel_expression.
return_type_t< T_y_cl, T_loc_cl, T_scale_cl > logistic_lpdf(const T_y_cl &y, const T_loc_cl &mu, const T_scale_cl &sigma)
The log of a logistic density for y with the specified location and scale parameters.
return_type_t< T_y_cl, T_loc_cl, T_scale_cl > logistic_cdf(const T_y_cl &y, const T_loc_cl &mu, const T_scale_cl &sigma)
Returns the logistic cumulative distribution function for the given location, and scale.
typename return_type< Ts... >::type return_type_t
Convenience type for the return type of the specified template parameters.
int64_t size(const T &m)
Returns the size (number of the elements) of a matrix_cl or var_value<matrix_cl<T>>.
bool size_zero(const T &x)
Returns 1 if input is of length 0, returns 0 otherwise.
static constexpr double NEGATIVE_INFTY
Negative infinity.
void check_consistent_sizes(const char *)
Trivial no input case, this function is a no-op.
void check_finite(const char *function, const char *name, const T_y &y)
Return true if all values in y are finite.
void check_not_nan(const char *function, const char *name, const T_y &y)
Check if y is not NaN.
fvar< T > inv_logit(const fvar< T > &x)
Returns the inverse logit function applied to the argument.
int64_t max_size(const T1 &x1, const Ts &... xs)
Calculate the size of the largest input.
auto make_partials_propagator(Ops &&... ops)
Construct an partials_propagator.
void check_positive_finite(const char *function, const char *name, const T_y &y)
Check if y is positive and finite.
static constexpr double INFTY
Positive infinity.
fvar< T > exp(const fvar< T > &x)
typename ref_type_if< true, T >::type ref_type_t
typename partials_return_type< Args... >::type partials_return_t
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Extends std::true_type when instantiated with zero or more template parameters, all of which extend t...