示例#1
0
文件: uq.py 项目: hajians/UQ
    '''
    PRIOR = uni_prior(x)
    if PRIOR > 10.0**-8:
        return likelihood(x) * PRIOR
    else:
        return 0.0


if __name__ == "__main__":

    import matplotlib.pyplot as plt

    ### Plotting
    # get the info of the true pipe
    pipe_true.info()
    # plot the pressure drop of the true pressure drop
    plt.plot(pipe_true.timeslices,
             pipe_true.pressure_drop,
             marker="o",
             label="true pressure drop")
    # plot the noisy pressure drop
    plt.plot(pipe_true.timeslices,
             y_obs,
             linestyle="--",
             marker="x",
             label="noisy pressure drop")
    plt.xlabel("$t_n$", fontsize=24)
    plt.ylabel("$\delta p_h^n$", fontsize=24)
    plt.yticks(fontsize=20)
    plt.xticks(fontsize=20)
示例#2
0
文件: uq_pcn.py 项目: hajians/UQ
    and standard deviation of size 1.
    '''

    LARGE_NUM = 1000000.0

    pipe.run(x, progress_bool=False)

    # check if we have negative friction
    pipe.get_current_lambda_average()
    for i in pipe.lambda_avg:
        if i < 0: return LARGE_NUM

    S = pipe.get_presure_drop(time_instance=time_ins, inplace=False)

    out = 0.5 * dot(S - y_obs, S - y_obs) / std_noise

    return out


if __name__ == "__main__":

    filename = "results/uq_pcn.dat"

    pipe.info()

    pcn = PCN(Nlikelihood, uniform_to_normal, normal_to_uniform,
              initial_point_mcmc)
    pcn.run(max_iter=4000, burning=400)

    pcn.write(filename, write_prob=True)