Skip to content

Commit 9da4dc8

Browse files
committed
Move stan::rng_t decl to Math library for consistency
1 parent 0379951 commit 9da4dc8

File tree

72 files changed

+240
-228
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+240
-228
lines changed

stan/math/prim/meta/rng_t.hpp

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#ifndef STAN_MATH_PRIM_META_RNG_T_HPP
2+
#define STAN_MATH_PRIM_META_RNG_T_HPP
3+
4+
#include <boost/random/mixmax.hpp>
5+
6+
namespace stan {
7+
8+
using rng_t = boost::random::mixmax;
9+
10+
} // namespace stan
11+
12+
#endif

test/unit/math/fwd/prob/lkj_corr_test.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
TEST(ProbDistributionsLkjCorr, fvar_double) {
77
using stan::math::fvar;
8-
boost::random::mixmax rng;
8+
stan::rng_t rng;
99
int K = 4;
1010
Eigen::Matrix<fvar<double>, Eigen::Dynamic, Eigen::Dynamic> Sigma(K, K);
1111
Sigma.setZero();
@@ -24,7 +24,7 @@ TEST(ProbDistributionsLkjCorr, fvar_double) {
2424

2525
TEST(ProbDistributionsLkjCorrCholesky, fvar_double) {
2626
using stan::math::fvar;
27-
boost::random::mixmax rng;
27+
stan::rng_t rng;
2828
int K = 4;
2929
Eigen::Matrix<fvar<double>, Eigen::Dynamic, Eigen::Dynamic> Sigma(K, K);
3030
Sigma.setZero();
@@ -43,7 +43,7 @@ TEST(ProbDistributionsLkjCorrCholesky, fvar_double) {
4343

4444
TEST(ProbDistributionsLkjCorr, fvar_fvar_double) {
4545
using stan::math::fvar;
46-
boost::random::mixmax rng;
46+
stan::rng_t rng;
4747
int K = 4;
4848
Eigen::Matrix<fvar<fvar<double> >, Eigen::Dynamic, Eigen::Dynamic> Sigma(K,
4949
K);
@@ -63,7 +63,7 @@ TEST(ProbDistributionsLkjCorr, fvar_fvar_double) {
6363

6464
TEST(ProbDistributionsLkjCorrCholesky, fvar_fvar_double) {
6565
using stan::math::fvar;
66-
boost::random::mixmax rng;
66+
stan::rng_t rng;
6767
int K = 4;
6868
Eigen::Matrix<fvar<fvar<double> >, Eigen::Dynamic, Eigen::Dynamic> Sigma(K,
6969
K);

test/unit/math/mix/prob/lkj_corr_test.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
TEST(ProbDistributionsLkjCorr, fvar_var) {
1010
using stan::math::fvar;
1111
using stan::math::var;
12-
boost::random::mixmax rng;
12+
stan::rng_t rng;
1313
int K = 4;
1414
Eigen::Matrix<fvar<var>, Eigen::Dynamic, Eigen::Dynamic> Sigma(K, K);
1515
Sigma.setZero();
@@ -31,7 +31,7 @@ TEST(ProbDistributionsLkjCorr, fvar_var) {
3131
TEST(ProbDistributionsLkjCorrCholesky, fvar_var) {
3232
using stan::math::fvar;
3333
using stan::math::var;
34-
boost::random::mixmax rng;
34+
stan::rng_t rng;
3535
int K = 4;
3636
Eigen::Matrix<fvar<var>, Eigen::Dynamic, Eigen::Dynamic> Sigma(K, K);
3737
Sigma.setZero();
@@ -54,7 +54,7 @@ TEST(ProbDistributionsLkjCorrCholesky, fvar_var) {
5454
TEST(ProbDistributionsLkjCorr, fvar_fvar_var) {
5555
using stan::math::fvar;
5656
using stan::math::var;
57-
boost::random::mixmax rng;
57+
stan::rng_t rng;
5858
int K = 4;
5959
Eigen::Matrix<fvar<fvar<var> >, Eigen::Dynamic, Eigen::Dynamic> Sigma(K, K);
6060
Sigma.setZero();
@@ -78,7 +78,7 @@ TEST(ProbDistributionsLkjCorr, fvar_fvar_var) {
7878
TEST(ProbDistributionsLkjCorrCholesky, fvar_fvar_var) {
7979
using stan::math::fvar;
8080
using stan::math::var;
81-
boost::random::mixmax rng;
81+
stan::rng_t rng;
8282
int K = 4;
8383
Eigen::Matrix<fvar<fvar<var> >, Eigen::Dynamic, Eigen::Dynamic> Sigma(K, K);
8484
Sigma.setZero();

test/unit/math/opencl/multiply_transpose_test.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <boost/random/mersenne_twister.hpp>
88
#include <gtest/gtest.h>
99
#include <algorithm>
10-
boost::random::mixmax rng;
10+
stan::rng_t rng;
1111

1212
TEST(MathMatrixOpenCL, multiply_transpose_exception_fail_zero) {
1313
stan::math::row_vector_d rv(0);

test/unit/math/opencl/prim/mdivide_left_tri_low_test.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ TEST(MathMatrixCL, mdivide_left_tri_low_cl_exception) {
2929
}
3030

3131
void mdivide_left_tri_low_Ab_test(int size) {
32-
boost::random::mixmax rng;
32+
stan::rng_t rng;
3333
auto m1 = stan::math::matrix_d(size, size);
3434
for (int i = 0; i < size; i++) {
3535
for (int j = 0; j < i; j++) {
@@ -57,7 +57,7 @@ void mdivide_left_tri_low_Ab_test(int size) {
5757
}
5858

5959
void mdivide_left_tri_low_A_test(int size) {
60-
boost::random::mixmax rng;
60+
stan::rng_t rng;
6161
auto m1 = stan::math::matrix_d(size, size);
6262
for (int i = 0; i < size; i++) {
6363
for (int j = 0; j < i; j++) {

test/unit/math/opencl/prim/mdivide_right_tri_low_test.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ TEST(MathMatrixCL, mdivide_right_tri_low_cl_exception) {
2929
}
3030

3131
void mdivide_right_tri_low_Ab_test(int size) {
32-
boost::random::mixmax rng;
32+
stan::rng_t rng;
3333
auto m1 = stan::math::matrix_d(size, size);
3434
for (int i = 0; i < size; i++) {
3535
for (int j = 0; j < i; j++) {

test/unit/math/opencl/tri_inverse_test.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ TEST(MathMatrixCL, inverse_cl_exception) {
2525
}
2626

2727
void lower_inverse_test(int size) {
28-
boost::random::mixmax rng;
28+
stan::rng_t rng;
2929
auto m1 = stan::math::matrix_d(size, size);
3030
for (int i = 0; i < size; i++) {
3131
for (int j = 0; j < i; j++) {
@@ -56,7 +56,7 @@ void lower_inverse_test(int size) {
5656
}
5757

5858
void upper_inverse_test(int size) {
59-
boost::random::mixmax rng;
59+
stan::rng_t rng;
6060
auto m1 = stan::math::matrix_d(size, size);
6161
for (int i = 0; i < size; i++) {
6262
for (int j = 0; j < i; j++) {

test/unit/math/prim/fun/chol2inv_test.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ TEST(MathMatrixPrimMat, chol2inv) {
2525
using stan::math::matrix_d;
2626
using stan::math::wishart_rng;
2727

28-
boost::random::mixmax rng;
28+
stan::rng_t rng;
2929
matrix_d I(3, 3);
3030
I.setZero();
3131
I.diagonal().setOnes();

test/unit/math/prim/prob/bernoulli_logit_glm_rng_test.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
TEST(ProbDistributionsBernoulliLogitGlm, vectorized) {
1010
using stan::math::bernoulli_logit_glm_rng;
1111
// Test scalar/vector combinations.
12-
boost::random::mixmax rng;
12+
stan::rng_t rng;
1313

1414
Eigen::MatrixXd x(2, 3);
1515
x << 3.5, -1.5, 0.0, 2.0, 1.0, 3.0;
@@ -70,7 +70,7 @@ TEST(ProbDistributionsBernoulliLogitGlm, vectorized) {
7070
TEST(ProbDistributionsBernoulliLogitGlm, errorCheck) {
7171
using stan::math::bernoulli_logit_glm_rng;
7272
// Check errors for nonfinite and wrong sizes.
73-
boost::random::mixmax rng;
73+
stan::rng_t rng;
7474

7575
int N = 3;
7676
int M = 2;
@@ -107,7 +107,7 @@ TEST(ProbDistributionsBernoulliLogitGlm, errorCheck) {
107107
TEST(ProbDistributionsBernoulliLogitGlm, marginalChiSquareGoodnessFitTest) {
108108
using stan::math::bernoulli_logit_glm_rng;
109109
// Check distribution of result.
110-
boost::random::mixmax rng;
110+
stan::rng_t rng;
111111
Eigen::MatrixXd x(2, 2);
112112
x << 3.5, -1.5, 2.0, -1.2;
113113
std::vector<double> alpha{2.0, 1.0};

test/unit/math/prim/prob/bernoulli_logit_test.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ TEST(ProbDistributionsBernoulliLogit, distributionCheck) {
3535
}
3636

3737
TEST(ProbDistributionsBernoulliLogit, error_check) {
38-
boost::random::mixmax rng;
38+
stan::rng_t rng;
3939

4040
EXPECT_NO_THROW(stan::math::bernoulli_logit_rng(-3.5, rng));
4141
EXPECT_THROW(
@@ -44,7 +44,7 @@ TEST(ProbDistributionsBernoulliLogit, error_check) {
4444
}
4545

4646
TEST(ProbDistributionsBernoulliLogit, logitChiSquareGoodnessFitTest) {
47-
boost::random::mixmax rng;
47+
stan::rng_t rng;
4848
// number of samples
4949
int N = 10000;
5050

test/unit/math/prim/prob/bernoulli_test.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ TEST(ProbDistributionsBernoulli, distributionCheck) {
3535
}
3636

3737
TEST(ProbDistributionsBernoulli, error_check) {
38-
boost::random::mixmax rng;
38+
stan::rng_t rng;
3939
EXPECT_NO_THROW(stan::math::bernoulli_rng(0.6, rng));
4040

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

4747
TEST(ProbDistributionsBernoulli, chiSquareGoodnessFitTest) {
48-
boost::random::mixmax rng;
48+
stan::rng_t rng;
4949
int N = 10000;
5050

5151
std::vector<double> expected;

test/unit/math/prim/prob/beta_binomial_test.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ TEST(ProbDistributionsBetaBinomial, distributionCheck) {
4040
}
4141

4242
TEST(ProbDistributionBetaBinomial, error_check) {
43-
boost::random::mixmax rng;
43+
stan::rng_t rng;
4444
EXPECT_NO_THROW(stan::math::beta_binomial_rng(4, 0.6, 2.0, rng));
4545

4646
EXPECT_THROW(stan::math::beta_binomial_rng(-4, 0.6, 2, rng),

test/unit/math/prim/prob/beta_proportion_test.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ TEST(ProbDistributionsBetaProportion, distributionTest) {
5050
}
5151

5252
TEST(ProbDistributionsBetaProportion, error_check) {
53-
boost::random::mixmax rng;
53+
stan::rng_t rng;
5454
EXPECT_NO_THROW(stan::math::beta_proportion_rng(0.5, 3.0, rng));
5555
EXPECT_NO_THROW(stan::math::beta_proportion_rng(1e-10, 1e-10, rng));
5656
EXPECT_THROW(stan::math::beta_proportion_rng(2.0, -1.0, rng),
@@ -68,7 +68,7 @@ TEST(ProbDistributionsBetaProportion, error_check) {
6868
}
6969

7070
TEST(ProbDistributionsBetaProportion, chiSquareGoodnessFitTest) {
71-
boost::random::mixmax rng;
71+
stan::rng_t rng;
7272
int N = 10000;
7373
int K = stan::math::round(2 * std::pow(N, 0.4));
7474

@@ -99,7 +99,7 @@ TEST(ProbDistributionsBetaProportion, chiSquareGoodnessFitTest) {
9999
}
100100

101101
TEST(ProbDistributionsBetaProportion, chiSquareGoodnessFitTest2) {
102-
boost::random::mixmax rng;
102+
stan::rng_t rng;
103103
int N = 10000;
104104
int K = stan::math::round(2 * std::pow(N, 0.4));
105105

test/unit/math/prim/prob/beta_test.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ TEST(ProbDistributionsBeta, distributionTest) {
4646
}
4747

4848
TEST(ProbDistributionsBeta, error_check) {
49-
boost::random::mixmax rng;
49+
stan::rng_t rng;
5050
EXPECT_NO_THROW(stan::math::beta_rng(2.0, 1.0, rng));
5151
EXPECT_NO_THROW(stan::math::beta_rng(1e-10, 1e-10, rng));
5252

@@ -60,7 +60,7 @@ TEST(ProbDistributionsBeta, error_check) {
6060
}
6161

6262
TEST(ProbDistributionsBeta, chiSquareGoodnessFitTest) {
63-
boost::random::mixmax rng;
63+
stan::rng_t rng;
6464
int N = 10000;
6565
int K = stan::math::round(2 * std::pow(N, 0.4));
6666

@@ -83,7 +83,7 @@ TEST(ProbDistributionsBeta, chiSquareGoodnessFitTest) {
8383
}
8484

8585
TEST(ProbDistributionsBeta, chiSquareGoodnessFitTestSmallParameters) {
86-
boost::random::mixmax rng;
86+
stan::rng_t rng;
8787
int N = 10000;
8888
int K = stan::math::round(2 * std::pow(N, 0.4));
8989

test/unit/math/prim/prob/binomial_test.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ TEST(ProbDistributionsBinomial, distributionCheck) {
3939
}
4040

4141
TEST(ProbDistributionBinomiali, error_check) {
42-
boost::random::mixmax rng;
42+
stan::rng_t rng;
4343
EXPECT_NO_THROW(stan::math::binomial_rng(4, 0.6, rng));
4444
EXPECT_THROW(stan::math::binomial_rng(-4, 0.6, rng), std::domain_error);
4545
EXPECT_THROW(stan::math::binomial_rng(4, -0.6, rng), std::domain_error);
@@ -50,7 +50,7 @@ TEST(ProbDistributionBinomiali, error_check) {
5050
}
5151

5252
TEST(ProbDistributionsBinomial, chiSquareGoodnessFitTest) {
53-
boost::random::mixmax rng;
53+
stan::rng_t rng;
5454
int N = 10000;
5555
int K = stan::math::round(2 * std::pow(N, 0.4));
5656
boost::math::binomial_distribution<> dist(100, 0.6);

test/unit/math/prim/prob/categorical_logit_rng_test.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
TEST(ProbDistributionsCategoricalLogit, error_check) {
88
using Eigen::VectorXd;
99
using stan::math::categorical_logit_rng;
10-
boost::random::mixmax rng;
10+
stan::rng_t rng;
1111

1212
VectorXd beta(3);
1313

@@ -27,7 +27,7 @@ TEST(ProbDistributionsCategoricalLogit, error_check) {
2727
TEST(ProbDistributionsCategoricalLogit, chiSquareGoodnessFitTest) {
2828
using Eigen::VectorXd;
2929
using stan::math::softmax;
30-
boost::random::mixmax rng;
30+
stan::rng_t rng;
3131
int N = 10000;
3232
int K = 3;
3333
VectorXd beta(K);

test/unit/math/prim/prob/categorical_test.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ TEST(ProbDistributionsCategorical, error_check) {
8888
using Eigen::Dynamic;
8989
using Eigen::Matrix;
9090
using stan::math::categorical_log;
91-
boost::random::mixmax rng;
91+
stan::rng_t rng;
9292

9393
Matrix<double, Dynamic, Dynamic> theta(3, 1);
9494
theta << 0.15, 0.45, 0.50;
@@ -100,7 +100,7 @@ TEST(ProbDistributionsCategorical, chiSquareGoodnessFitTest) {
100100
using Eigen::Dynamic;
101101
using Eigen::Matrix;
102102
using stan::math::categorical_log;
103-
boost::random::mixmax rng;
103+
stan::rng_t rng;
104104

105105
int N = 10000;
106106
Matrix<double, Dynamic, Dynamic> theta(3, 1);

test/unit/math/prim/prob/cauchy_test.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ TEST(ProbDistributionsCauchy, distributionTest) {
4646
}
4747

4848
TEST(ProbDistributionsCauchy, error_check) {
49-
boost::random::mixmax rng;
49+
stan::rng_t rng;
5050
EXPECT_NO_THROW(stan::math::cauchy_rng(2.0, 1.0, rng));
5151

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

6161
TEST(ProbDistributionsCauchy, chiSquareGoodnessFitTest) {
62-
boost::random::mixmax rng;
62+
stan::rng_t rng;
6363
int N = 10000;
6464
int K = stan::math::round(2 * std::pow(N, 0.4));
6565

test/unit/math/prim/prob/chi_square_test.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ TEST(ProbDistributionsChiSquare, distributionTest) {
4242
}
4343

4444
TEST(ProbDistributionsChiSquare, error_check) {
45-
boost::random::mixmax rng;
45+
stan::rng_t rng;
4646
EXPECT_NO_THROW(stan::math::chi_square_rng(2.0, rng));
4747

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

5353
TEST(ProbDistributionsChiSquare, chiSquareGoodnessFitTest) {
54-
boost::random::mixmax rng;
54+
stan::rng_t rng;
5555
int N = 10000;
5656
int K = stan::math::round(2 * std::pow(N, 0.4));
5757

test/unit/math/prim/prob/dirichlet_multinomial_test.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ TEST(ProbDistributionsDirichletMultinomial, zeros) {
9090
TEST(ProbDistributionsDirichletMultinomial, rng) {
9191
using Eigen::Dynamic;
9292
using Eigen::Matrix;
93-
boost::random::mixmax rng;
93+
stan::rng_t rng;
9494

9595
Matrix<double, Dynamic, 1> theta(3);
9696
theta << 0.5, 5.5, 12.0;
@@ -113,7 +113,7 @@ TEST(ProbDistributionsDirichletMultinomial, rng) {
113113
TEST(ProbDistributionsDirichletMultinomial, rngError) {
114114
using Eigen::Dynamic;
115115
using Eigen::Matrix;
116-
boost::random::mixmax rng;
116+
stan::rng_t rng;
117117

118118
Matrix<double, Dynamic, 1> theta(3);
119119
theta << 0.5, 1.5, 4.0;
@@ -135,7 +135,7 @@ TEST(ProbDistributionsDirichletMultinomial, rngError) {
135135
TEST(ProbDistributionsDirichletMultinomial, chiSquareGoodnessFitTest) {
136136
using Eigen::Dynamic;
137137
using Eigen::Matrix;
138-
boost::random::mixmax rng;
138+
stan::rng_t rng;
139139
int M = 100;
140140
int trials = 100;
141141
int N = M * trials;
@@ -171,7 +171,7 @@ TEST(ProbDistributionsDirichletMultinomial, equivBetaBinomial) {
171171
using Eigen::Matrix;
172172
using stan::math::beta_binomial_lpmf;
173173

174-
boost::random::mixmax rng;
174+
stan::rng_t rng;
175175
std::vector<int> ns;
176176
Matrix<double, Dynamic, 1> theta(2, 1);
177177
double alpha = 4.0;

0 commit comments

Comments
 (0)