Exemplo n.º 1
0
def main():
    # Чтение данных тестов
    n, mu, sigm, alpha, precision, histogram_run, charts_run = ff.read_tests_settings(
        INPUT_PATH + TESTS_FILENAME)
    a, b = alg.get_bounds(mu, sigm)
    # Формирование последовательности
    sequence, density, count, modeling_time = alg.make_sequence(
        n, a, b, mu, sigm)
    # Формирование интервалов
    intervals, intervals_width = alg.get_intervals(sequence)
    hits, v = alg.interval_hits(sequence, intervals)
    # Тест критерия Хи-квадрат
    chi2_r, chi2_S, chi2_PSS, chi2_passed = alg.chi2_test(
        sequence, intervals, hits, mu, sigm, alpha)
    # Тест критерия Смирнова
    sm_S, sm_PSS, sm_passed = alg.smirnov_test(sequence, mu, sigm, alpha)
    ff.write_tests_results(OUTPUT_PATH + TESTS_RESULT, precision, mu, sigm,
                           alpha, a, b, sequence, density, count, intervals,
                           hits, modeling_time, chi2_r, chi2_S, chi2_PSS,
                           chi2_passed, sm_S, sm_PSS, sm_passed)
    if histogram_run:
        alg.make_histogram(OUTPUT_PATH + HISTOGRAM, intervals, intervals_width,
                           v, mu, sigm)
    if charts_run:
        alg.make_charts(OUTPUT_PATH + DENSITY_CHART,
                        OUTPUT_PATH + DISTRIBUTION_CHART, a, b, mu, sigm)
Exemplo n.º 2
0
def main():
    # Чтение данных тестов
    n_list, correction_n, sigm, alpha, precision, histogram_run, chart_run = read_tests_settings(INPUT_PATH + TESTS_FILENAME)
    # Инициализация параметров для выполнения нескольких распределений
    DISTR_COUNT    = 2
    DISTR_TITLE    = ["Рэлея", "Нормального"]
    DISTR_FILENAME = ["rayleigh", "norm"]
    EMPIRIC_DISTR  = [distr2.rayleigh_distribution, distr2.normal_distribution]
    THEOR_DISTR    = [distr2.rayleigh.cdf, distr2.norm.cdf]
    # Неиспользуемый параметр loc для распределения Рэлея
    ARGS_LIST      = [[0, sigm, correction_n], [correction_n]]
    ARGS_LABEL     = [["_", "sigm", "correction_n"], ["correction_n"]]
    for i in range(DISTR_COUNT):
        for j in range(len(n_list)):
            # Формирование последовательности
            sequence, modeling_time = alg.make_sequence(n_list[j], EMPIRIC_DISTR[i], *ARGS_LIST[i])
            # Формирование интервалов
            intervals, intervals_width = alg.get_intervals(sequence)
            hits, v = alg.interval_hits(sequence, intervals)
            # Тест критерия Хи-квадрат
            chi2_r, chi2_S, chi2_PSS, chi2_passed = alg.chi2_test(n_list[j], intervals, hits, alpha, THEOR_DISTR[i], *ARGS_LIST[i][:-1])
            # Тест критерия Крамера-Мизеса-Смирнов
            cms_S, cms_PSS, cms_passed = alg.cms_test(sequence, alpha, THEOR_DISTR[i], *ARGS_LIST[i][:-1])
            ff.write_tests_results(OUTPUT_PATH + ff.get_filename(DISTR_FILENAME[i], TESTS_RESULT, n_list[j]), precision, 
                                   ARGS_LIST[i][1:], ARGS_LABEL[i][1:], alpha, sequence, intervals, hits, modeling_time,
                                   chi2_r, chi2_S, chi2_PSS, chi2_passed, cms_S, cms_PSS, cms_passed)
            if histogram_run:
                alg.make_histogram(OUTPUT_PATH + ff.get_filename(DISTR_FILENAME[i], HISTOGRAM, n_list[j]), 
                                   HISTOGRAM_TITLE + DISTR_TITLE[i], intervals, intervals_width, v, THEOR_DISTR[i], *ARGS_LIST[i][:-1])
        if chart_run:
            alg.make_chart(OUTPUT_PATH + ff.get_filename(DISTR_FILENAME[i], CHART), 
                           CHART_TITLE + DISTR_TITLE[i], THEOR_DISTR[i], *ARGS_LIST[i][:-1])
