예제 #1
0
    def test_dist(self):
        np.random.seed(1234567)
        x = stats.tukeylambda.rvs(-0.7, loc=2, scale=0.5, size=10000) + 1e4

        # Test that we can specify distributions both by name and as objects.
        max1 = stats.ppcc_max(x, dist='tukeylambda')
        max2 = stats.ppcc_max(x, dist=stats.tukeylambda)
        assert_almost_equal(max1, -0.71215366521264145, decimal=5)
        assert_almost_equal(max2, -0.71215366521264145, decimal=5)

        # Test that 'tukeylambda' is the default dist
        max3 = stats.ppcc_max(x)
        assert_almost_equal(max3, -0.71215366521264145, decimal=5)
예제 #2
0
    def test_dist(self):
        np.random.seed(1234567)
        x = stats.tukeylambda.rvs(-0.7, loc=2, scale=0.5, size=10000) + 1e4

        # Test that we can specify distributions both by name and as objects.
        max1 = stats.ppcc_max(x, dist='tukeylambda')
        max2 = stats.ppcc_max(x, dist=stats.tukeylambda)
        assert_almost_equal(max1, -0.71215366521264145, decimal=5)
        assert_almost_equal(max2, -0.71215366521264145, decimal=5)

        # Test that 'tukeylambda' is the default dist
        max3 = stats.ppcc_max(x)
        assert_almost_equal(max3, -0.71215366521264145, decimal=5)
예제 #3
0
    def test_brack(self):
        np.random.seed(1234567)
        x = stats.tukeylambda.rvs(-0.7, loc=2, scale=0.5, size=10000) + 1e4
        assert_raises(ValueError, stats.ppcc_max, x, brack=(0.0, 1.0, 0.5))

        # On Python 2.6 the result is accurate to 5 decimals. On Python >= 2.7
        # it is accurate up to 16 decimals
        assert_almost_equal(stats.ppcc_max(x, brack=(0, 1)),
                            -0.71215366521264145, decimal=5)

        # On Python 2.6 the result is accurate to 5 decimals. On Python >= 2.7
        # it is accurate up to 16 decimals
        assert_almost_equal(stats.ppcc_max(x, brack=(-2, 2)),
                            -0.71215366521264145, decimal=5)
예제 #4
0
    def test_brack(self):
        np.random.seed(1234567)
        x = stats.tukeylambda.rvs(-0.7, loc=2, scale=0.5, size=10000) + 1e4
        assert_raises(ValueError, stats.ppcc_max, x, brack=(0.0, 1.0, 0.5))

        # On Python 2.6 the result is accurate to 5 decimals. On Python >= 2.7
        # it is accurate up to 16 decimals
        assert_almost_equal(stats.ppcc_max(x, brack=(0, 1)),
                            -0.71215366521264145, decimal=5)

        # On Python 2.6 the result is accurate to 5 decimals. On Python >= 2.7
        # it is accurate up to 16 decimals
        assert_almost_equal(stats.ppcc_max(x, brack=(-2, 2)),
                            -0.71215366521264145, decimal=5)
예제 #5
0
 def calcPPCC(self):
     """
     Open shape parameter bounds dialog, compute shape parameter accordingly
     """
     dist_name = self.scipyDistsList.currentItem().text()
     dialog = ShapeFactorBoundsWindow(self, self.samples, dist_name)
     if dialog.exec_():
         lowerBound, upperBound = dialog.getBounds()
         if lowerBound != None and upperBound != None:
             value = stats.ppcc_max(self.samples,
                                    brack=(lowerBound, upperBound),
                                    dist=dist_name)
             self.shape1Text.setText(str(value))
예제 #6
0
 def test_ppcc_max_basic(self):
     np.random.seed(1234567)
     x = stats.tukeylambda.rvs(-0.7, loc=2, scale=0.5, size=10000) + 1e4
     # On Python 2.6 the result is accurate to 5 decimals. On Python >= 2.7
     # it is accurate up to 16 decimals
     assert_almost_equal(stats.ppcc_max(x), -0.71215366521264145, decimal=5)
예제 #7
0
 def test_ppcc_max_basic(self):
     np.random.seed(1234567)
     x = stats.tukeylambda.rvs(-0.7, loc=2, scale=0.5, size=10000) + 1e4
     # On Python 2.6 the result is accurate to 5 decimals. On Python >= 2.7
     # it is accurate up to 16 decimals
     assert_almost_equal(stats.ppcc_max(x), -0.71215366521264145, decimal=5)
# First we generate some random data from a Tukey-Lambda distribution,
# with shape parameter -0.7:

from scipy import stats
x = stats.tukeylambda.rvs(
    -0.7, loc=2, scale=0.5, size=10000, random_state=1234567) + 1e4

# Now we explore this data with a PPCC plot as well as the related
# probability plot and Box-Cox normplot.  A red line is drawn where we
# expect the PPCC value to be maximal (at the shape parameter -0.7 used
# above):

import matplotlib.pyplot as plt
fig = plt.figure(figsize=(8, 6))
ax = fig.add_subplot(111)
res = stats.ppcc_plot(x, -5, 5, plot=ax)

# We calculate the value where the shape should reach its maximum and a red
# line is drawn there. The line should coincide with the highest point in the
# ppcc_plot.

max = stats.ppcc_max(x)
ax.vlines(max, 0, 1, colors='r', label='Expected shape value')

plt.show()