1#ifndef STAN_MATH_PRIM_PROB_STD_NORMAL_CDF_HPP
2#define STAN_MATH_PRIM_PROB_STD_NORMAL_CDF_HPP
32 require_all_not_nonscalar_prim_or_rev_kernel_expression_t<T_y>* =
nullptr>
37 static constexpr const char* function =
"std_normal_cdf";
45 T_partials_return cdf(1.0);
51 for (
size_t n = 0; n < N; n++) {
52 const T_partials_return y_dbl = y_vec.val(n);
54 T_partials_return cdf_n;
57 }
else if (y_dbl < -5.0) {
58 cdf_n = 0.5 *
erfc(-scaled_y);
59 }
else if (y_dbl > 8.25) {
62 cdf_n = 0.5 * (1.0 +
erf(scaled_y));
68 const T_partials_return rep_deriv
73 partials<0>(ops_partials)[n] += rep_deriv;
79 for (
size_t n = 0; n < N; ++n) {
80 partials<0>(ops_partials)[n] *= cdf;
84 return ops_partials.build(cdf);
scalar_seq_view provides a uniform sequence-like wrapper around either a scalar or a sequence of scal...
return_type_t< T_y_cl > std_normal_cdf(const T_y_cl &y)
Returns the standard normal cumulative distribution function.
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.
fvar< T > erf(const fvar< T > &x)
static constexpr double INV_SQRT_TWO
The value of 1 over the square root of 2, .
static constexpr double INV_SQRT_TWO_PI
The value of 1 over the square root of , .
fvar< T > erfc(const fvar< T > &x)
void check_not_nan(const char *function, const char *name, const T_y &y)
Check if y is not NaN.
auto make_partials_propagator(Ops &&... ops)
Construct an partials_propagator.
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...