當前位置: 首頁>>代碼示例>>Python>>正文


Python stats.probplot方法代碼示例

本文整理匯總了Python中scipy.stats.probplot方法的典型用法代碼示例。如果您正苦於以下問題:Python stats.probplot方法的具體用法?Python stats.probplot怎麽用?Python stats.probplot使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在scipy.stats的用法示例。


在下文中一共展示了stats.probplot方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _norm_plot_pos

# 需要導入模塊: from scipy import stats [as 別名]
# 或者: from scipy.stats import probplot [as 別名]
def _norm_plot_pos(observations):
    """
    Computes standard normal (Gaussian) plotting positions using scipy.

    Parameters
    ----------
    observations : array-like
        Sequence of observed quantities.

    Returns
    -------
    plotting_position : array of floats

    """
    ppos, sorted_res = stats.probplot(observations, fit=False)
    return stats.norm.cdf(ppos) 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:18,代碼來源:ros.py

示例2: test_dist_keyword

# 需要導入模塊: from scipy import stats [as 別名]
# 或者: from scipy.stats import probplot [as 別名]
def test_dist_keyword(self):
        np.random.seed(12345)
        x = stats.norm.rvs(size=20)
        osm1, osr1 = stats.probplot(x, fit=False, dist='t', sparams=(3,))
        osm2, osr2 = stats.probplot(x, fit=False, dist=stats.t, sparams=(3,))
        assert_allclose(osm1, osm2)
        assert_allclose(osr1, osr2)

        assert_raises(ValueError, stats.probplot, x, dist='wrong-dist-name')
        assert_raises(AttributeError, stats.probplot, x, dist=[])

        class custom_dist(object):
            """Some class that looks just enough like a distribution."""
            def ppf(self, q):
                return stats.norm.ppf(q, loc=2)

        osm1, osr1 = stats.probplot(x, sparams=(2,), fit=False)
        osm2, osr2 = stats.probplot(x, dist=custom_dist(), fit=False)
        assert_allclose(osm1, osm2)
        assert_allclose(osr1, osr2) 
開發者ID:Relph1119,項目名稱:GraphicDesignPatternByPython,代碼行數:22,代碼來源:test_morestats.py

示例3: test_plot_kwarg

# 需要導入模塊: from scipy import stats [as 別名]
# 或者: from scipy.stats import probplot [as 別名]
def test_plot_kwarg(self):
        np.random.seed(7654321)
        fig = plt.figure()
        fig.add_subplot(111)
        x = stats.t.rvs(3, size=100)
        res1, fitres1 = stats.probplot(x, plot=plt)
        plt.close()
        res2, fitres2 = stats.probplot(x, plot=None)
        res3 = stats.probplot(x, fit=False, plot=plt)
        plt.close()
        res4 = stats.probplot(x, fit=False, plot=None)
        # Check that results are consistent between combinations of `fit` and
        # `plot` keywords.
        assert_(len(res1) == len(res2) == len(res3) == len(res4) == 2)
        assert_allclose(res1, res2)
        assert_allclose(res1, res3)
        assert_allclose(res1, res4)
        assert_allclose(fitres1, fitres2)

        # Check that a Matplotlib Axes object is accepted
        fig = plt.figure()
        ax = fig.add_subplot(111)
        stats.probplot(x, fit=False, plot=ax)
        plt.close() 
開發者ID:Relph1119,項目名稱:GraphicDesignPatternByPython,代碼行數:26,代碼來源:test_morestats.py

示例4: test_normality_increase_lambert

# 需要導入模塊: from scipy import stats [as 別名]
# 或者: from scipy.stats import probplot [as 別名]
def test_normality_increase_lambert(self):
        # Generate random data and check that it is more normal after inference
        for i, y in enumerate([np.random.standard_cauchy(size=ns), experimental_data]):
            print('Distribution %d' % i)
            print('Before')
            print(('anderson: %0.3f\tshapiro: %0.3f' % (anderson(y)[0], shapiro(y)[0])).expandtabs(30))
            stats.probplot(y, dist="norm", plot=plt)
            plt.savefig(os.path.join(self.test_dir, '%d_before.png' % i))
            plt.clf()
    
            tau = g.igmm(y)
            x = g.w_t(y, tau)
            print('After')
            print(('anderson: %0.3f\tshapiro: %0.3f' % (anderson(x)[0], shapiro(x)[0])).expandtabs(30))
            stats.probplot(x, dist="norm", plot=plt)
            plt.savefig(os.path.join(self.test_dir, '%d_after.png' % i))
            plt.clf() 
開發者ID:gregversteeg,項目名稱:gaussianize,代碼行數:19,代碼來源:test_gaussianize.py

