25#ifndef _gcem_incomplete_beta_inv_HPP
26#define _gcem_incomplete_beta_inv_HPP
36 const T direc,
const T lb_val,
const int iter_count)
noexcept;
50 return( p > T(0.5) ? \
63 return( t_val - ( T(2.515517) + T(0.802853)*t_val + T(0.010328)*t_val*t_val ) \
64 / ( T(1) + T(1.432788)*t_val + T(0.189269)*t_val*t_val + T(0.001308)*t_val*t_val*t_val ) );
73 return( T(1)/(2*alpha_par - T(1)) + T(1)/(2*beta_par - T(1)) );
82 return( T(1)/(2*beta_par - T(1)) - T(1)/(2*alpha_par - T(1)) );
91 return( T(2) / ab_term_1 );
101 return( value *
sqrt(h_term + (value*value - T(3))/T(6))/h_term \
102 - ab_term_2*((value*value - T(3))/T(6) + T(5)/T(6) - T(2)/(T(3)*h_term)) );
111 return( alpha_par / (alpha_par + beta_par*exp(2*w_term)) );
140 return(
pow(alpha_par/(alpha_par+beta_par),alpha_par) / alpha_par );
149 return(
pow(beta_par/(alpha_par+beta_par),beta_par) / beta_par );
158 return( p <= s_1/(s_1 + s_2) ?
pow(p*(s_1+s_2)*alpha_par,T(1)/alpha_par) :
159 T(1) -
pow(p*(s_1+s_2)*beta_par,T(1)/beta_par) );
170 return( (alpha_par > T(1) && beta_par > T(1)) ?
174 p < T(0.5) ? T(1) : T(-1) ) :
212 exp( (alpha_par - T(1))*
log(value) + (beta_par - T(1))*
log(T(1) - value) - lb_val ) );
221 return( deriv_1*((alpha_par - T(1))/value - (beta_par - T(1))/(T(1) - value)) );
248 return( ratio_val_1 /
max( T(0.8),
min( T(1.2), T(1) - T(0.5)*ratio_val_1*ratio_val_2 ) ) );
255 const T lb_val,
const int iter_count)
267 ), lb_val, iter_count) );
274 const T lb_val,
const int iter_count)
281 lb_val, iter_count+1) :
304 any_nan(alpha_par, beta_par, p) ? \
313 alpha_par,beta_par,p,
lbeta(alpha_par,beta_par)) );
316template<
typename T1,
typename T2,
typename T3,
typename TC = common_t<T1,T2,T3>>
346template<
typename T1,
typename T2,
typename T3>
#define GCEM_INCML_BETA_INV_MAX_ITER
Definition: gcem_options.hpp:169
constexpr T incomplete_beta_inv_begin(const T initial_val, const T alpha_par, const T beta_par, const T p, const T lb_val) noexcept
Definition: incomplete_beta_inv.hpp:289
constexpr T incomplete_beta_inv_initial_val_1_int_w(const T value, const T ab_term_2, const T h_term) noexcept
Definition: incomplete_beta_inv.hpp:97
constexpr T incomplete_beta_inv_initial_val_1_int_ab1(const T alpha_par, const T beta_par) noexcept
Definition: incomplete_beta_inv.hpp:70
constexpr T incomplete_beta_inv_recur(const T value, const T alpha_par, const T beta_par, const T p, const T deriv_1, const T lb_val, const int iter_count) noexcept
Definition: incomplete_beta_inv.hpp:254
constexpr T incomplete_beta_inv_check(const T alpha_par, const T beta_par, const T p) noexcept
Definition: incomplete_beta_inv.hpp:300
constexpr TC incomplete_beta_inv_type_check(const T1 a, const T2 b, const T3 p) noexcept
Definition: incomplete_beta_inv.hpp:319
constexpr T incomplete_beta_inv_initial_val_2_s1(const T alpha_par, const T beta_par) noexcept
Definition: incomplete_beta_inv.hpp:137
constexpr T incomplete_beta_inv_ratio_val_1(const T value, const T alpha_par, const T beta_par, const T p, const T deriv_1) noexcept
Definition: incomplete_beta_inv.hpp:227
constexpr T incomplete_beta_inv_initial_val_1_int_h(const T ab_term_1) noexcept
Definition: incomplete_beta_inv.hpp:88
constexpr T incomplete_beta_inv_initial_val_1_int_ab2(const T alpha_par, const T beta_par) noexcept
Definition: incomplete_beta_inv.hpp:79
constexpr T incomplete_beta_inv_ratio_val_2(const T value, const T alpha_par, const T beta_par, const T deriv_1) noexcept
Definition: incomplete_beta_inv.hpp:236
constexpr bool any_nan(const T1 x, const T2 y) noexcept
Definition: is_nan.hpp:48
constexpr T incomplete_beta_inv_initial_val_2_s2(const T alpha_par, const T beta_par) noexcept
Definition: incomplete_beta_inv.hpp:146
constexpr T incomplete_beta_inv_deriv_2(const T value, const T alpha_par, const T beta_par, const T deriv_1) noexcept
Definition: incomplete_beta_inv.hpp:218
constexpr T incomplete_beta_inv_err_val(const T value, const T alpha_par, const T beta_par, const T p) noexcept
Definition: incomplete_beta_inv.hpp:194
constexpr T incomplete_beta_inv_initial_val_1_tval(const T p) noexcept
Definition: incomplete_beta_inv.hpp:47
constexpr T incomplete_beta_inv_decision(const T value, const T alpha_par, const T beta_par, const T p, const T direc, const T lb_val, const int iter_count) noexcept
Definition: incomplete_beta_inv.hpp:273
constexpr T incomplete_beta_inv_initial_val_1_int_end(const T alpha_par, const T beta_par, const T w_term) noexcept
Definition: incomplete_beta_inv.hpp:108
constexpr T incomplete_beta_inv_deriv_1(const T value, const T alpha_par, const T beta_par, const T lb_val) noexcept
Definition: incomplete_beta_inv.hpp:203
constexpr T incomplete_beta_inv_initial_val_2(const T alpha_par, const T beta_par, const T p, const T s_1, const T s_2) noexcept
Definition: incomplete_beta_inv.hpp:155
constexpr T incomplete_beta_inv_initial_val_1(const T alpha_par, const T beta_par, const T t_val, const T sgn_term) noexcept
Definition: incomplete_beta_inv.hpp:117
constexpr T incomplete_beta_inv_halley(const T ratio_val_1, const T ratio_val_2) noexcept
Definition: incomplete_beta_inv.hpp:245
constexpr T incomplete_beta_inv_initial_val_1_int_begin(const T t_val) noexcept
Definition: incomplete_beta_inv.hpp:60
constexpr T incomplete_beta_inv_initial_val(const T alpha_par, const T beta_par, const T p) noexcept
Definition: incomplete_beta_inv.hpp:167
Definition: is_even.hpp:29
constexpr T abs(const T x) noexcept
Compile-time absolute value function.
Definition: abs.hpp:40
constexpr common_t< T1, T2, T3 > incomplete_beta_inv(const T1 a, const T2 b, const T3 p) noexcept
Compile-time inverse incomplete beta function.
Definition: incomplete_beta_inv.hpp:349
constexpr common_t< T1, T2 > max(const T1 x, const T2 y) noexcept
Compile-time pairwise maximum function.
Definition: max.hpp:41
constexpr common_return_t< T1, T2, T3 > incomplete_beta(const T1 a, const T2 b, const T3 z) noexcept
Compile-time regularized incomplete beta function.
Definition: incomplete_beta.hpp:191
constexpr return_t< T > log(const T x) noexcept
Compile-time natural logarithm function.
Definition: log.hpp:186
constexpr return_t< T > sqrt(const T x) noexcept
Compile-time square-root function.
Definition: sqrt.hpp:109
constexpr common_t< T1, T2 > pow(const T1 base, const T2 exp_term) noexcept
Compile-time power function.
Definition: pow.hpp:82
constexpr common_t< T1, T2 > min(const T1 x, const T2 y) noexcept
Compile-time pairwise minimum function.
Definition: min.hpp:41
std::numeric_limits< T > GCLIM
Definition: gcem_options.hpp:74
constexpr common_return_t< T1, T2 > lbeta(const T1 a, const T2 b) noexcept
Compile-time log-beta function.
Definition: lbeta.hpp:39