Skip to content

Commit f8c103a

Browse files
committed
More changes for Bob
1 parent e324b67 commit f8c103a

File tree

6 files changed

+278
-299
lines changed

6 files changed

+278
-299
lines changed

stan/math/prim/prob/wiener4_lccdf.hpp

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,17 @@ inline auto wiener_prob_derivative_term(const T_a& a, const T_v& v,
9797
* @param a The boundary separation
9898
* @param v The relative starting point
9999
* @param w The drift rate
100-
* @param err The log error tolerance
100+
* @param log_err The log error tolerance in the computation of the number
101+
* of terms for the infinite sums
101102
* @return ccdf
102103
*/
103104
template <typename T_y, typename T_a, typename T_w, typename T_v,
104105
typename T_err>
105106
inline auto wiener4_ccdf(const T_y& y, const T_a& a, const T_v& v, const T_w& w,
106-
T_err&& err = log(1e-12)) noexcept {
107+
T_err log_err = log(1e-12)) noexcept {
107108
const auto prob_hit_upper = exp(log_wiener_prob_hit_upper(a, v, w));
108109
const auto cdf
109-
= internal::wiener4_distribution<GradientCalc::ON>(y, a, v, w, err);
110+
= internal::wiener4_distribution<GradientCalc::ON>(y, a, v, w, log_err);
110111
return prob_hit_upper - cdf;
111112
}
112113

@@ -118,14 +119,15 @@ inline auto wiener4_ccdf(const T_y& y, const T_a& a, const T_v& v, const T_w& w,
118119
* @param v The relative starting point
119120
* @param w The drift rate
120121
* @param cdf The CDF value
121-
* @param err The log error tolerance
122+
* @param log_err The log error tolerance in the computation of the number
123+
* of terms for the infinite sums
122124
* @return Gradient with respect to a
123125
*/
124126
template <typename T_y, typename T_a, typename T_w, typename T_v,
125127
typename T_cdf, typename T_err>
126128
inline auto wiener4_ccdf_grad_a(const T_y& y, const T_a& a, const T_v& v,
127129
const T_w& w, T_cdf&& cdf,
128-
T_err&& err = log(1e-12)) noexcept {
130+
T_err log_err = log(1e-12)) noexcept {
129131
using ret_t = return_type_t<T_a, T_w, T_v>;
130132

131133
// derivative of the wiener probability w.r.t. 'a' (on log-scale)
@@ -134,7 +136,7 @@ inline auto wiener4_ccdf_grad_a(const T_y& y, const T_a& a, const T_v& v,
134136
prob_grad_a = ret_t(NEGATIVE_INFTY);
135137
}
136138
const auto log_prob_hit_upper = log_wiener_prob_hit_upper(a, v, w);
137-
const auto cdf_grad_a = wiener4_cdf_grad_a(y, a, v, w, cdf, err);
139+
const auto cdf_grad_a = wiener4_cdf_grad_a(y, a, v, w, cdf, log_err);
138140
return prob_grad_a * exp(log_prob_hit_upper) - cdf_grad_a;
139141
}
140142

@@ -146,14 +148,15 @@ inline auto wiener4_ccdf_grad_a(const T_y& y, const T_a& a, const T_v& v,
146148
* @param v The relative starting point
147149
* @param w The drift rate
148150
* @param cdf The CDF value
149-
* @param err The log error tolerance
151+
* @param log_err The log error tolerance in the computation of the number
152+
* of terms for the infinite sums
150153
* @return Gradient with respect to v
151154
*/
152155
template <typename T_y, typename T_a, typename T_w, typename T_v,
153156
typename T_cdf, typename T_err>
154157
inline auto wiener4_ccdf_grad_v(const T_y& y, const T_a& a, const T_v& v,
155158
const T_w& w, T_cdf&& cdf,
156-
T_err&& err = log(1e-12)) noexcept {
159+
T_err log_err = log(1e-12)) noexcept {
157160
using ret_t = return_type_t<T_a, T_w, T_v>;
158161
const auto log_prob_hit_upper = log_wiener_prob_hit_upper(a, v, w);
159162
// derivative of the wiener probability w.r.t. 'v' (on log-scale)
@@ -162,7 +165,7 @@ inline auto wiener4_ccdf_grad_v(const T_y& y, const T_a& a, const T_v& v,
162165
prob_grad_v = ret_t(NEGATIVE_INFTY);
163166
}
164167

165-
const auto cdf_grad_v = wiener4_cdf_grad_v(y, a, v, w, cdf, err);
168+
const auto cdf_grad_v = wiener4_cdf_grad_v(y, a, v, w, cdf, log_err);
166169
return prob_grad_v * exp(log_prob_hit_upper) - cdf_grad_v;
167170
}
168171

@@ -174,14 +177,15 @@ inline auto wiener4_ccdf_grad_v(const T_y& y, const T_a& a, const T_v& v,
174177
* @param v The relative starting point
175178
* @param w The drift rate
176179
* @param cdf The CDF value
177-
* @param err The log error tolerance
180+
* @param log_err The log error tolerance in the computation of the number
181+
* of terms for the infinite sums
178182
* @return Gradient with respect to w
179183
*/
180184
template <typename T_y, typename T_a, typename T_w, typename T_v,
181185
typename T_cdf, typename T_err>
182186
inline auto wiener4_ccdf_grad_w(const T_y& y, const T_a& a, const T_v& v,
183187
const T_w& w, T_cdf&& cdf,
184-
T_err&& err = log(1e-12)) noexcept {
188+
T_err log_err = log(1e-12)) noexcept {
185189
using ret_t = return_type_t<T_a, T_w, T_v>;
186190
const auto log_prob_hit_upper = log_wiener_prob_hit_upper(a, v, w);
187191
// derivative of the wiener probability w.r.t. 'v' (on log-scale)
@@ -193,7 +197,7 @@ inline auto wiener4_ccdf_grad_w(const T_y& y, const T_a& a, const T_v& v,
193197
prob_grad_w *= exp(exponent);
194198
}
195199

196-
const auto cdf_grad_w = wiener4_cdf_grad_w(y, a, v, w, cdf, err);
200+
const auto cdf_grad_w = wiener4_cdf_grad_w(y, a, v, w, cdf, log_err);
197201
return prob_grad_w * exp(log_prob_hit_upper) - cdf_grad_w;
198202
}
199203

@@ -238,11 +242,11 @@ inline auto wiener_lccdf(const T_y& y, const T_a& a, const T_t0& t0,
238242
T_w_ref w_ref = w;
239243
T_v_ref v_ref = v;
240244

241-
decltype(auto) y_val = to_ref(as_value_column_array_or_scalar(y_ref));
242-
decltype(auto) a_val = to_ref(as_value_column_array_or_scalar(a_ref));
243-
decltype(auto) v_val = to_ref(as_value_column_array_or_scalar(v_ref));
244-
decltype(auto) w_val = to_ref(as_value_column_array_or_scalar(w_ref));
245-
decltype(auto) t0_val = to_ref(as_value_column_array_or_scalar(t0_ref));
245+
auto y_val = to_ref(as_value_column_array_or_scalar(y_ref));
246+
auto a_val = to_ref(as_value_column_array_or_scalar(a_ref));
247+
auto v_val = to_ref(as_value_column_array_or_scalar(v_ref));
248+
auto w_val = to_ref(as_value_column_array_or_scalar(w_ref));
249+
auto t0_val = to_ref(as_value_column_array_or_scalar(t0_ref));
246250

247251
static constexpr const char* function_name = "wiener4_lccdf";
248252
if (size_zero(y, a, t0, w, v)) {

0 commit comments

Comments
 (0)