def test_histogram():
    plt.ion()
    dist = Weibull_Distribution(alpha=30, beta=4)
    samples = dist.random_samples(500, seed=2)
    plt.subplot(121)
    histogram(samples, white_above=dist.mean)
    plt.subplot(122)
    histogram(samples, white_above=dist.mean, cumulative=True)
    plt.show()
    plt.close()
    plt.ioff()
示例#2
0
def test_Fit_Weibull_2P():
    dist = Weibull_Distribution(alpha=50, beta=2)
    rawdata = dist.random_samples(20, seed=5)
    data = make_right_censored_data(data=rawdata, threshold=dist.mean)
    fit = Fit_Weibull_2P(failures=data.failures, right_censored=data.right_censored, show_probability_plot=False, print_results=False)
    assert_allclose(fit.alpha, 45.099010886086354,rtol=rtol,atol=atol)
    assert_allclose(fit.beta, 2.7827531773597975,rtol=rtol,atol=atol)
    assert_allclose(fit.gamma, 0,rtol=rtol,atol=atol)
    assert_allclose(fit.AICc, 115.66971887883678,rtol=rtol,atol=atol)
    assert_allclose(fit.Cov_alpha_beta, 0.9178064889295382,rtol=rtol,atol=atol)
    assert_allclose(fit.loglik, -55.4819182629478,rtol=rtol,atol=atol)
    assert_allclose(fit.initial_guess[1], 2.96571536864614,rtol=rtol,atol=atol)
示例#3
0
def test_Fit_Weibull_3P():
    dist = Weibull_Distribution(alpha=50, beta=2, gamma=500)
    rawdata = dist.random_samples(20, seed=5)
    data = make_right_censored_data(data=rawdata, threshold=dist.mean)
    fit = Fit_Weibull_3P(failures=data.failures, right_censored=data.right_censored, show_probability_plot=False, print_results=False)
    assert_allclose(fit.alpha, 41.38429989624438,rtol=rtol,atol=atol)
    assert_allclose(fit.beta, 0.6941872050001636,rtol=rtol,atol=atol)
    assert_allclose(fit.gamma, 514.5074549826453,rtol=rtol,atol=atol)
    assert_allclose(fit.AICc, 114.68964821342475,rtol=rtol,atol=atol)
    assert_allclose(fit.Cov_alpha_beta, 1.3076497743444904,rtol=rtol,atol=atol)
    assert_allclose(fit.loglik, -53.59482410671237,rtol=rtol,atol=atol)
    assert_allclose(fit.initial_guess[1], 1.2001459605994476,rtol=rtol,atol=atol)
示例#4
0
def test_Fit_Weibull_3P():
    dist = Weibull_Distribution(alpha=50, beta=2, gamma=500)
    rawdata = dist.random_samples(20, seed=5)
    data = make_right_censored_data(data=rawdata, threshold=dist.mean)

    MLE = Fit_Weibull_3P(failures=data.failures,
                         right_censored=data.right_censored,
                         method='MLE',
                         show_probability_plot=False,
                         print_results=False)
    assert_allclose(MLE.alpha, 33.012333115455654, rtol=rtol, atol=atol)
    assert_allclose(MLE.beta, 1.3273429690012193, rtol=rtol, atol=atol)
    assert_allclose(MLE.gamma, 513.7219668227023, rtol=rtol, atol=atol)
    assert_allclose(MLE.AICc, 116.53275812088592, rtol=rtol, atol=atol)
    assert_allclose(MLE.BIC, 118.0199549415479, rtol=rtol, atol=atol)
    assert_allclose(MLE.loglik, -54.51637906044296, rtol=rtol, atol=atol)
    assert_allclose(MLE.AD, 55.6067996515715, rtol=rtol, atol=atol)
    assert_allclose(MLE.Cov_alpha_beta,
                    -0.7687692976797089,
                    rtol=rtol,
                    atol=atol)

    LS = Fit_Weibull_3P(failures=data.failures,
                        right_censored=data.right_censored,
                        method='LS',
                        show_probability_plot=False,
                        print_results=False)
    assert_allclose(LS.alpha, 32.639290779819824, rtol=rtol, atol=atol)
    assert_allclose(LS.beta, 1.2701961119432184, rtol=rtol, atol=atol)
    assert_allclose(LS.gamma, 514.5065549826453, rtol=rtol, atol=atol)
    assert_allclose(LS.AICc, 119.47369772704523, rtol=rtol, atol=atol)
    assert_allclose(LS.BIC, 120.96089454770721, rtol=rtol, atol=atol)
    assert_allclose(LS.loglik, -55.98684886352262, rtol=rtol, atol=atol)
    assert_allclose(LS.AD, 55.70853682331155, rtol=rtol, atol=atol)
    assert_allclose(LS.Cov_alpha_beta,
                    -0.8435523816679948,
                    rtol=rtol,
                    atol=atol)
示例#5
0
def test_Fit_Weibull_2P():
    dist = Weibull_Distribution(alpha=50, beta=2)
    rawdata = dist.random_samples(20, seed=5)
    data = make_right_censored_data(data=rawdata, threshold=dist.mean)

    MLE = Fit_Weibull_2P(failures=data.failures,
                         right_censored=data.right_censored,
                         method='MLE',
                         show_probability_plot=False,
                         print_results=False)
    assert_allclose(MLE.alpha, 45.099010886086354, rtol=rtol, atol=atol)
    assert_allclose(MLE.beta, 2.7827531773597984, rtol=rtol, atol=atol)
    assert_allclose(MLE.gamma, 0, rtol=rtol, atol=atol)
    assert_allclose(MLE.AICc, 115.66971887883678, rtol=rtol, atol=atol)
    assert_allclose(MLE.BIC, 116.95530107300358, rtol=rtol, atol=atol)
    assert_allclose(MLE.loglik, -55.4819182629478, rtol=rtol, atol=atol)
    assert_allclose(MLE.AD, 55.60004028891652, rtol=rtol, atol=atol)
    assert_allclose(MLE.Cov_alpha_beta,
                    -0.9178064889295378,
                    rtol=rtol,
                    atol=atol)

    LS = Fit_Weibull_2P(failures=data.failures,
                        right_censored=data.right_censored,
                        method='LS',
                        show_probability_plot=False,
                        print_results=False)
    assert_allclose(LS.alpha, 42.91333312142757, rtol=rtol, atol=atol)
    assert_allclose(LS.beta, 2.9657153686461033, rtol=rtol, atol=atol)
    assert_allclose(LS.gamma, 0, rtol=rtol, atol=atol)
    assert_allclose(LS.AICc, 115.93668384456019, rtol=rtol, atol=atol)
    assert_allclose(LS.BIC, 117.222266038727, rtol=rtol, atol=atol)
    assert_allclose(LS.loglik, -55.61540074580951, rtol=rtol, atol=atol)
    assert_allclose(LS.AD, 55.62807482958476, rtol=rtol, atol=atol)
    assert_allclose(LS.Cov_alpha_beta,
                    -0.1119680481788733,
                    rtol=rtol,
                    atol=atol)