Пример #1
0
            ax = fig.add_axes([0.10, 0.15, 0.85, 0.75])
            plt.plot(chn[::nthin2, j + 1],
                     chn[::nthin2, i + 1],
                     'o',
                     markeredgecolor='blue',
                     markerfacecolor='b',
                     markersize=5)
            ax.set_xlabel(vnames[j], fontsize=22)
            ax.set_ylabel(vnames[i], fontsize=22)
            plt.savefig('line_infer.chn_' + vnames[j] + '_' + vnames[i] +
                        '.pdf')
            plt.clf()

    ## Plot posterior PDF 'triangle' ################################################
    np_kde = 100
    postp.plot_all_posteriors(chn[:, 1:], vnames, np_kde,
                              "line_infer.posteriors", debug, dense_plots)

if generate_stats:
    postp.get_mcmc_stats(all_samples, vnames, "line_infer", debug)

# ## Find PC coefficients corresponding to the chain samples #######################
# samfile="chain_samples.dat"
# # save chain samples minus the step column
# np.savetxt(samfile,chn[:,1:])
# print("Running KDE-Rosenblatt transformation to build input PCE")
# cmd = pcequad+' -o' + str(pcord)+' -f ' + samfile + ' -x ' + pctype + ' -w' + str(bw) + ' > pcequad.log'
# print("Running",cmd)
# os.system(cmd)

# for res_file in [chainfile, samfile, 'quadpts.dat', 'quadpts_mapped.dat', 'PCcoeff.dat']:
#     shutil.copyfile(res_file, 'prob5_'+res_file)
Пример #2
0
                                              desired_stats)

        print("\nMAP parameter set:")
        for idx in range(len(map_params)):
            print(v_names[idx], ":", map_params[idx])

        # Save MAP parameter info to a file
        MAP_info = np.stack((v_names, map_params), axis=-1)
        np.savetxt(out_file_base + "_map_params.dat", MAP_info, fmt='%-8s')

        # Plot posteriors
        # first and last three columns do not contain variable samples
        if post_plots:
            uqtkinfpp.plot_all_posteriors(all_samples[:, 1:(1 + len(v_names))],
                                          v_names,
                                          np_kde,
                                          out_file_base,
                                          demo_verbose,
                                          dense=True)

        # Make graphs for each parameter
        if parameter_graphs:
            graph_tools.plot_parameter_graphs(out_file_base +
                                              "_parameter_graphs",
                                              all_samples,
                                              v_names,
                                              interactive=interactive,
                                              jpeg=jpeg)

        # Make graphs for the agreement between data and observations:
        model.model_info["fit_params"] = map_params
Пример #3
0
                    plt.clf()
            indx = indx + 10
        else:
            break

    ## Scatter plots from posterior ##################################################################
    for i in range(n_all_vars):
        for j in range(i):
            fig = plt.figure(figsize=(10, 10))
            ax = fig.add_axes([0.12, 0.12, 0.8, 0.8])
            plt.plot(chn[:, j + 1],
                     chn[:, i + 1],
                     'o',
                     markeredgecolor='blue',
                     markerfacecolor='b',
                     markersize=5)
            ax.set_xlabel(vnames[j], fontsize=22)
            ax.set_ylabel(vnames[i], fontsize=22)
            plt.savefig('tmcmc_bimodal.chn_' + vnames[j] + '_' + vnames[i] +
                        '.posterior.pdf')
            plt.clf()

    ## Plot posterior PDF 'triangle' ################################################
    np_kde = 100
    postp.plot_all_posteriors(chn[:, 1:], vnames, np_kde,
                              "tmcmc_bimodal.posteriors", 0, dense_plots)

print(
    "END: TMCMC example done: check out tmcmc_bimodal.*.pdf files for results."
)