Exemplo n.º 3
0
def main():
    # Чтение данных тестов
    n_list, mu, nu, k, alpha, precision, histogram_run, chart_run = read_tests_settings(INPUT_PATH + TESTS_FILENAME)
    # Инициализация параметров для выполнения нескольких распределений
    DISTR_COUNT    = 3
    DISTR_TITLE    = ["Фишера", "Хи-квадрат", "Нормального"]
    DISTR_FILENAME = ["fisher", "chi2", "norm"]
    EMPIRIC_DISTR  = [distr1.fisher_distribution, distr1.chi2_distribution, distr1.normal_distribution]
    THEOR_DISTR    = [distr1.f.cdf, distr1.chi2.cdf, distr1.norm.cdf]
    ARGS_LIST      = [[mu, nu], [k], []]
    ARGS_LABEL     = [["mu", "nu"], ["k"], []]
    for i in range(DISTR_COUNT):
        for j in range(len(n_list)):
            # Формирование последовательности
            sequence, modeling_time = alg.make_sequence(n_list[j], EMPIRIC_DISTR[i], *ARGS_LIST[i])
            # Формирование интервалов
            intervals, intervals_width = alg.get_intervals(sequence)
            hits, v = alg.interval_hits(sequence, intervals)
            # Тест критерия Хи-квадрат
            chi2_r, chi2_S, chi2_PSS, chi2_passed = alg.chi2_test(n_list[j], intervals, hits, alpha, THEOR_DISTR[i], *ARGS_LIST[i])
            # Тест критерия Крамера-Мизеса-Смирнов
            cms_S, cms_PSS, cms_passed = alg.cms_test(sequence, alpha, THEOR_DISTR[i], *ARGS_LIST[i])
            ff.write_tests_results(OUTPUT_PATH + ff.get_filename(DISTR_FILENAME[i], TESTS_RESULT, n_list[j]), precision, 
                                   ARGS_LIST[i], ARGS_LABEL[i], alpha, sequence, intervals, hits, modeling_time,
                                   chi2_r, chi2_S, chi2_PSS, chi2_passed, cms_S, cms_PSS, cms_passed)
            if histogram_run:
                alg.make_histogram(OUTPUT_PATH + ff.get_filename(DISTR_FILENAME[i], HISTOGRAM, n_list[j]), 
                                   HISTOGRAM_TITLE + DISTR_TITLE[i], intervals, intervals_width, v, THEOR_DISTR[i], *ARGS_LIST[i])
        if chart_run:
            alg.make_chart(OUTPUT_PATH + ff.get_filename(DISTR_FILENAME[i], CHART), 
                           CHART_TITLE + DISTR_TITLE[i], THEOR_DISTR[i], *ARGS_LIST[i])
Exemplo n.º 4
0
def main():
    # Чтение данных тестов
    n, sigm, alpha, precision, histogram_run, charts_run = ff.read_tests_settings(INPUT_PATH + TESTS_FILENAME)
    # Формирование последовательности
    sequence, modeling_time = alg.make_sequence(n, sigm)
    # Формирование интервалов
    intervals = alg.get_intervals(sequence)
    hits, v = alg.interval_hits(sequence, intervals)
    # Тест критерия типа Хи-квадрат
    chi2_r, chi2_S, chi2_PSS, chi2_passed = alg.chi2_test(sequence, intervals, hits, sigm, alpha)
    # Тест критерия типа Омега-квадрат Андерса-Дарлинга
    ad_S, ad_PSS, ad_passed = alg.anderson_darling_test(sequence, sigm, alpha)
    ff.write_tests_results(OUTPUT_PATH + TESTS_RESULT, precision, sigm, alpha, sequence, intervals, hits, modeling_time,
                           chi2_r, chi2_S, chi2_PSS, chi2_passed, ad_S, ad_PSS, ad_passed)
    if histogram_run:
        alg.make_histogram(OUTPUT_PATH + HISTOGRAM, intervals, v, sigm)
    if charts_run:
        alg.make_charts(OUTPUT_PATH + DENSITY_CHART, OUTPUT_PATH + DISTRIBUTION_CHART, sigm)