コード例 #1
0
def test_Fit_Gamma_2P():
    dist = Gamma_Distribution(alpha=50, beta=2)
    rawdata = dist.random_samples(20, seed=5)
    data = make_right_censored_data(data=rawdata, threshold=dist.mean)
    fit = Fit_Gamma_2P(failures=data.failures, right_censored=data.right_censored, show_probability_plot=False, print_results=False)
    assert_allclose(fit.alpha, 30.895318057143644,rtol=rtol,atol=atol)
    assert_allclose(fit.beta, 2.5300452644724367,rtol=rtol,atol=atol)
    assert_allclose(fit.gamma, 0,rtol=rtol,atol=atol)
    assert_allclose(fit.AICc, 154.33194705093553,rtol=rtol,atol=atol)
    assert_allclose(fit.Cov_alpha_beta, 11.610666775358292,rtol=rtol,atol=atol)
    assert_allclose(fit.loglik, -74.81303234899717,rtol=rtol,atol=atol)
    assert_allclose(fit.initial_guess[1], 4.878548406768285,rtol=rtol,atol=atol)
コード例 #2
0
def test_Fit_Gamma_3P():
    dist = Gamma_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_Gamma_3P(failures=data.failures, right_censored=data.right_censored, show_probability_plot=False, print_results=False)
    assert_allclose(fit.alpha, 161.86588917785375,rtol=rtol,atol=atol)
    assert_allclose(fit.beta, 0.5429156736189351,rtol=rtol,atol=atol)
    assert_allclose(fit.gamma, 515.4451173341464,rtol=rtol,atol=atol)
    assert_allclose(fit.AICc, 150.01356065455715,rtol=rtol,atol=atol)
    assert_allclose(fit.Cov_alpha_beta, 11.303022319282686,rtol=rtol,atol=atol)
    assert_allclose(fit.loglik, -71.25678032727858,rtol=rtol,atol=atol)
    assert_allclose(fit.initial_guess[1], 0.5957708701483985,rtol=rtol,atol=atol)
コード例 #3
0
def test_Fit_Gamma_3P():
    dist = Gamma_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_Gamma_3P(failures=data.failures,
                       right_censored=data.right_censored,
                       method='MLE',
                       show_probability_plot=False,
                       print_results=False)
    assert_allclose(MLE.alpha, 161.8637212853173, rtol=1e-6,
                    atol=1e-4)  # needs bigger tolerance for Python 3.8 and 3.9
    assert_allclose(MLE.beta, 0.5429184966902371, rtol=1e-6,
                    atol=1e-6)  # needs bigger tolerance for Python 3.8 and 3.9
    assert_allclose(MLE.gamma, 515.4451173341464, rtol=rtol, atol=atol)
    assert_allclose(MLE.AICc, 150.0135606540687, rtol=rtol, atol=atol)
    assert_allclose(MLE.BIC, 151.50075747473068, rtol=rtol, atol=atol)
    assert_allclose(MLE.loglik, -71.25678032703435, rtol=rtol, atol=atol)
    assert_allclose(MLE.AD, 38.63647775048046, rtol=rtol, atol=atol)
    assert_allclose(
        MLE.Cov_alpha_beta, 11.302538880460721, rtol=1e-4,
        atol=0.0002)  # needs bigger tolerance for Python 3.8 and 3.9

    LS = Fit_Gamma_3P(failures=data.failures,
                      right_censored=data.right_censored,
                      method='LS',
                      show_probability_plot=False,
                      print_results=False)
    assert_allclose(LS.alpha, 67.82751726558604, rtol=1e-6,
                    atol=1e-4)  # needs bigger tolerance for Python 3.8 and 3.9
    assert_allclose(LS.beta, 31.29226170989501, rtol=1e-6,
                    atol=1e-6)  # needs bigger tolerance for Python 3.8 and 3.9
    assert_allclose(LS.gamma, 505.13533298746347, rtol=rtol, atol=atol)
    assert_allclose(LS.AICc, 2727.0287032370256, rtol=rtol, atol=atol)
    assert_allclose(LS.BIC, 2728.5159000576878, rtol=rtol, atol=atol)
    assert_allclose(LS.loglik, -1359.7643516185128, rtol=rtol, atol=atol)
    assert_allclose(LS.AD, 574.8571449781781, rtol=rtol, atol=atol)
    assert_allclose(
        LS.Cov_alpha_beta, 2.4557691690459174, rtol=1e-4,
        atol=0.0002)  # needs bigger tolerance for Python 3.8 and 3.9
コード例 #4
0
def test_Fit_Gamma_2P():
    dist = Gamma_Distribution(alpha=50, beta=2)
    rawdata = dist.random_samples(20, seed=5)
    data = make_right_censored_data(data=rawdata, threshold=dist.mean)

    MLE = Fit_Gamma_2P(failures=data.failures,
                       right_censored=data.right_censored,
                       method='MLE',
                       show_probability_plot=False,
                       print_results=False)
    assert_allclose(MLE.alpha, 30.895317427895733, rtol=rtol, atol=atol)
    assert_allclose(MLE.beta, 2.5300452519936405, rtol=rtol, atol=atol)
    assert_allclose(MLE.gamma, 0, rtol=rtol, atol=atol)
    assert_allclose(MLE.AICc, 154.33194705093553, rtol=rtol, atol=atol)
    assert_allclose(MLE.BIC, 155.61752924510233, rtol=rtol, atol=atol)
    assert_allclose(MLE.loglik, -74.81303234899717, rtol=rtol, atol=atol)
    assert_allclose(MLE.AD, 38.004356262808585, rtol=rtol, atol=atol)
    assert_allclose(MLE.Cov_alpha_beta,
                    -11.610946543514364,
                    rtol=rtol,
                    atol=atol)

    LS = Fit_Gamma_2P(failures=data.failures,
                      right_censored=data.right_censored,
                      method='LS',
                      show_probability_plot=False,
                      print_results=False)
    assert_allclose(LS.alpha, 25.803340662553182, rtol=rtol, atol=atol)
    assert_allclose(LS.beta, 2.8344248030280284, rtol=rtol, atol=atol)
    assert_allclose(LS.gamma, 0, rtol=rtol, atol=atol)
    assert_allclose(LS.AICc, 154.55898223226797, rtol=rtol, atol=atol)
    assert_allclose(LS.BIC, 155.84456442643477, rtol=rtol, atol=atol)
    assert_allclose(LS.loglik, -74.92654993966339, rtol=rtol, atol=atol)
    assert_allclose(LS.AD, 38.01670664187149, rtol=rtol, atol=atol)
    assert_allclose(LS.Cov_alpha_beta,
                    -5.761109354575602,
                    rtol=rtol,
                    atol=atol)