Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions test/prob/bernoulli/bernoulli_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,3 @@ class AgradDistributionsBernoulli : public AgradDistributionTest {
throw std::domain_error("n should either be 1 or 0");
}
};

TEST(ProbDistributionsBernoulliCDF, Values) {
EXPECT_FLOAT_EQ(1, stan::math::bernoulli_cdf(1, 0.57));
EXPECT_FLOAT_EQ(1 - 0.57, stan::math::bernoulli_cdf(0, 0.57));
}
5 changes: 0 additions & 5 deletions test/prob/beta_binomial/beta_binomial_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,3 @@ class AgradDistributionsBetaBinomial : public AgradDistributionTest {
- lbeta(alpha, beta);
}
};

TEST(ProbDistributionsBetaBinomialCDF, Values) {
EXPECT_FLOAT_EQ(0.8868204314,
stan::math::beta_binomial_cdf(49, 100, 1.349, 3.938));
}
15 changes: 0 additions & 15 deletions test/prob/binomial/binomial_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,3 @@ class AgradDistributionsBinomial : public AgradDistributionTest {
+ (N - n) * log1m(theta);
}
};

TEST(ProbDistributionsBinomialCDF, Values) {
EXPECT_FLOAT_EQ(0.042817421, stan::math::binomial_cdf(24, 54, 0.57));
EXPECT_FLOAT_EQ(1.0 - 0.57,
stan::math::binomial_cdf(
0, 1, 0.57)); // Consistency with expected Bernoulli
EXPECT_FLOAT_EQ(1.0, stan::math::binomial_cdf(
1, 1, 0.57)); // Consistency with expected Bernoulli
EXPECT_FLOAT_EQ(stan::math::bernoulli_cdf(0, 0.57),
stan::math::binomial_cdf(
0, 1, 0.57)); // Consistency with implemented Bernoulli
EXPECT_FLOAT_EQ(stan::math::bernoulli_cdf(1, 0.57),
stan::math::binomial_cdf(
1, 1, 0.57)); // Consistency with implemented Bernoulli
}
7 changes: 0 additions & 7 deletions test/prob/cauchy/cauchy_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,3 @@ class AgradDistributionsCauchy : public AgradDistributionTest {
return -stan::math::LOG_PI - log(sigma) - log1p(square((y - mu) / sigma));
}
};

TEST(ProbDistributionsCauchy, Cumulative) {
using stan::math::cauchy_cdf;
EXPECT_FLOAT_EQ(0.75, cauchy_cdf(1.0, 0.0, 1.0));
EXPECT_FLOAT_EQ(0.187167, cauchy_cdf(-1.5, 0.0, 1.0));
EXPECT_FLOAT_EQ(0.187167, cauchy_cdf(-2.5, -1.0, 1.0));
}
11 changes: 0 additions & 11 deletions test/prob/double_exponential/double_exponential_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,3 @@ class AgradDistributionsDoubleExponential : public AgradDistributionTest {
return -LOG_TWO - log(sigma) - fabs(y - mu) / sigma;
}
};

TEST(ProbDistributionsDoubleExponential, Cumulative) {
EXPECT_FLOAT_EQ(0.5, stan::math::double_exponential_cdf(1.0, 1.0, 1.0));
EXPECT_FLOAT_EQ(0.8160603, stan::math::double_exponential_cdf(2.0, 1.0, 1.0));
EXPECT_FLOAT_EQ(0.003368973,
stan::math::double_exponential_cdf(-3.0, 2.0, 1.0));
EXPECT_FLOAT_EQ(0.6967347, stan::math::double_exponential_cdf(1.0, 0.0, 2.0));
EXPECT_FLOAT_EQ(0.2246645, stan::math::double_exponential_cdf(1.9, 2.3, 0.5));
EXPECT_FLOAT_EQ(0.10094826,
stan::math::double_exponential_cdf(1.9, 2.3, 0.25));
}
16 changes: 0 additions & 16 deletions test/prob/exponential/exponential_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,3 @@ class AgradDistributionsExponential : public AgradDistributionTest {
return log(beta) - beta * y;
}
};

TEST(ProbDistributionsExponential, Cumulative) {
using stan::math::exponential_cdf;
using std::numeric_limits;
EXPECT_FLOAT_EQ(0.95021293, exponential_cdf(2.0, 1.5));
EXPECT_FLOAT_EQ(1.0, exponential_cdf(15.0, 3.9));
EXPECT_FLOAT_EQ(0.62280765, exponential_cdf(0.25, 3.9));

// ??
// EXPECT_FLOAT_EQ(0.0,
// exponential_cdf(-numeric_limits<double>::infinity(),
// 1.5));
EXPECT_FLOAT_EQ(0.0, exponential_cdf(0.0, 1.5));
EXPECT_FLOAT_EQ(1.0,
exponential_cdf(numeric_limits<double>::infinity(), 1.5));
}
11 changes: 0 additions & 11 deletions test/prob/frechet/frechet_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,3 @@ class AgradDistributionsFrechet : public AgradDistributionTest {
- pow(sigma / y, alpha);
}
};

