Helpful Stan Functions
Student T distribution functions

Functions

real student_t_lcdf_stan (real x, real df)
 
real student_t_lccdf_stan (real x, real df)
 

Detailed Description

real student_t_lcdf_stan(real x, real df) {
int lower_tail = 1;
real lval;
if (df <= 0) {
reject("df must be > 0. Found df = ", df);
}
if (is_inf(x)) {
return not_a_number();
}
if (is_inf(df))
return normal_lcdf(x | 0, 1);
real nx = 1 + (x / df) * x;
if (nx > 1e100)
lval = -0.5 * df * (2 * log(abs(x)) - log(df)) - lbeta(0.5 * df, 0.5) - log(0.5 * df);
else
lval = df > x * x ? beta_lccdf(x * x / (df + x * x) | 0.5, df / 2)
: beta_lcdf(1 / nx | df / 2, 0.5);
if (x <= 0) {
lower_tail = 0;
}
if (lower_tail == 1) {
return log1m(0.5 * exp(lval));
} else {
return lval - log2();
}
return lval;
}
real student_t_lccdf_stan(real x, real df) {
real lval;
if (df <= 0) {
reject("df must be > 0. Found df = ", df);
}
if (is_inf(x)) {
return not_a_number();
}
if (is_inf(df))
return normal_lccdf(x | 0, 1);
real nx = 1 + (x / df) * x;
if (nx > 1e100)
lval = -0.5 * df * (2 * log(abs(x)) - log(df)) - lbeta(0.5 * df, 0.5) - log(0.5 * df);
else
lval = df > x * x ? beta_lccdf(x * x / (df + x * x) | 0.5, df / 2)
: beta_lcdf(1 / nx | df / 2, 0.5);
return x < 0 ? log1m(0.5 * exp(lval)) : lval - log2();
}
real student_t_lccdf_stan(real x, real df)
Definition: student_t.stanfunctions:60
real student_t_lcdf_stan(real x, real df)
Definition: student_t.stanfunctions:17

Function Documentation

◆ student_t_lccdf_stan()

real student_t_lccdf_stan ( real  x,
real  df 
)

Student T Log Complementary Cumulative Distribution Function

The in-built Stan function shows poor numerical precision.

Parameters
xReal \(\in (0, \infty)\) scale parameter
dfReal \(-1 < \lambda < 1\)
Exceptions
rejectif \( df \leq 0 \)
Returns
log probability

◆ student_t_lcdf_stan()

real student_t_lcdf_stan ( real  x,
real  df 
)

Student T Log Cumulative Distribution Function

The in-built Stan function shows poor numerical precision.

Parameters
xReal \(\in (0, \infty)\) scale parameter
dfReal \(-1 < \lambda < 1\)
Exceptions
rejectif \( df \leq 0 \)
Returns
log probability