Skip to content

Commit 57bf957

Browse files
committed
TST/CLN: Tighten tol to reduce spurious test failure
Sighten integration tol to avoid spurious fail on Win32 Clean up related functions
1 parent 725e8c8 commit 57bf957

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

statsmodels/sandbox/distributions/multivariate.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ def bghfactor(df):
6565

6666

6767
def mvstdtprob(a, b, R, df, ieps=1e-5, quadkwds=None, mvstkwds=None):
68-
'''probability of rectangular area of standard t distribution
68+
"""
69+
Probability of rectangular area of standard t distribution
6970
7071
assumes mean is zero and R is correlation matrix
7172
@@ -74,14 +75,12 @@ def mvstdtprob(a, b, R, df, ieps=1e-5, quadkwds=None, mvstkwds=None):
7475
This function does not calculate the estimate of the combined error
7576
between the underlying multivariate normal probability calculations
7677
and the integration.
77-
78-
'''
79-
kwds = dict(args=(a,b,R,df), epsabs=1e-4, epsrel=1e-2, limit=150)
78+
"""
79+
kwds = dict(args=(a, b, R, df), epsabs=1e-4, epsrel=1e-2, limit=150)
8080
if not quadkwds is None:
8181
kwds.update(quadkwds)
82-
#print kwds
83-
res, err = integrate.quad(funbgh2, *chi.ppf([ieps,1-ieps], df),
84-
**kwds)
82+
lower, upper = chi.ppf([ieps, 1 - ieps], df)
83+
res, err = integrate.quad(funbgh2, lower, upper, **kwds)
8584
prob = res * bghfactor(df)
8685
return prob
8786

statsmodels/sandbox/distributions/tests/test_multivariate.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,17 @@ def test_mvn_mvt_3(self):
6363
df = self.df
6464
corr2 = self.corr2
6565

66-
#from -inf
67-
#print 'from -inf'
6866
a2 = a.copy()
6967
a2[:] = -np.inf
70-
probmvn_R = 0.9961141 #using higher precision in R, error approx. 6.866163e-07
71-
probmvt_R = 0.9522146 #using higher precision in R, error approx. 1.6e-07
72-
assert_almost_equal(probmvt_R, mvstdtprob(a2, b, corr2, df), 4)
73-
assert_almost_equal(probmvn_R, mvstdnormcdf(a2, b, corr2, maxpts=100000,
74-
abseps=1e-5), 4)
68+
# using higher precision in R, error approx. 6.866163e-07
69+
probmvn_R = 0.9961141
70+
# using higher precision in R, error approx. 1.6e-07
71+
probmvt_R = 0.9522146
72+
quadkwds = {'epsabs': 1e-08}
73+
probmvt = mvstdtprob(a2, b, corr2, df, quadkwds=quadkwds)
74+
assert_almost_equal(probmvt_R, probmvt, 4)
75+
probmvn = mvstdnormcdf(a2, b, corr2, maxpts=100000, abseps=1e-5)
76+
assert_almost_equal(probmvn_R, probmvn, 4)
7577

7678
def test_mvn_mvt_4(self):
7779
a, bl = self.a, self.b

0 commit comments

Comments
 (0)