@@ -43,21 +43,6 @@ TEST(ProbDistributionsInvGaussian, distributionCheck) {
4343 check_quantiles_real_real (InvGaussianTestRig ());
4444}
4545
46- TEST (ProbDistributionsInvGaussian, error_check) {
47- boost::random::mt19937 rng;
48- EXPECT_NO_THROW (stan::math::inv_gaussian_rng (1.0 , 2.0 , rng));
49- EXPECT_THROW (stan::math::inv_gaussian_rng (0.0 , 2.0 , rng), std::domain_error);
50- EXPECT_THROW (stan::math::inv_gaussian_rng (-1.0 , 2.0 , rng), std::domain_error);
51- EXPECT_THROW (stan::math::inv_gaussian_rng (1.0 , 0.0 , rng), std::domain_error);
52- EXPECT_THROW (stan::math::inv_gaussian_rng (1.0 , -1.0 , rng), std::domain_error);
53- EXPECT_THROW (
54- stan::math::inv_gaussian_rng (stan::math::positive_infinity (), 2.0 , rng),
55- std::domain_error);
56- EXPECT_THROW (
57- stan::math::inv_gaussian_rng (1.0 , stan::math::positive_infinity (), rng),
58- std::domain_error);
59- }
60-
6146TEST (ProbDistributionsInvGaussian, rngStableForLargeMuOverLambda) {
6247 boost::random::mt19937 rng (1234 );
6348 for (double mu : {1.0 , 1e3 , 1e6 , 1e9 , 1e12 }) {
@@ -91,25 +76,6 @@ TEST(ProbDistributionsInvGaussian, rngMomentsAtLargeMu) {
9176 EXPECT_NEAR (mu * mu * mu / lambda, var, 0.15 * mu * mu * mu / lambda);
9277}
9378
94- // reference values from mpmath at 60 digits
95-
96- TEST (ProbDistributionsInvGaussian, values) {
97- using stan::math::inv_gaussian_cdf;
98- using stan::math::inv_gaussian_lccdf;
99- using stan::math::inv_gaussian_lcdf;
100- using stan::math::inv_gaussian_lpdf;
101-
102- EXPECT_FLOAT_EQ (-2.479180611448965157415 , inv_gaussian_lpdf (1.2 , 0.5 , 2.0 ));
103- EXPECT_FLOAT_EQ (-2.391593703832052124008 , inv_gaussian_lpdf (0.3 , 1.0 , 5.0 ));
104- EXPECT_FLOAT_EQ (0.9815922531042920910742 , inv_gaussian_cdf (1.2 , 0.5 , 2.0 ));
105- EXPECT_FLOAT_EQ (0.003359190912064955560317 , inv_gaussian_cdf (0.3 , 1.0 , 5.0 ));
106- EXPECT_FLOAT_EQ (-0.01857927772712011847827 , inv_gaussian_lcdf (1.2 , 0.5 , 2.0 ));
107- EXPECT_FLOAT_EQ (-5.696055133984662592139 , inv_gaussian_lcdf (0.3 , 1.0 , 5.0 ));
108- EXPECT_FLOAT_EQ (-3.9949836760335225255 , inv_gaussian_lccdf (1.2 , 0.5 , 2.0 ));
109- EXPECT_FLOAT_EQ (-0.003364845660995599504277 ,
110- inv_gaussian_lccdf (0.3 , 1.0 , 5.0 ));
111- }
112-
11379TEST (ProbDistributionsInvGaussian, boundaries) {
11480 using stan::math::inv_gaussian_cdf;
11581 using stan::math::inv_gaussian_lccdf;
@@ -153,6 +119,7 @@ TEST(ProbDistributionsInvGaussian, boundariesInContainer) {
153119}
154120
155121// 2 lambda / mu is past the overflow point of exp for all of these.
122+ // reference values from mpmath at 60 digits
156123TEST (ProbDistributionsInvGaussian, largeExpFactor) {
157124 using stan::math::inv_gaussian_lccdf;
158125 using stan::math::inv_gaussian_lcdf;
@@ -248,24 +215,6 @@ TEST(ProbDistributionsInvGaussian, cdfCcdfSumToOne) {
248215 }
249216}
250217
251- TEST (ProbDistributionsInvGaussian, vectorMatchesScalarSum) {
252- using stan::math::inv_gaussian_lccdf;
253- using stan::math::inv_gaussian_lcdf;
254- using stan::math::inv_gaussian_lpdf;
255- std::vector<double > y{0.2 , 0.5 , 1.0 , 2.0 , 5.0 };
256- double sum_lpdf = 0 ;
257- double sum_lcdf = 0 ;
258- double sum_lccdf = 0 ;
259- for (double yi : y) {
260- sum_lpdf += inv_gaussian_lpdf (yi, 1.3 , 3.0 );
261- sum_lcdf += inv_gaussian_lcdf (yi, 1.3 , 3.0 );
262- sum_lccdf += inv_gaussian_lccdf (yi, 1.3 , 3.0 );
263- }
264- EXPECT_FLOAT_EQ (sum_lpdf, inv_gaussian_lpdf (y, 1.3 , 3.0 ));
265- EXPECT_FLOAT_EQ (sum_lcdf, inv_gaussian_lcdf (y, 1.3 , 3.0 ));
266- EXPECT_FLOAT_EQ (sum_lccdf, inv_gaussian_lccdf (y, 1.3 , 3.0 ));
267- }
268-
269218// check helper functions; tolerances scale with each value's magnitude
270219TEST (ProbDistributionsInvGaussian, internalLogPhi) {
271220 using stan::math::internal::log_Phi;
@@ -294,29 +243,16 @@ TEST(ProbDistributionsInvGaussian, internalLogPhi) {
294243 EXPECT_FLOAT_EQ (0.0 , log_Phi (inf));
295244 EXPECT_FLOAT_EQ (-inf, log_Phi (-inf));
296245 EXPECT_TRUE (std::isnan (log_Phi (std::numeric_limits<double >::quiet_NaN ())));
297- }
298246
299- // The true slope at z = -30 is about 30, so across a 2e-10 interval the
300- // honest change is about 6e-9.
301- TEST (ProbDistributionsInvGaussian, internalLogPhiBranchContinuity) {
302- using stan::math::internal::log_Phi;
247+ // branch continuity: the true slope at z = -30 is about 30, so across a
248+ // 2e-10 interval the honest change is about 6e-9
303249 double eps = 1e-10 ;
304250 double step = log_Phi (-30.0 + eps) - log_Phi (-30.0 - eps);
305251 EXPECT_LT (std::fabs (step), 1e-7 );
306252}
307253
308- TEST (ProbDistributionsInvGaussian, errors ) {
254+ TEST (ProbDistributionsInvGaussian, sizeMismatch ) {
309255 using stan::math::inv_gaussian_lpdf;
310- double inf = std::numeric_limits<double >::infinity ();
311-
312- EXPECT_THROW (inv_gaussian_lpdf (-1.0 , 1.0 , 2.0 ), std::domain_error);
313- EXPECT_THROW (inv_gaussian_lpdf (1.0 , 0.0 , 2.0 ), std::domain_error);
314- EXPECT_THROW (inv_gaussian_lpdf (1.0 , -1.0 , 2.0 ), std::domain_error);
315- EXPECT_THROW (inv_gaussian_lpdf (1.0 , inf, 2.0 ), std::domain_error);
316- EXPECT_THROW (inv_gaussian_lpdf (1.0 , 1.0 , 0.0 ), std::domain_error);
317- EXPECT_THROW (inv_gaussian_lpdf (1.0 , 1.0 , -1.0 ), std::domain_error);
318- EXPECT_THROW (inv_gaussian_lpdf (1.0 , 1.0 , inf), std::domain_error);
319-
320256 std::vector<double > y{1.0 , 2.0 };
321257 std::vector<double > mu{1.0 , 2.0 , 3.0 };
322258 EXPECT_THROW (inv_gaussian_lpdf (y, mu, 1.0 ), std::invalid_argument);
0 commit comments