Example #1
0
 def test_gdtrib(self):
     # Use small values of a and x or mpmath doesn't converge
     _assert_inverts(
         sp.gdtrib,
         lambda a, b, x: mpmath.gammainc(b, b=a*x, regularized=True),
         1, [Arg(0, 1e2, inclusive_a=False), ProbArg(),
             Arg(0, 1e3, inclusive_a=False)], rtol=1e-5)
Example #2
0
 def test_gdtrix(self):
     _assert_inverts(
         sp.gdtrix,
         lambda a, b, x: mpmath.gammainc(b, b=a*x, regularized=True),
         2, [Arg(0, 1e3, inclusive_a=False), Arg(0, 1e3, inclusive_a=False),
             ProbArg()], rtol=1e-7,
         endpt_atol=[None, 1e-7, 1e-10])
Example #3
0
 def test_btdtria(self):
     _assert_inverts(
         sp.btdtria,
         lambda a, b, x: mpmath.betainc(a, b, x2=x, regularized=True),
         0, [ProbArg(), Arg(0, 1e2, inclusive_a=False),
             Arg(0, 1, inclusive_a=False, inclusive_b=False)],
         rtol=1e-6)
Example #4
0
 def test_chndtridf(self):
     # Use a larger atol since mpmath is doing numerical integration
     _assert_inverts(
         sp.chndtridf,
         _noncentral_chi_cdf,
         1, [Arg(0, 100, inclusive_a=False), ProbArg(),
             Arg(0, 100, inclusive_a=False)],
         n=1000, rtol=1e-4, atol=1e-15)
Example #5
0
 def test_btdtrib(self):
     # Use small values of a or mpmath doesn't converge
     _assert_inverts(
         sp.btdtrib,
         lambda a, b, x: mpmath.betainc(a, b, x2=x, regularized=True),
         1, [Arg(0, 1e2, inclusive_a=False), ProbArg(),
          Arg(0, 1, inclusive_a=False, inclusive_b=False)],
         rtol=1e-7, endpt_atol=[None, 1e-18, 1e-15])
def test_gammainc():
    # Quick check that the gammainc in
    # special._precompute.gammainc_data agrees with mpmath's
    # gammainc.
    assert_mpmath_equal(gammainc,
                        lambda a, x: mp.gammainc(a, b=x, regularized=True),
                        [Arg(0, 100, inclusive_a=False), Arg(0, 100)],
                        nan_ok=False, rtol=1e-17, n=50, dps=50)
def test_gammaincc():
    # Check that the gammaincc in special._precompute.gammainc_data
    # agrees with mpmath's gammainc.
    assert_mpmath_equal(lambda a, x: gammaincc(a, x, dps=1000),
                        lambda a, x: mp.gammainc(a, a=x, regularized=True),
                        [Arg(20, 100), Arg(20, 100)],
                        nan_ok=False, rtol=1e-17, n=50, dps=1000)

    # Test the fast integer path
    assert_mpmath_equal(gammaincc,
                        lambda a, x: mp.gammainc(a, a=x, regularized=True),
                        [IntArg(1, 100), Arg(0, 100)],
                        nan_ok=False, rtol=1e-17, n=50, dps=50)
Example #8
0
 def test_tklmbda_neg_shape(self):
     _assert_inverts(
         sp.tklmbda,
         _tukey_lmbda_quantile,
         0, [ProbArg(), Arg(-25, 0, inclusive_b=False)],
         spfunc_first=False, rtol=1e-5,
         endpt_atol=[1e-9, 1e-5])
Example #9
0
 def test_tklmbda_zero_shape(self):
     # When lmbda = 0 the CDF has a simple closed form
     one = mpmath.mpf(1)
     assert_mpmath_equal(
         lambda x: sp.tklmbda(x, 0),
         lambda x: one/(mpmath.exp(-x) + one),
         [Arg()], rtol=1e-7)
Example #10
0
 def test_tklmbda_pos_shape(self):
     _assert_inverts(sp.tklmbda,
                     _tukey_lmbda_quantile,
                     0,
                     [ProbArg(), Arg(0, 100, inclusive_a=False)],
                     spfunc_first=False,
                     rtol=1e-5)
Example #11
0
 def test_stdtr(self):
     # Ideally the left endpoint for Arg() should be 0.
     assert_mpmath_equal(
         sp.stdtr,
         _student_t_cdf,
         [IntArg(1, 100), Arg(1e-10, np.inf)],
         rtol=1e-7)
Example #12
0
 def test_chndtrix(self):
     # Use a larger atol since mpmath is doing numerical integration
     _assert_inverts(
         sp.chndtrix,
         _noncentral_chi_cdf,
         0, [ProbArg(), IntArg(1, 100), Arg(0, 100, inclusive_a=False)],
         n=1000, rtol=1e-4, atol=1e-15,
         endpt_atol=[1e-6, None, None])
Example #13
0
 def test_fdtridfd(self):
     _assert_inverts(
         sp.fdtridfd,
         _f_cdf,
         1, [IntArg(1, 100),
             ProbArg(),
             Arg(0, 100, inclusive_a=False)],
         rtol=1e-7)
Example #14
0
 def test_stdtridf(self):
     _assert_inverts(
         sp.stdtridf,
         _student_t_cdf,
         0, [ProbArg(), Arg()], rtol=1e-7)