TEST(ProbDistributionsFrechet, Cumulative) {
using stan::math::frechet_cdf;
using std::numeric_limits;
EXPECT_FLOAT_EQ(0.6065306597, frechet_cdf(2.0, 1.0, 1.0));
EXPECT_FLOAT_EQ(2.744338423e-5, frechet_cdf(0.8, 2.9, 1.8));
EXPECT_FLOAT_EQ(0.0, frechet_cdf(0.25, 3.9, 1.7));

EXPECT_FLOAT_EQ(1.0,
frechet_cdf(numeric_limits<double>::infinity(), 1.0, 1.0));
}
4 changes: 0 additions & 4 deletions test/prob/inv_gamma/inv_gamma_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,3 @@ class AgradDistributionsInvGamma : public AgradDistributionTest {
- beta / y;
}
};

TEST(ProbDistributionsInvGammaCdf, Values) {
EXPECT_FLOAT_EQ(0.557873, stan::math::inv_gamma_cdf(4.39, 1.349, 3.938));
}
4 changes: 0 additions & 4 deletions test/prob/logistic/logistic_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,3 @@ class AgradDistributionsLogistic : public AgradDistributionTest {
return -(y - mu) / sigma - log(sigma) - 2.0 * log1p(exp(-(y - mu) / sigma));
}
};

TEST(ProbDistributionsLogisticCDF, Values) {
EXPECT_FLOAT_EQ(0.047191944, stan::math::logistic_cdf(-3.45, 5.235, 2.89));
}
2 changes: 1 addition & 1 deletion test/prob/loglogistic/loglogistic_cdf_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using stan::math::var;
using std::numeric_limits;
using std::vector;

