Skip to content

Commit

Permalink
Update RNG tests to use mixmax RNG
Browse files Browse the repository at this point in the history
  • Loading branch information
andrjohns committed May 17, 2024
1 parent 814d915 commit 0379951
Show file tree
Hide file tree
Showing 71 changed files with 228 additions and 228 deletions.
8 changes: 4 additions & 4 deletions test/unit/math/fwd/prob/lkj_corr_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

TEST(ProbDistributionsLkjCorr, fvar_double) {
using stan::math::fvar;
boost::random::mt19937 rng;
boost::random::mixmax rng;
int K = 4;
Eigen::Matrix<fvar<double>, Eigen::Dynamic, Eigen::Dynamic> Sigma(K, K);
Sigma.setZero();
Expand All @@ -24,7 +24,7 @@ TEST(ProbDistributionsLkjCorr, fvar_double) {

TEST(ProbDistributionsLkjCorrCholesky, fvar_double) {
using stan::math::fvar;
boost::random::mt19937 rng;
boost::random::mixmax rng;
int K = 4;
Eigen::Matrix<fvar<double>, Eigen::Dynamic, Eigen::Dynamic> Sigma(K, K);
Sigma.setZero();
Expand All @@ -43,7 +43,7 @@ TEST(ProbDistributionsLkjCorrCholesky, fvar_double) {

TEST(ProbDistributionsLkjCorr, fvar_fvar_double) {
using stan::math::fvar;
boost::random::mt19937 rng;
boost::random::mixmax rng;
int K = 4;
Eigen::Matrix<fvar<fvar<double> >, Eigen::Dynamic, Eigen::Dynamic> Sigma(K,
K);
Expand All @@ -63,7 +63,7 @@ TEST(ProbDistributionsLkjCorr, fvar_fvar_double) {

TEST(ProbDistributionsLkjCorrCholesky, fvar_fvar_double) {
using stan::math::fvar;
boost::random::mt19937 rng;
boost::random::mixmax rng;
int K = 4;
Eigen::Matrix<fvar<fvar<double> >, Eigen::Dynamic, Eigen::Dynamic> Sigma(K,
K);
Expand Down
8 changes: 4 additions & 4 deletions test/unit/math/mix/prob/lkj_corr_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
TEST(ProbDistributionsLkjCorr, fvar_var) {
using stan::math::fvar;
using stan::math::var;
boost::random::mt19937 rng;
boost::random::mixmax rng;
int K = 4;
Eigen::Matrix<fvar<var>, Eigen::Dynamic, Eigen::Dynamic> Sigma(K, K);
Sigma.setZero();
Expand All @@ -31,7 +31,7 @@ TEST(ProbDistributionsLkjCorr, fvar_var) {
TEST(ProbDistributionsLkjCorrCholesky, fvar_var) {
using stan::math::fvar;
using stan::math::var;
boost::random::mt19937 rng;
boost::random::mixmax rng;
int K = 4;
Eigen::Matrix<fvar<var>, Eigen::Dynamic, Eigen::Dynamic> Sigma(K, K);
Sigma.setZero();
Expand All @@ -54,7 +54,7 @@ TEST(ProbDistributionsLkjCorrCholesky, fvar_var) {
TEST(ProbDistributionsLkjCorr, fvar_fvar_var) {
using stan::math::fvar;
using stan::math::var;
boost::random::mt19937 rng;
boost::random::mixmax rng;
int K = 4;
Eigen::Matrix<fvar<fvar<var> >, Eigen::Dynamic, Eigen::Dynamic> Sigma(K, K);
Sigma.setZero();
Expand All @@ -78,7 +78,7 @@ TEST(ProbDistributionsLkjCorr, fvar_fvar_var) {
TEST(ProbDistributionsLkjCorrCholesky, fvar_fvar_var) {
using stan::math::fvar;
using stan::math::var;
boost::random::mt19937 rng;
boost::random::mixmax rng;
int K = 4;
Eigen::Matrix<fvar<fvar<var> >, Eigen::Dynamic, Eigen::Dynamic> Sigma(K, K);
Sigma.setZero();
Expand Down
2 changes: 1 addition & 1 deletion test/unit/math/opencl/multiply_transpose_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <boost/random/mersenne_twister.hpp>
#include <gtest/gtest.h>
#include <algorithm>
boost::random::mt19937 rng;
boost::random::mixmax rng;

TEST(MathMatrixOpenCL, multiply_transpose_exception_fail_zero) {
stan::math::row_vector_d rv(0);
Expand Down
4 changes: 2 additions & 2 deletions test/unit/math/opencl/prim/mdivide_left_tri_low_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ TEST(MathMatrixCL, mdivide_left_tri_low_cl_exception) {
}

void mdivide_left_tri_low_Ab_test(int size) {
boost::random::mt19937 rng;
boost::random::mixmax rng;
auto m1 = stan::math::matrix_d(size, size);
for (int i = 0; i < size; i++) {
for (int j = 0; j < i; j++) {
Expand Down Expand Up @@ -57,7 +57,7 @@ void mdivide_left_tri_low_Ab_test(int size) {
}

void mdivide_left_tri_low_A_test(int size) {
boost::random::mt19937 rng;
boost::random::mixmax rng;
auto m1 = stan::math::matrix_d(size, size);
for (int i = 0; i < size; i++) {
for (int j = 0; j < i; j++) {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/math/opencl/prim/mdivide_right_tri_low_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ TEST(MathMatrixCL, mdivide_right_tri_low_cl_exception) {
}

void mdivide_right_tri_low_Ab_test(int size) {
boost::random::mt19937 rng;
boost::random::mixmax rng;
auto m1 = stan::math::matrix_d(size, size);
for (int i = 0; i < size; i++) {
for (int j = 0; j < i; j++) {
Expand Down
4 changes: 2 additions & 2 deletions test/unit/math/opencl/tri_inverse_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ TEST(MathMatrixCL, inverse_cl_exception) {
}

void lower_inverse_test(int size) {
boost::random::mt19937 rng;
boost::random::mixmax rng;
auto m1 = stan::math::matrix_d(size, size);
for (int i = 0; i < size; i++) {
for (int j = 0; j < i; j++) {
Expand Down Expand Up @@ -56,7 +56,7 @@ void lower_inverse_test(int size) {
}

void upper_inverse_test(int size) {
boost::random::mt19937 rng;
boost::random::mixmax rng;
auto m1 = stan::math::matrix_d(size, size);
for (int i = 0; i < size; i++) {
for (int j = 0; j < i; j++) {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/math/prim/fun/chol2inv_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ TEST(MathMatrixPrimMat, chol2inv) {
using stan::math::matrix_d;
using stan::math::wishart_rng;

boost::random::mt19937 rng;
boost::random::mixmax rng;
matrix_d I(3, 3);
I.setZero();
I.diagonal().setOnes();
Expand Down
6 changes: 3 additions & 3 deletions test/unit/math/prim/prob/bernoulli_logit_glm_rng_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
TEST(ProbDistributionsBernoulliLogitGlm, vectorized) {
using stan::math::bernoulli_logit_glm_rng;
// Test scalar/vector combinations.
boost::random::mt19937 rng;
boost::random::mixmax rng;

Eigen::MatrixXd x(2, 3);
x << 3.5, -1.5, 0.0, 2.0, 1.0, 3.0;
Expand Down Expand Up @@ -70,7 +70,7 @@ TEST(ProbDistributionsBernoulliLogitGlm, vectorized) {
TEST(ProbDistributionsBernoulliLogitGlm, errorCheck) {
using stan::math::bernoulli_logit_glm_rng;
// Check errors for nonfinite and wrong sizes.
boost::random::mt19937 rng;
boost::random::mixmax rng;

int N = 3;
int M = 2;
Expand Down Expand Up @@ -107,7 +107,7 @@ TEST(ProbDistributionsBernoulliLogitGlm, errorCheck) {
TEST(ProbDistributionsBernoulliLogitGlm, marginalChiSquareGoodnessFitTest) {
using stan::math::bernoulli_logit_glm_rng;
// Check distribution of result.
boost::random::mt19937 rng;
boost::random::mixmax rng;
Eigen::MatrixXd x(2, 2);
x << 3.5, -1.5, 2.0, -1.2;
std::vector<double> alpha{2.0, 1.0};
Expand Down
4 changes: 2 additions & 2 deletions test/unit/math/prim/prob/bernoulli_logit_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ TEST(ProbDistributionsBernoulliLogit, distributionCheck) {
}

TEST(ProbDistributionsBernoulliLogit, error_check) {
boost::random::mt19937 rng;
boost::random::mixmax rng;

EXPECT_NO_THROW(stan::math::bernoulli_logit_rng(-3.5, rng));
EXPECT_THROW(
Expand All @@ -44,7 +44,7 @@ TEST(ProbDistributionsBernoulliLogit, error_check) {
}

TEST(ProbDistributionsBernoulliLogit, logitChiSquareGoodnessFitTest) {
boost::random::mt19937 rng;
boost::random::mixmax rng;
// number of samples
int N = 10000;

Expand Down
4 changes: 2 additions & 2 deletions test/unit/math/prim/prob/bernoulli_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ TEST(ProbDistributionsBernoulli, distributionCheck) {
}

TEST(ProbDistributionsBernoulli, error_check) {
boost::random::mt19937 rng;
boost::random::mixmax rng;
EXPECT_NO_THROW(stan::math::bernoulli_rng(0.6, rng));

EXPECT_THROW(stan::math::bernoulli_rng(1.6, rng), std::domain_error);
Expand All @@ -45,7 +45,7 @@ TEST(ProbDistributionsBernoulli, error_check) {
}

TEST(ProbDistributionsBernoulli, chiSquareGoodnessFitTest) {
boost::random::mt19937 rng;
boost::random::mixmax rng;
int N = 10000;

std::vector<double> expected;
Expand Down
2 changes: 1 addition & 1 deletion test/unit/math/prim/prob/beta_binomial_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ TEST(ProbDistributionsBetaBinomial, distributionCheck) {
}

TEST(ProbDistributionBetaBinomial, error_check) {
boost::random::mt19937 rng;
boost::random::mixmax rng;
EXPECT_NO_THROW(stan::math::beta_binomial_rng(4, 0.6, 2.0, rng));

EXPECT_THROW(stan::math::beta_binomial_rng(-4, 0.6, 2, rng),
Expand Down
6 changes: 3 additions & 3 deletions test/unit/math/prim/prob/beta_proportion_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ TEST(ProbDistributionsBetaProportion, distributionTest) {
}

TEST(ProbDistributionsBetaProportion, error_check) {
boost::random::mt19937 rng;
boost::random::mixmax rng;
EXPECT_NO_THROW(stan::math::beta_proportion_rng(0.5, 3.0, rng));
EXPECT_NO_THROW(stan::math::beta_proportion_rng(1e-10, 1e-10, rng));
EXPECT_THROW(stan::math::beta_proportion_rng(2.0, -1.0, rng),
Expand All @@ -68,7 +68,7 @@ TEST(ProbDistributionsBetaProportion, error_check) {
}

TEST(ProbDistributionsBetaProportion, chiSquareGoodnessFitTest) {
boost::random::mt19937 rng;
boost::random::mixmax rng;
int N = 10000;
int K = stan::math::round(2 * std::pow(N, 0.4));

Expand Down Expand Up @@ -99,7 +99,7 @@ TEST(ProbDistributionsBetaProportion, chiSquareGoodnessFitTest) {
}

TEST(ProbDistributionsBetaProportion, chiSquareGoodnessFitTest2) {
boost::random::mt19937 rng;
boost::random::mixmax rng;
int N = 10000;
int K = stan::math::round(2 * std::pow(N, 0.4));

Expand Down
6 changes: 3 additions & 3 deletions test/unit/math/prim/prob/beta_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ TEST(ProbDistributionsBeta, distributionTest) {
}

TEST(ProbDistributionsBeta, error_check) {
boost::random::mt19937 rng;
boost::random::mixmax rng;
EXPECT_NO_THROW(stan::math::beta_rng(2.0, 1.0, rng));
EXPECT_NO_THROW(stan::math::beta_rng(1e-10, 1e-10, rng));

Expand All @@ -60,7 +60,7 @@ TEST(ProbDistributionsBeta, error_check) {
}

TEST(ProbDistributionsBeta, chiSquareGoodnessFitTest) {
boost::random::mt19937 rng;
boost::random::mixmax rng;
int N = 10000;
int K = stan::math::round(2 * std::pow(N, 0.4));

Expand All @@ -83,7 +83,7 @@ TEST(ProbDistributionsBeta, chiSquareGoodnessFitTest) {
}

TEST(ProbDistributionsBeta, chiSquareGoodnessFitTestSmallParameters) {
boost::random::mt19937 rng;
boost::random::mixmax rng;
int N = 10000;
int K = stan::math::round(2 * std::pow(N, 0.4));

Expand Down
4 changes: 2 additions & 2 deletions test/unit/math/prim/prob/binomial_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ TEST(ProbDistributionsBinomial, distributionCheck) {
}

TEST(ProbDistributionBinomiali, error_check) {
boost::random::mt19937 rng;
boost::random::mixmax rng;
EXPECT_NO_THROW(stan::math::binomial_rng(4, 0.6, rng));
EXPECT_THROW(stan::math::binomial_rng(-4, 0.6, rng), std::domain_error);
EXPECT_THROW(stan::math::binomial_rng(4, -0.6, rng), std::domain_error);
Expand All @@ -50,7 +50,7 @@ TEST(ProbDistributionBinomiali, error_check) {
}

TEST(ProbDistributionsBinomial, chiSquareGoodnessFitTest) {
boost::random::mt19937 rng;
boost::random::mixmax rng;
int N = 10000;
int K = stan::math::round(2 * std::pow(N, 0.4));
boost::math::binomial_distribution<> dist(100, 0.6);
Expand Down
4 changes: 2 additions & 2 deletions test/unit/math/prim/prob/categorical_logit_rng_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
TEST(ProbDistributionsCategoricalLogit, error_check) {
using Eigen::VectorXd;
using stan::math::categorical_logit_rng;
boost::random::mt19937 rng;
boost::random::mixmax rng;

VectorXd beta(3);

Expand All @@ -27,7 +27,7 @@ TEST(ProbDistributionsCategoricalLogit, error_check) {
TEST(ProbDistributionsCategoricalLogit, chiSquareGoodnessFitTest) {
using Eigen::VectorXd;
using stan::math::softmax;
boost::random::mt19937 rng;
boost::random::mixmax rng;
int N = 10000;
int K = 3;
VectorXd beta(K);
Expand Down
4 changes: 2 additions & 2 deletions test/unit/math/prim/prob/categorical_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ TEST(ProbDistributionsCategorical, error_check) {
using Eigen::Dynamic;
using Eigen::Matrix;
using stan::math::categorical_log;
boost::random::mt19937 rng;
boost::random::mixmax rng;

Matrix<double, Dynamic, Dynamic> theta(3, 1);
theta << 0.15, 0.45, 0.50;
Expand All @@ -100,7 +100,7 @@ TEST(ProbDistributionsCategorical, chiSquareGoodnessFitTest) {
using Eigen::Dynamic;
using Eigen::Matrix;
using stan::math::categorical_log;
boost::random::mt19937 rng;
boost::random::mixmax rng;

int N = 10000;
Matrix<double, Dynamic, Dynamic> theta(3, 1);
Expand Down
4 changes: 2 additions & 2 deletions test/unit/math/prim/prob/cauchy_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ TEST(ProbDistributionsCauchy, distributionTest) {
}

TEST(ProbDistributionsCauchy, error_check) {
boost::random::mt19937 rng;
boost::random::mixmax rng;
EXPECT_NO_THROW(stan::math::cauchy_rng(2.0, 1.0, rng));

EXPECT_THROW(stan::math::cauchy_rng(2.0, -1.0, rng), std::domain_error);
Expand All @@ -59,7 +59,7 @@ TEST(ProbDistributionsCauchy, error_check) {
}

TEST(ProbDistributionsCauchy, chiSquareGoodnessFitTest) {
boost::random::mt19937 rng;
boost::random::mixmax rng;
int N = 10000;
int K = stan::math::round(2 * std::pow(N, 0.4));

Expand Down
4 changes: 2 additions & 2 deletions test/unit/math/prim/prob/chi_square_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ TEST(ProbDistributionsChiSquare, distributionTest) {
}

TEST(ProbDistributionsChiSquare, error_check) {
boost::random::mt19937 rng;
boost::random::mixmax rng;
EXPECT_NO_THROW(stan::math::chi_square_rng(2.0, rng));

EXPECT_THROW(stan::math::chi_square_rng(-2.0, rng), std::domain_error);
Expand All @@ -51,7 +51,7 @@ TEST(ProbDistributionsChiSquare, error_check) {
}

TEST(ProbDistributionsChiSquare, chiSquareGoodnessFitTest) {
boost::random::mt19937 rng;
boost::random::mixmax rng;
int N = 10000;
int K = stan::math::round(2 * std::pow(N, 0.4));

Expand Down
8 changes: 4 additions & 4 deletions test/unit/math/prim/prob/dirichlet_multinomial_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ TEST(ProbDistributionsDirichletMultinomial, zeros) {
TEST(ProbDistributionsDirichletMultinomial, rng) {
using Eigen::Dynamic;
using Eigen::Matrix;
boost::random::mt19937 rng;
boost::random::mixmax rng;

Matrix<double, Dynamic, 1> theta(3);
theta << 0.5, 5.5, 12.0;
Expand All @@ -113,7 +113,7 @@ TEST(ProbDistributionsDirichletMultinomial, rng) {
TEST(ProbDistributionsDirichletMultinomial, rngError) {
using Eigen::Dynamic;
using Eigen::Matrix;
boost::random::mt19937 rng;
boost::random::mixmax rng;

Matrix<double, Dynamic, 1> theta(3);
theta << 0.5, 1.5, 4.0;
Expand All @@ -135,7 +135,7 @@ TEST(ProbDistributionsDirichletMultinomial, rngError) {
TEST(ProbDistributionsDirichletMultinomial, chiSquareGoodnessFitTest) {
using Eigen::Dynamic;
using Eigen::Matrix;
boost::random::mt19937 rng;
boost::random::mixmax rng;
int M = 100;
int trials = 100;
int N = M * trials;
Expand Down Expand Up @@ -171,7 +171,7 @@ TEST(ProbDistributionsDirichletMultinomial, equivBetaBinomial) {
using Eigen::Matrix;
using stan::math::beta_binomial_lpmf;

boost::random::mt19937 rng;
boost::random::mixmax rng;
std::vector<int> ns;
Matrix<double, Dynamic, 1> theta(2, 1);
double alpha = 4.0;
Expand Down
Loading

0 comments on commit 0379951

Please sign in to comment.