示例5: test_probplot_bad_arg

# 需要導入模塊: from scipy import stats [as 別名]
# 或者: from scipy.stats import probplot [as 別名]
def test_probplot_bad_arg():
    """Raise ValueError when given an invalid distribution."""
    data = [1]
    assert_raises(ValueError, stats.probplot, data, dist="plate_of_shrimp") 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:6,代碼來源:test_morestats.py

示例6: QQ_plot

# 需要導入模塊: from scipy import stats [as 別名]
# 或者: from scipy.stats import probplot [as 別名]
def QQ_plot(self):
        """
        returns the QQ-plot with normal distribution

        """
        plt.figure(figsize=(12, 8), facecolor='w', edgecolor='k',
                   linewidth= 2.0, frameon=True)
        stats.probplot(self.scvr, dist="norm", plot=plt)
        plt.xlabel('SCVR')
        plt.ylabel('Standard quantile')
        plt.show() 
開發者ID:capaulson,項目名稱:pyKriging,代碼行數:13,代碼來源:CrossValidation.py

示例7: test_basic

# 需要導入模塊: from scipy import stats [as 別名]
# 或者: from scipy.stats import probplot [as 別名]
def test_basic(self):
        np.random.seed(12345)
        x = stats.norm.rvs(size=20)
        osm, osr = stats.probplot(x, fit=False)
        osm_expected = [-1.8241636, -1.38768012, -1.11829229, -0.91222575,
                        -0.73908135, -0.5857176, -0.44506467, -0.31273668,
                        -0.18568928, -0.06158146, 0.06158146, 0.18568928,
                        0.31273668, 0.44506467, 0.5857176, 0.73908135,
                        0.91222575, 1.11829229, 1.38768012, 1.8241636]
        assert_allclose(osr, np.sort(x))
        assert_allclose(osm, osm_expected)

        res, res_fit = stats.probplot(x, fit=True)
        res_fit_expected = [1.05361841, 0.31297795, 0.98741609]
        assert_allclose(res_fit, res_fit_expected) 
開發者ID:Relph1119,項目名稱:GraphicDesignPatternByPython,代碼行數:17,代碼來源:test_morestats.py

示例8: test_sparams_keyword

# 需要導入模塊: from scipy import stats [as 別名]
# 或者: from scipy.stats import probplot [as 別名]
def test_sparams_keyword(self):
        np.random.seed(123456)
        x = stats.norm.rvs(size=100)
        # Check that None, () and 0 (loc=0, for normal distribution) all work
        # and give the same results
        osm1, osr1 = stats.probplot(x, sparams=None, fit=False)
        osm2, osr2 = stats.probplot(x, sparams=0, fit=False)
        osm3, osr3 = stats.probplot(x, sparams=(), fit=False)
        assert_allclose(osm1, osm2)
        assert_allclose(osm1, osm3)
        assert_allclose(osr1, osr2)
        assert_allclose(osr1, osr3)
        # Check giving (loc, scale) params for normal distribution
        osm, osr = stats.probplot(x, sparams=(), fit=False) 
開發者ID:Relph1119,項目名稱:GraphicDesignPatternByPython,代碼行數:16,代碼來源:test_morestats.py

示例9: test_probplot_bad_args

# 需要導入模塊: from scipy import stats [as 別名]
# 或者: from scipy.stats import probplot [as 別名]
def test_probplot_bad_args(self):
        # Raise ValueError when given an invalid distribution.
        assert_raises(ValueError, stats.probplot, [1], dist="plate_of_shrimp") 
開發者ID:Relph1119,項目名稱:GraphicDesignPatternByPython,代碼行數:5,代碼來源:test_morestats.py

示例10: test_array_of_size_one

# 需要導入模塊: from scipy import stats [as 別名]
# 或者: from scipy.stats import probplot [as 別名]
def test_array_of_size_one(self):
        with np.errstate(invalid='ignore'):
            assert_equal(stats.probplot([1], fit=True),
                         ((np.array([0.]), np.array([1])),
                          (np.nan, np.nan, 0.0))) 
開發者ID:Relph1119,項目名稱:GraphicDesignPatternByPython,代碼行數:7,代碼來源:test_morestats.py

示例11: test_empty

# 需要導入模塊: from scipy import stats [as 別名]
# 或者: from scipy.stats import probplot [as 別名]
def test_empty(self):
        # For consistency with probplot return for one empty array,
        # ppcc contains all zeros and svals is the same as for normal array
        # input.
        svals, ppcc = stats.ppcc_plot([], 0, 1)
        assert_allclose(svals, np.linspace(0, 1, num=80))
        assert_allclose(ppcc, np.zeros(80, dtype=float)) 
