Ejemplo n.º 1
0
def plot_all_models(path_to_data, init_guess = 0.000001):
    data = dp.read_data(path_to_data)
    time_passed = data[-1] - data[-2]
    jm_data = data[:]
    times_of_falls = dp.convert_time_between_errors_to_time_of_errors(data)[:-1]
    time_of_last_error = dp.time_of_last_error(data)
    m = Musa(time_passed, times_of_falls, init_guess)
    mo = MusaOkumoto(time_passed, times_of_falls, init_guess)
    j = JelinskiMoranda(jm_data)
    plot.add_errors_plot(data, {'label': 'Real errors'}) # label = 'Real error'
    plot.add_func_plot(m._mu, 0, 1*time_of_last_error, 100, {'label': "Musa"})     # style : '--', label = "Musa"
    plot.add_func_plot(mo._mu, 0, 1*time_of_last_error, 100, {'label': "Musa-Okumoto"})    # style : '-.', label = "Musa - Okumoto"
    plot.add_func_plot(j.func_n, 0, 1*time_of_last_error, 100, {'label': 'Jelinsky-Moranda'})  # style : ':',  label = "Jelinski - Moranda"

    plot.legend()

    # with open("G:/dynamic_models.csv", 'w+') as f:
    #     f.write('tau\treal_error\tmusa\tmusa_okumoto\tjm\n')
    #     err = 1
    #     for i in tau:
    #         f.write("{0:.2f}\t{1}\t{2:.2f}\t{3:.2f}\t{4:.2f}\n".format(i, err, m._mu(i)[0], mo._mu(i)[0], j.func_n(i)[0]))
    #         err += 1

    plot.xlabel("Time")
    plot.ylabel("Number of erros")
    plot.grid()
    plot.show()
Ejemplo n.º 2
0
def get_musa_okumoto_data(path_to_data):
    data = dp.read_data(path_to_data)
    time_passed = data[-1] - data[-2]
    errors = dp.convert_time_between_errors_to_time_of_errors(data)
    times_of_falls = errors[:-1]
    time_of_last_error = times_of_falls[-1]
    init_guess = 0.00000001
    m = MusaOkumoto(time_passed, times_of_falls, init_guess)

    x = [int(i) for i in np.linspace(1, 1.2 * time_of_last_error, 20)]
    # Mean time of errors to the time of work
    y_mu = [int(m.func_mu(i)) for i in x]
    # Failure raite aka Intensivnost otkazov
    y_lambda = [round(float(m.func_lambd(i)), 4) for i in x]
    # Reliability function aka Funkciya nadezhnosti
    prediction_time_of_work = 100
    y_r = [round(float(m.func_r(i, prediction_time_of_work)), 4) for i in x]

    return {
        'mu': {
            'x': x,
            'y': y_mu
        },
        'lambda': {
            'x': x,
            'y': y_lambda
        },
        'r': {
            'x': x,
            'y': y_r
        },
        'errors_time': data
    }
Ejemplo n.º 3
0
def get_jelinski_moranda_data(path_to_data):

    data = dp.read_data(path_to_data)
    times_of_falls = data[:]
    j = JelinskiMoranda(times_of_falls)
    time_of_last_error = dp.time_of_last_error(times_of_falls)
    x = [int(i) for i in np.linspace(1, 1.2 * time_of_last_error, 20)]
    y_n = [round(float(j.func_n(i)), 4) for i in x]  #  Mean value of errors
    # TODO: Test this plots
    x_numbers_of_errors = [i for i in range(len(times_of_falls))]
    y_mttf = [int(j.func_MTTF(i)) for i in x_numbers_of_errors]
    y_lambda = [
        round(float(j.func_lambda(i)), 4) for i in x_numbers_of_errors
    ]  #  Intensity of errors - Step chart
    y_r = [round(float(j.func_R(i)), 4)
           for i in x_numbers_of_errors]  #  Reliability - Step chart
    return {
        'n': {
            'x': x,
            'y': y_n
        },
        'mttf': {
            'x': x_numbers_of_errors,
            'y': y_mttf
        },
        'lambda': {
            'x': x_numbers_of_errors,
            'y': y_lambda
        },
        'r': {
            'x': x_numbers_of_errors,
            'y': y_r
        },
        'errors_time': times_of_falls
    }