class AgradCdfLogistic : public AgradCdfTest {
class AgradCdfLoglogistic : public AgradCdfTest {
public:
void valid_values(vector<vector<double> >& parameters, vector<double>& cdf) {
vector<double> param(3);
Expand Down
14 changes: 0 additions & 14 deletions test/prob/lognormal/lognormal_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,3 @@ class AgradDistributionsLognormal : public AgradDistributionTest {
- square(log(y) - mu) / (2.0 * sigma * sigma);
}
};

TEST(ProbDistributionsLognormal, Cumulative) {
using stan::math::lognormal_cdf;
EXPECT_FLOAT_EQ(0.4687341, lognormal_cdf(1.2, 0.3, 1.5));
EXPECT_FLOAT_EQ(0.2835506, lognormal_cdf(12.0, 3.0, 0.9));

double pos_inf = std::numeric_limits<double>::infinity();

// ?? double neg_inf = -pos_inf;
// ?? EXPECT_FLOAT_EQ(0.0, lognormal_cdf(neg_inf, 0.0, 1.0));

EXPECT_FLOAT_EQ(0.0, lognormal_cdf(0.0, 0.0, 1.0));
EXPECT_FLOAT_EQ(1.0, lognormal_cdf(pos_inf, 0.0, 1.0));
}
2 changes: 1 addition & 1 deletion test/prob/neg_binomial_2/neg_binomial_2_ccdf_log_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using stan::math::var;
using std::numeric_limits;
using std::vector;

class AgradCdfLogNegBinomial2 : public AgradCcdfLogTest {
class AgradCcdfLogNegBinomial2 : public AgradCcdfLogTest {
public:
void valid_values(vector<vector<double> >& parameters,
vector<double>& ccdf_log) {
Expand Down
4 changes: 0 additions & 4 deletions test/prob/pareto/pareto_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,3 @@ class AgradDistributionsPareto : public AgradDistributionTest {
return log(alpha) + lmultiply(alpha, y_min) - lmultiply(alpha + 1.0, y);
}
};

TEST(ProbDistributionsParetoCDF, Values) {
EXPECT_FLOAT_EQ(0.60434447, stan::math::pareto_cdf(3.45, 2.89, 5.235));
}
2 changes: 1 addition & 1 deletion test/prob/poisson/poisson_log_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using stan::math::var;
using std::numeric_limits;
using std::vector;

class AgradDistributionsPoisson : public AgradDistributionTest {
class AgradDistributionsPoissonLog : public AgradDistributionTest {
public:
void valid_values(vector<vector<double> >& parameters,
vector<double>& log_prob) {
Expand Down
2 changes: 1 addition & 1 deletion test/prob/std_normal/std_normal_cdf_log_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using stan::math::square;
using std::numeric_limits;
using std::vector;

class AgradCdfLogNormal : public AgradCdfLogTest {
class AgradCdfLogStdNormal : public AgradCdfLogTest {
public:
void valid_values(vector<vector<double> >& parameters,
vector<double>& cdf_log) {
Expand Down
55 changes: 29 additions & 26 deletions test/prob/utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct is_empty<empty> {
// ------------------------------------------------------------

namespace std {
std::ostream& operator<<(std::ostream& os, const vector<double>& param) {
inline std::ostream& operator<<(std::ostream& os, const vector<double>& param) {
os << "(";
for (size_t n = 0; n < param.size(); n++) {
os << param[n];
Expand All @@ -40,7 +40,7 @@ std::ostream& operator<<(std::ostream& os, const vector<double>& param) {
return os;
}

std::ostream& operator<<(std::ostream& os, const vector<var>& param) {
inline std::ostream& operator<<(std::ostream& os, const vector<var>& param) {
os << "(";
for (size_t n = 0; n < param.size(); n++) {
os << param[n];
Expand All @@ -64,7 +64,8 @@ inline T get_param(const vector<double>& params, const size_t n) {
}

template <>
empty get_param<empty>(const vector<double>& /*params*/, const size_t /*n*/) {
inline empty get_param<empty>(const vector<double>& /*params*/,
const size_t /*n*/) {
return empty();
}

Expand Down Expand Up @@ -133,8 +134,8 @@ inline T get_params(const vector<vector<double>>& parameters, const size_t p) {

// handle empty
template <>
empty get_params<empty>(const vector<vector<double>>& /*parameters*/,
const size_t /*p*/) {
inline empty get_params<empty>(const vector<vector<double>>& /*parameters*/,
const size_t /*p*/) {
return empty();
}
// handle scalars
Expand Down Expand Up @@ -175,7 +176,7 @@ inline fvar<var> get_params<fvar<var>>(const vector<vector<double>>& parameters,
return param;
}
template <>
fvar<fvar<double>> get_params<fvar<fvar<double>>>(
inline fvar<fvar<double>> get_params<fvar<fvar<double>>>(
const vector<vector<double>>& parameters, const size_t p) {
fvar<fvar<double>> param(0);
if (p < parameters[0].size()) {
Expand All @@ -185,7 +186,7 @@ fvar<fvar<double>> get_params<fvar<fvar<double>>>(
return param;
}
template <>
fvar<fvar<var>> get_params<fvar<fvar<var>>>(
inline fvar<fvar<var>> get_params<fvar<fvar<var>>>(
const vector<vector<double>>& parameters, const size_t p) {
fvar<fvar<var>> param(0);
if (p < parameters[0].size()) {
Expand All @@ -195,7 +196,8 @@ fvar<fvar<var>> get_params<fvar<fvar<var>>>(
return param;
}
template <>
int get_params<int>(const vector<vector<double>>& parameters, const size_t p) {
inline int get_params<int>(const vector<vector<double>>& parameters,
const size_t p) {
int param(0);
if (p < parameters[0].size())
param = (int)parameters[0][p];
Expand All @@ -212,7 +214,7 @@ inline vector<int> get_params<vector<int>>(
return param;
}
template <>
vector<double> get_params<vector<double>>(
inline vector<double> get_params<vector<double>>(
const vector<vector<double>>& parameters, const size_t p) {
vector<double> param(parameters.size());
for (size_t n = 0; n < parameters.size(); n++)
Expand All @@ -230,7 +232,7 @@ inline vector<var> get_params<vector<var>>(
return param;
}
template <>
vector<fvar<double>> get_params<vector<fvar<double>>>(
inline vector<fvar<double>> get_params<vector<fvar<double>>>(
const vector<vector<double>>& parameters, const size_t p) {
vector<fvar<double>> param(parameters.size());
for (size_t n = 0; n < parameters.size(); n++)
Expand All @@ -241,7 +243,7 @@ vector<fvar<double>> get_params<vector<fvar<double>>>(
return param;
}
template <>
vector<fvar<var>> get_params<vector<fvar<var>>>(
inline vector<fvar<var>> get_params<vector<fvar<var>>>(
const vector<vector<double>>& parameters, const size_t p) {
vector<fvar<var>> param(parameters.size());
for (size_t n = 0; n < parameters.size(); n++)
Expand All @@ -252,7 +254,7 @@ vector<fvar<var>> get_params<vector<fvar<var>>>(
return param;
}
template <>
vector<fvar<fvar<double>>> get_params<vector<fvar<fvar<double>>>>(
inline vector<fvar<fvar<double>>> get_params<vector<fvar<fvar<double>>>>(
const vector<vector<double>>& parameters, const size_t p) {
vector<fvar<fvar<double>>> param(parameters.size());
for (size_t n = 0; n < parameters.size(); n++)
Expand All @@ -263,7 +265,7 @@ vector<fvar<fvar<double>>> get_params<vector<fvar<fvar<double>>>>(
return param;
}
template <>
vector<fvar<fvar<var>>> get_params<vector<fvar<fvar<var>>>>(
inline vector<fvar<fvar<var>>> get_params<vector<fvar<fvar<var>>>>(
const vector<vector<double>>& parameters, const size_t p) {
vector<fvar<fvar<var>>> param(parameters.size());
for (size_t n = 0; n < parameters.size(); n++)
Expand Down Expand Up @@ -300,8 +302,8 @@ inline T get_params(const vector<vector<double>>& parameters,

// handle empty
template <>
empty get_params<empty>(const vector<vector<double>>& /*parameters*/,
const size_t /*n*/, const size_t /*p*/) {
inline empty get_params<empty>(const vector<vector<double>>& /*parameters*/,
const size_t /*n*/, const size_t /*p*/) {
return empty();
}
// handle scalars
Expand Down Expand Up @@ -342,7 +344,7 @@ inline fvar<var> get_params<fvar<var>>(const vector<vector<double>>& parameters,
return param;
}
template <>
fvar<fvar<double>> get_params<fvar<fvar<double>>>(
inline fvar<fvar<double>> get_params<fvar<fvar<double>>>(
const vector<vector<double>>& parameters, const size_t n, const size_t p) {
fvar<fvar<double>> param(0);
if (p < parameters[0].size()) {
Expand All @@ -352,7 +354,7 @@ fvar<fvar<double>> get_params<fvar<fvar<double>>>(
return param;
}
template <>
fvar<fvar<var>> get_params<fvar<fvar<var>>>(
inline fvar<fvar<var>> get_params<fvar<fvar<var>>>(
const vector<vector<double>>& parameters, const size_t n, const size_t p) {
fvar<fvar<var>> param(0);
if (p < parameters[0].size()) {
Expand All @@ -362,8 +364,8 @@ fvar<fvar<var>> get_params<fvar<fvar<var>>>(
return param;
}
template <>
int get_params<int>(const vector<vector<double>>& parameters, const size_t n,
const size_t p) {
inline int get_params<int>(const vector<vector<double>>& parameters,
const size_t n, const size_t p) {
int param(0);
if (p < parameters[0].size())
param = (int)parameters[n][p];
Expand All @@ -381,7 +383,7 @@ inline vector<int> get_params<vector<int>>(
return param;
}
template <>
vector<double> get_params<vector<double>>(
inline vector<double> get_params<vector<double>>(
const vector<vector<double>>& parameters, const size_t /*n*/,
const size_t p) {
vector<double> param(parameters.size());
Expand All @@ -401,7 +403,7 @@ inline vector<var> get_params<vector<var>>(
return param;
}
template <>
vector<fvar<double>> get_params<vector<fvar<double>>>(
inline vector<fvar<double>> get_params<vector<fvar<double>>>(
const vector<vector<double>>& parameters, const size_t /*n*/,
const size_t p) {
vector<fvar<double>> param(parameters.size());
Expand All @@ -413,7 +415,7 @@ vector<fvar<double>> get_params<vector<fvar<double>>>(
return param;
}
template <>
vector<fvar<var>> get_params<vector<fvar<var>>>(
inline vector<fvar<var>> get_params<vector<fvar<var>>>(
const vector<vector<double>>& parameters, const size_t /*n*/,
const size_t p) {
vector<fvar<var>> param(parameters.size());
Expand All @@ -425,7 +427,7 @@ vector<fvar<var>> get_params<vector<fvar<var>>>(
return param;
}
template <>
vector<fvar<fvar<double>>> get_params<vector<fvar<fvar<double>>>>(
inline vector<fvar<fvar<double>>> get_params<vector<fvar<fvar<double>>>>(
const vector<vector<double>>& parameters, const size_t /*n*/,
const size_t p) {
vector<fvar<fvar<double>>> param(parameters.size());
Expand All @@ -437,7 +439,7 @@ vector<fvar<fvar<double>>> get_params<vector<fvar<fvar<double>>>>(
return param;
}
template <>
vector<fvar<fvar<var>>> get_params<vector<fvar<fvar<var>>>>(
inline vector<fvar<fvar<var>>> get_params<vector<fvar<fvar<var>>>>(
const vector<vector<double>>& parameters, const size_t /*n*/,
const size_t p) {
vector<fvar<fvar<var>>> param(parameters.size());
Expand Down Expand Up @@ -541,8 +543,9 @@ typename scalar_type<T>::type select_var_param(
}

template <>
empty select_var_param<empty>(const vector<vector<double>>& /*parameters*/,
const size_t /*n*/, const size_t /*p*/) {
inline empty select_var_param<empty>(
const vector<vector<double>>& /*parameters*/, const size_t /*n*/,
const size_t /*p*/) {
return empty();
}

Expand Down
Loading
Loading