開發者ID:Relph1119,項目名稱:GraphicDesignPatternByPython,代碼行數:9,代碼來源:test_morestats.py

示例12: qqplot

# 需要導入模塊: from scipy import stats [as 別名]
# 或者: from scipy.stats import probplot [as 別名]
def qqplot(self, x: np.ndarray, prefix: Text = 'qq', output_dir: Text = "/tmp/"):
        """Show qq plots compared to normal before and after the transform."""
        x = _update_x(x)
        y = self.transform(x)
        n_dim = y.shape[1]
        for i in range(n_dim):
            stats.probplot(x[:, i], dist="norm", plot=plt)
            plt.savefig(os.path.join(output_dir, prefix + '_%d_before.png' % i))
            plt.clf()
            stats.probplot(y[:, i], dist="norm", plot=plt)
            plt.savefig(os.path.join(output_dir, prefix + '_%d_after.png' % i))
            plt.clf() 
開發者ID:gregversteeg,項目名稱:gaussianize,代碼行數:14,代碼來源:gaussianize.py

示例13: decomp_plot

# 需要導入模塊: from scipy import stats [as 別名]
# 或者: from scipy.stats import probplot [as 別名]
def decomp_plot(df, time, signal, estimator, residue, name = None, format='png', max_length = 1000, horizon = 1) :
    assert(df.shape[0] > 0)
    assert(df.shape[1] > 0)
    assert(time in df.columns)
    assert(signal in df.columns)
    assert(estimator in df.columns)
    assert(residue in df.columns)


    import matplotlib
    # print("MATPLOTLIB_BACKEND",  matplotlib.get_backend())
    # matplotlib.use('Agg')
    import matplotlib.pyplot as plt
    df1 = df.tail(max(max_length , 4 * horizon));
    if(name is not None):
        plt.switch_backend('Agg')
    fig, axs = plt.subplots(ncols=2, figsize=(32, 16))
    lColor = COMPONENT_COLOR;
    if(name is not None and name.endswith("Forecast")):
        lColor = FORECAST_COLOR;
    df1.plot.line(time, [signal, estimator, residue],
                  color=[SIGNAL_COLOR, lColor, RESIDUE_COLOR],
                  ax=axs[0] , grid = True, legend=False)
    add_patched_legend(axs[0] , [signal, estimator, residue])
    residues =  df1[residue].values

    import scipy.stats as scistats
    resid = residues[~np.isnan(residues)]
    scistats.probplot(resid, dist="norm", plot=axs[1])

    if(name is not None):
        plt.switch_backend('Agg')
        fig.savefig(name + '_decomp_output.' + format)
        plt.close(fig) 
開發者ID:antoinecarme,項目名稱:pyaf,代碼行數:36,代碼來源:Plots.py

示例14: decomp_plot_as_png_base64

# 需要導入模塊: from scipy import stats [as 別名]
# 或者: from scipy.stats import probplot [as 別名]
def decomp_plot_as_png_base64(df, time, signal, estimator, residue, name = None, max_length = 1000, horizon = 1) :
    assert(df.shape[0] > 0)
    assert(df.shape[1] > 0)
    assert(time in df.columns)
    assert(signal in df.columns)
    assert(estimator in df.columns)
    assert(residue in df.columns)

    import matplotlib
    # matplotlib.use('Agg')
    import matplotlib.pyplot as plt
    plt.switch_backend('Agg')
    df1 = df.tail(max(max_length, 4 * horizon));
    fig, axs = plt.subplots(ncols=2, figsize=(16, 8))
    lColor = COMPONENT_COLOR;
    if(name is not None and name.endswith("Forecast")):
        lColor = FORECAST_COLOR;
    df1.plot.line(time, [signal, estimator, residue],
                  color=[SIGNAL_COLOR, lColor, RESIDUE_COLOR],
                  ax=axs[0] , grid = True, legend = False)
    add_patched_legend(axs[0] , [signal, estimator, residue])
    residues =  df1[residue].values

    import scipy.stats as scistats
    resid = residues[~np.isnan(residues)]
    scistats.probplot(resid, dist="norm", plot=axs[1])

    figfile = BytesIO()
    fig.savefig(figfile, format='png')
    figfile.seek(0)  # rewind to beginning of file
    figdata_png = base64.b64encode(figfile.getvalue())
    plt.close(fig)
    return figdata_png.decode('utf8') 
開發者ID:antoinecarme,項目名稱:pyaf,代碼行數:35,代碼來源:Plots.py


注:本文中的scipy.stats.probplot方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。