Exemplo n.º 1
0
 def test_lmparams_glogistic(self):
     "Test parameter estimation from L_moments for the generalized logistic distribution"
     (loc, scl, shp) = (0.0, 1., 0.999)
     lmoms = glogistic(shp, loc, scl,).lstats(4)
     assert_almost_equal(glogistic.lmparams(lmoms),
                         np.array((loc, scl, shp)), 6)
     (loc, scl, shp) = (0.0, 0.5, -0.999)
     lmoms = glogistic(shp, loc, scl).lstats(4)
     assert_almost_equal(glogistic.lmparams(lmoms),
                         np.array((loc, scl, shp)), 6)
     (loc, scl, shp) = (0.5, 2.0, 0.5)
     lmoms = glogistic(shp, loc, scl).lstats(4)
     assert_almost_equal(glogistic.lmparams(lmoms),
                         np.array((loc, scl, shp)), 6)
     (loc, scl, shp) = (0, 2, 0)
     lmoms = glogistic(shp, loc, scl).lstats(4)
     assert_almost_equal(glogistic.lmparams(lmoms),
                         np.array((loc, scl, shp)), 6)
     #
     lmoms = (-1., 1., 3.)
     #self.failUnlessRaises(ValueError, pel_glogistic, lmoms)
     lmoms = (-1., 1., 1./3)
     assert_almost_equal(glogistic.lmparams(lmoms),
                         np.array([-1.51901997,  0.82699334, -0.33333333]))
     lmoms = (-1., 1., -0.9)
     assert_almost_equal(glogistic.lmparams(lmoms),
                         np.array([-0.01032489, 0.1092924, 0.9]))
     lmoms = (-1., 1., +0.9)
     assert_almost_equal(glogistic.lmparams(lmoms),
                         np.array([-1.98967511, 0.1092924, -0.9]))
     lmoms = (+1., +1., +0.7)
     assert_almost_equal(np.array(glogistic.lmparams(lmoms)),
                         np.array([ 0.09697573,  0.36788301, -0.7]))
 def test_ppf(self):
     "Try the PPF of the glogistic distribution"
     c = 0.
     _glo = [-6.906754779, -1.098612289, 0.0, 6.906754779]
     assert_almost_equal(glogistic(c).ppf([0.001, 0.25, 0.5, 0.999]), _glo)
     c = 0.1
     _glo = [-9.95062699, -1.16123174, 0.0, 4.98762620]
     assert_almost_equal(glogistic(c).ppf([0.001, 0.25, 0.5, 0.999]), _glo)
     c = 1.
     _glo = [-998.0, -2.0, 0.0, 0.998998998999]
     assert_almost_equal(glogistic(c).ppf([0.001, 0.25, 0.5, 0.999]), _glo)
 def test_cdf(self):
     "Try the CDF of the glogistic distribution"
     c = 1.
     _glo = [0.5, 0.57142857, 0.66666667, 1.0]
     assert_almost_equal(glogistic(c).cdf([0., 0.25, 0.5, 1.0]), _glo)
     c = 0.1
     _glo = [0.5, 0.56295858, 0.62549377, 0.74146659]
     assert_almost_equal(glogistic(c).cdf([0., 0.25, 0.5, 1.0]), _glo)
     c = 0.
     _glo = [0.5, 0.5621765009, 0.622459331, 0.7310585786]
     assert_almost_equal(glogistic(c).cdf([0., 0.25, 0.5, 1.0]), _glo)
 def test_ppf(self):
     "Try the PPF of the glogistic distribution"
     c = 0.
     _glo = [-6.906754779, -1.098612289, 0.0, 6.906754779]
     assert_almost_equal(glogistic(c).ppf([0.001, 0.25, 0.5, 0.999]), _glo)
     c = 0.1
     _glo =  [-9.95062699, -1.16123174, 0.0, 4.98762620]
     assert_almost_equal(glogistic(c).ppf([0.001, 0.25, 0.5, 0.999]), _glo)
     c = 1.
     _glo =  [-998.0, -2.0, 0.0, 0.998998998999]
     assert_almost_equal(glogistic(c).ppf([0.001, 0.25, 0.5, 0.999]), _glo)
 def test_cdf(self):
     "Try the CDF of the glogistic distribution"
     c = 1.
     _glo = [0.5, 0.57142857, 0.66666667, 1.0]
     assert_almost_equal(glogistic(c).cdf([0., 0.25, 0.5, 1.0]), _glo)
     c = 0.1
     _glo =  [0.5, 0.56295858, 0.62549377, 0.74146659]
     assert_almost_equal(glogistic(c).cdf([0., 0.25, 0.5, 1.0]), _glo)
     c = 0.
     _glo =  [0.5, 0.5621765009, 0.622459331, 0.7310585786]
     assert_almost_equal(glogistic(c).cdf([0., 0.25, 0.5, 1.0]), _glo)
 def test_lmparams_glogistic(self):
     "Test parameter estimation from L_moments for the generalized logistic distribution"
     (loc, scl, shp) = (0.0, 1., 0.999)
     lmoms = glogistic(
         shp,
         loc,
         scl,
     ).lstats(4)
     assert_almost_equal(glogistic.lmparams(lmoms), np.array(
         (loc, scl, shp)), 6)
     (loc, scl, shp) = (0.0, 0.5, -0.999)
     lmoms = glogistic(shp, loc, scl).lstats(4)
     assert_almost_equal(glogistic.lmparams(lmoms), np.array(
         (loc, scl, shp)), 6)
     (loc, scl, shp) = (0.5, 2.0, 0.5)
     lmoms = glogistic(shp, loc, scl).lstats(4)
     assert_almost_equal(glogistic.lmparams(lmoms), np.array(
         (loc, scl, shp)), 6)
     (loc, scl, shp) = (0, 2, 0)
     lmoms = glogistic(shp, loc, scl).lstats(4)
     assert_almost_equal(glogistic.lmparams(lmoms), np.array(
         (loc, scl, shp)), 6)
     #
     lmoms = (-1., 1., 3.)
     #self.failUnlessRaises(ValueError, pel_glogistic, lmoms)
     lmoms = (-1., 1., 1. / 3)
     assert_almost_equal(glogistic.lmparams(lmoms),
                         np.array([-1.51901997, 0.82699334, -0.33333333]))
     lmoms = (-1., 1., -0.9)
     assert_almost_equal(glogistic.lmparams(lmoms),
                         np.array([-0.01032489, 0.1092924, 0.9]))
     lmoms = (-1., 1., +0.9)
     assert_almost_equal(glogistic.lmparams(lmoms),
                         np.array([-1.98967511, 0.1092924, -0.9]))
     lmoms = (+1., +1., +0.7)
     assert_almost_equal(np.array(glogistic.lmparams(lmoms)),
                         np.array([0.09697573, 0.36788301, -0.7]))