コード例 #1
0
ファイル: model_generation.py プロジェクト: githubmlai/TCCS
def plot_sample_and_theoretical_pdf_of_abs_fft_noise(
    fft_well_log,
    list_wave_number,
    list_hurst_related_exponent,
    list_characteristic_distance,
    squared_energy_of_window,
    variance_of_noise_in_time_domain,
    output_directory,
    output_file_base_name,
    figure_output_settings,
):

    figure = plt.figure()
    # sample pdf (histogram)
    for hurst_related_exponent_local, characteristic_dist_local in zip(
        list_hurst_related_exponent, list_characteristic_distance
    ):
        von_karman_energy_spectrum = calc_von_karman_energy_spectrum(
            list_wave_number, hurst_related_exponent_local, characteristic_dist_local
        )
        rayleigh_rand_var_instance = calc_rayleigh_rand_var_instances_from_fft_well_log(
            fft_well_log, von_karman_energy_spectrum
        )
        label_str = "(%.3f,%.3f)" % (hurst_related_exponent_local, characteristic_dist_local)
        plt.hist(rayleigh_rand_var_instance, bins=100, normed=True, label=label_str, histtype="step")
        plt.legend(loc="upper right")

        # theoretical pdf
    random_variable = make_rayleigh_rand_var_of_abs_fft_noise(
        squared_energy_of_window, variance_of_noise_in_time_domain
    )
    support = np.linspace(0, max(np.abs(fft_well_log)))
    plt.plot(support, random_variable.pdf(support))

    output_file = output_directory + os.path.sep + output_file_base_name
    ph.saveFigureToFile(figure, output_file, **figure_output_settings)
コード例 #2
0
ファイル: main.py プロジェクト: githubmlai/TCCS
                likelihood_by_hurst_characteristic = 1 / brute_opt_result[3]
                                # the third return argument of brute search is the search grid,
                                # so likelihood_by_hurst_characteristic should be the value *inside* those bounds.
                                # Therefore, remove the last value from likelihood_by_hurst_characteristic
                likelihood_by_hurst_characteristic = likelihood_by_hurst_characteristic[:-1, :-1]
                p = ax.pcolormesh(brute_opt_result[2][1],
                                  brute_opt_result[2][0],
                                  likelihood_by_hurst_characteristic)
                figure.colorbar(p)
                plt.xlabel('b (characteristic_distance)')
                plt.xticks(rotation=90)
                plt.ylabel('H (hurst_related_exponent)')
                ax.set_title(exhaustive_search_result_str)
                output_file_base_name = "true_v_opt_b_H"
                output_file = output_directory + os.path.sep + output_file_base_name
                plot_helper.saveFigureToFile(figure, output_file, **figure_output_settings)

                            # constrained optimization
            do_box_constrained_optimization = 0
            if do_box_constrained_optimization:
                hurst_hurst_related_exponent_min = -0.49
                hurst_hurst_related_exponent_max = 1.0
                characteristic_dist_min = 1.0
                characteristic_dist_max = 12.0

                initial_guess = (0.5 * (hurst_hurst_related_exponent_min + hurst_hurst_related_exponent_max),
                                 0.5 * (characteristic_dist_min + characteristic_dist_max))
                minimize_result = optimize.minimize(likelihood_measure.calc_inverse_likelihood,
                                                    initial_guess,
                                                    args=params,
                                                    method="TNC",