Ejemplo n.º 4
0
def plot_all_models(path_to_data, init_guess=0.000001):
    data = dp.read_data(path_to_data)
    time_passed = data[-1] - data[-2]
    jm_data = data[:]
    times_of_falls = dp.convert_time_between_errors_to_time_of_errors(
        data)[:-1]
    time_of_last_error = dp.time_of_last_error(data)
    m = Musa(time_passed, times_of_falls, init_guess)
    mo = MusaOkumoto(time_passed, times_of_falls, init_guess)
    j = JelinskiMoranda(jm_data)
    plot.add_errors_plot(data,
                         {'label': 'Real errors'})  # label = 'Real error'
    plot.add_func_plot(m._mu, 0, 1 * time_of_last_error, 100,
                       {'label': "Musa"})  # style : '--', label = "Musa"
    plot.add_func_plot(
        mo._mu, 0, 1 * time_of_last_error, 100,
        {'label': "Musa-Okumoto"})  # style : '-.', label = "Musa - Okumoto"
    plot.add_func_plot(j.func_n, 0, 1 * time_of_last_error, 100,
                       {'label': 'Jelinsky-Moranda'
                        })  # style : ':',  label = "Jelinski - Moranda"

    plot.legend()

    # with open("G:/dynamic_models.csv", 'w+') as f:
    #     f.write('tau\treal_error\tmusa\tmusa_okumoto\tjm\n')
    #     err = 1
    #     for i in tau:
    #         f.write("{0:.2f}\t{1}\t{2:.2f}\t{3:.2f}\t{4:.2f}\n".format(i, err, m._mu(i)[0], mo._mu(i)[0], j.func_n(i)[0]))
    #         err += 1

    plot.xlabel("Time")
    plot.ylabel("Number of erros")
    plot.grid()
    plot.show()
Ejemplo n.º 5
0
def musa_okumoto_plot(path_to_data):
    data = dp.read_data(path_to_data)
    time_passed = data[-1] - data[-2]
    errors = dp.convert_time_between_errors_to_time_of_errors(data)
    times_of_falls = errors[:-1]
    init_guess = 0.00000001
    m = MusaOkumoto(time_passed, times_of_falls, init_guess)
    plot.add_errors_plot(data)
    plot.add_func_plot(m._mu, 0, 1.2 * m.t[-1], 1000)
    plot.grid()
    plot.show()
Ejemplo n.º 6
0
def jelinski_moranda_plot_errors(path_to_data):
    '''Plot Errors for Jelinsky-moranda model'''
    data = dp.read_data(path_to_data)
    times_of_falls = data[:]
    j = JelinskiMoranda(times_of_falls)
    plot.add_errors_plot(times_of_falls)
    plot.add_func_plot(j.func_n, 0, dp.time_of_last_error(times_of_falls), 1000)
    plot.xlabel("Time")
    plot.ylabel("Errors")
    plot.grid()
    plot.show()
Ejemplo n.º 7
0
def musa_okumoto_plot(path_to_data):
    data = dp.read_data(path_to_data)
    time_passed = data[-1] - data[-2]
    errors = dp.convert_time_between_errors_to_time_of_errors(data)
    times_of_falls = errors[:-1]
    init_guess = 0.00000001
    m = MusaOkumoto(time_passed, times_of_falls, init_guess)
    plot.add_errors_plot(data)
    plot.add_func_plot(m._mu, 0, 1.2 * m.t[-1], 1000)
    plot.grid()
    plot.show()
Ejemplo n.º 8
0
def jelinski_moranda_plot_errors(path_to_data):
    '''Plot Errors for Jelinsky-moranda model'''
    data = dp.read_data(path_to_data)
    times_of_falls = data[:]
    j = JelinskiMoranda(times_of_falls)
    plot.add_errors_plot(times_of_falls)
    plot.add_func_plot(j.func_n, 0, dp.time_of_last_error(times_of_falls),
                       1000)
    plot.xlabel("Time")
    plot.ylabel("Errors")
    plot.grid()
    plot.show()
Ejemplo n.º 9
0
def plot_musa_and_musa_okumoto(path_to_data):
    data =dp.read_data(path_to_data)
    time_passed = data[-1] - data[-2]
    times_of_errors = dp.convert_time_between_errors_to_time_of_errors(data)[:-1]
    init_guess = 0.00000001
    time_of_last_error = dp.time_of_last_error(data)
    m = Musa(time_passed, times_of_errors, init_guess)
    mo = MusaOkumoto(time_passed, times_of_errors, init_guess)
    plot.add_errors_plot(data)
    plot.add_func_plot(m._mu, 0, 1.2 * time_of_last_error, 1000)
    plot.add_func_plot(mo._mu, 0, 1.2 * time_of_last_error, 1000)
    plot.xlabel("Time")
    plot.ylabel("Errors")
    plot.grid()
    plot.show()
