Skip to content

Commit

Permalink
TST/CLN: Tighten tol to reduce spurious test failure
Browse files Browse the repository at this point in the history
Sighten integration tol to avoid spurious fail on Win32
Clean up related functions
  • Loading branch information
bashtage committed Sep 14, 2018
1 parent 725e8c8 commit 57bf957
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
13 changes: 6 additions & 7 deletions statsmodels/sandbox/distributions/multivariate.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ def bghfactor(df):


def mvstdtprob(a, b, R, df, ieps=1e-5, quadkwds=None, mvstkwds=None):
'''probability of rectangular area of standard t distribution
"""
Probability of rectangular area of standard t distribution
assumes mean is zero and R is correlation matrix
Expand All @@ -74,14 +75,12 @@ def mvstdtprob(a, b, R, df, ieps=1e-5, quadkwds=None, mvstkwds=None):
This function does not calculate the estimate of the combined error
between the underlying multivariate normal probability calculations
and the integration.
'''
kwds = dict(args=(a,b,R,df), epsabs=1e-4, epsrel=1e-2, limit=150)
"""
kwds = dict(args=(a, b, R, df), epsabs=1e-4, epsrel=1e-2, limit=150)
if not quadkwds is None:
kwds.update(quadkwds)
#print kwds
res, err = integrate.quad(funbgh2, *chi.ppf([ieps,1-ieps], df),
**kwds)
lower, upper = chi.ppf([ieps, 1 - ieps], df)
res, err = integrate.quad(funbgh2, lower, upper, **kwds)
prob = res * bghfactor(df)
return prob

Expand Down
16 changes: 9 additions & 7 deletions statsmodels/sandbox/distributions/tests/test_multivariate.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,17 @@ def test_mvn_mvt_3(self):
df = self.df
corr2 = self.corr2

#from -inf
#print 'from -inf'
a2 = a.copy()
a2[:] = -np.inf
probmvn_R = 0.9961141 #using higher precision in R, error approx. 6.866163e-07
probmvt_R = 0.9522146 #using higher precision in R, error approx. 1.6e-07
assert_almost_equal(probmvt_R, mvstdtprob(a2, b, corr2, df), 4)
assert_almost_equal(probmvn_R, mvstdnormcdf(a2, b, corr2, maxpts=100000,
abseps=1e-5), 4)
# using higher precision in R, error approx. 6.866163e-07
probmvn_R = 0.9961141
# using higher precision in R, error approx. 1.6e-07
probmvt_R = 0.9522146
quadkwds = {'epsabs': 1e-08}
probmvt = mvstdtprob(a2, b, corr2, df, quadkwds=quadkwds)
assert_almost_equal(probmvt_R, probmvt, 4)
probmvn = mvstdnormcdf(a2, b, corr2, maxpts=100000, abseps=1e-5)
assert_almost_equal(probmvn_R, probmvn, 4)

def test_mvn_mvt_4(self):
a, bl = self.a, self.b
Expand Down

0 comments on commit 57bf957

Please sign in to comment.