Ejemplo n.º 10
0
def plot_musa_and_musa_okumoto(path_to_data):
    data = dp.read_data(path_to_data)
    time_passed = data[-1] - data[-2]
    times_of_errors = dp.convert_time_between_errors_to_time_of_errors(
        data)[:-1]
    init_guess = 0.00000001
    time_of_last_error = dp.time_of_last_error(data)
    m = Musa(time_passed, times_of_errors, init_guess)
    mo = MusaOkumoto(time_passed, times_of_errors, init_guess)
    plot.add_errors_plot(data)
    plot.add_func_plot(m._mu, 0, 1.2 * time_of_last_error, 1000)
    plot.add_func_plot(mo._mu, 0, 1.2 * time_of_last_error, 1000)
    plot.xlabel("Time")
    plot.ylabel("Errors")
    plot.grid()
    plot.show()
Ejemplo n.º 11
0
def get_jelinski_moranda_data(path_to_data):

    data = dp.read_data(path_to_data)
    times_of_falls = data[:]
    j = JelinskiMoranda(times_of_falls)
    time_of_last_error = dp.time_of_last_error(times_of_falls)
    x = [int(i) for i in np.linspace(1, 1.2 * time_of_last_error, 20)]
    y_n = [round(float(j.func_n(i)), 4) for i in x]                                 #  Mean value of errors
    # TODO: Test this plots
    x_numbers_of_errors = [i for i in range(len(times_of_falls))]
    y_mttf = [int(j.func_MTTF(i)) for i in x_numbers_of_errors]
    y_lambda = [round(float(j.func_lambda(i)), 4) for i in x_numbers_of_errors]     #  Intensity of errors - Step chart
    y_r = [round(float(j.func_R(i)), 4) for i in x_numbers_of_errors]               #  Reliability - Step chart
    return {'n': {'x': x, 'y': y_n},
            'mttf': {'x': x_numbers_of_errors, 'y': y_mttf},
            'lambda': {'x': x_numbers_of_errors, 'y': y_lambda},
            'r': {'x': x_numbers_of_errors, 'y': y_r},
            'errors_time': times_of_falls}
Ejemplo n.º 12
0
def jelinski_moranda_MTTF(path_to_data, file_to_write_data = ''):
    data = dp.read_data(path_to_data)
    times_of_falls = data[:]
    j = JelinskiMoranda(times_of_falls)
    x = [i for i in range(len(times_of_falls))]
    y = [j.func_MTTF(i) for i in x]

    if file_to_write_data:
        with open(file_to_write_data, 'w+') as f:
            f.write("i\treal_falls\tmttf\n")
            for i in range(len(times_of_falls)):
                f.write("{0}\t{1}\t{2:.2f}\n".format(i, times_of_falls[i], y[i][0]))

    plot.add_xy_plot(x, y)           # style '--', label = 'JM-model error'
    plot.add_xy_plot(x, times_of_falls) # style label = 'Real error'
    plot.xlabel("Error")
    plot.ylabel("Mean time error")
    plot.grid()
    plot.show()
Ejemplo n.º 13
0
def jelinski_moranda_MTTF(path_to_data, file_to_write_data=''):
    data = dp.read_data(path_to_data)
    times_of_falls = data[:]
    j = JelinskiMoranda(times_of_falls)
    x = [i for i in range(len(times_of_falls))]
    y = [j.func_MTTF(i) for i in x]

    if file_to_write_data:
        with open(file_to_write_data, 'w+') as f:
            f.write("i\treal_falls\tmttf\n")
            for i in range(len(times_of_falls)):
                f.write("{0}\t{1}\t{2:.2f}\n".format(i, times_of_falls[i],
                                                     y[i][0]))

    plot.add_xy_plot(x, y)  # style '--', label = 'JM-model error'
    plot.add_xy_plot(x, times_of_falls)  # style label = 'Real error'
    plot.xlabel("Error")
    plot.ylabel("Mean time error")
    plot.grid()
    plot.show()
Ejemplo n.º 14
0
def get_musa_data(path_to_data):
    data = dp.read_data(path_to_data)
    time_passed = data[-1] - data[-2]
    errors = dp.convert_time_between_errors_to_time_of_errors(data)
    times_of_falls = errors[:-1]
    time_of_last_error = times_of_falls[-1]
    init_guess = 0.000001
    m = Musa(time_passed, times_of_falls, init_guess)

    x = [int(i) for i in np.linspace(1, 1.2 * time_of_last_error, 20)]
    # Mean number of errors to the time of work
    y_mu = [int(m.func_mu(i)) for i in x]
    # Failure raite aka Intensivnost otkazov
    y_lambda = [round(float(m.func_lambd(i)),4) for i in x]
    # Reliability function aka Funkciya nadezhnosti
    prediction_time_of_work = 100
    y_r = [round(float(m.func_r(i, prediction_time_of_work)),4) for i in x]

    return {
        'mu': {'x': x, 'y': y_mu},
        'lambda': {'x': x, 'y': y_lambda},
        'r': {'x': x, 'y': y_r},
        'errors_time': data}