示例#1
0
from virocon import GlobalHierarchicalModel
from virocon.predefined import get_DNVGL_Hs_U

dist_descriptions, fit_descriptions, semantics = get_DNVGL_Hs_U()

ghm = GlobalHierarchicalModel(dist_descriptions)
ghm.fit(data, fit_descriptions=fit_descriptions)

# %%
from virocon.plotting import plot_2D_isodensity

plot_2D_isodensity(ghm, data, semantics=semantics)

# %%

my_f = ghm.pdf(x)

my_f_weibull3 = ghm.distributions[0].pdf(x[:, 0])
my_weibull3_params = (
    ghm.distributions[0].beta,
    ghm.distributions[0].gamma,
    ghm.distributions[0].alpha,
)

my_weibull2 = ghm.distributions[1]
my_given = my_weibull2.conditioning_values
my_f_weibull2 = []
for given in my_given:
    my_f_weibull2.append(my_weibull2.pdf(x[:, 1], given))

my_f_weibull2 = np.stack(my_f_weibull2, axis=1)
            colors="k",
            zorder=2,
        ))
    CS_empirical[-1].collections[0].set_label("KDE, constant density")

    # Define the structure of the joint distribution model and fit it to the data.
    dist_descriptions, fit_descriptions, semantics = get_OMAE2020_Hs_Tz()
    model = GlobalHierarchicalModel(dist_descriptions)
    data = np.array([hs, tz])
    data = data.T
    model.fit(data)

    f = np.empty_like(hgrid)
    for i in range(hgrid.shape[0]):
        for j in range(hgrid.shape[1]):
            f[i, j] = model.pdf([hgrid[i, j], tgrid[i, j]])

    CS.append(
        ax.contour(
            tgrid,
            hgrid,
            f,
            levels=levels,
            zorder=2,
            colors="b",
            linestyles="--",
            linewidths=1,
        ))
    CS[-1].collections[0].set_label("Model, constant density")

    ax.legend(
            colors="k",
            zorder=2,
        ))
    CS_empirical[-1].collections[0].set_label("KDE, constant density")

    # Define the structure of the joint distribution model and fit it to the data.
    dist_descriptions, fit_descriptions, semantics = get_OMAE2020_V_Hs()
    model = GlobalHierarchicalModel(dist_descriptions)
    data = np.array([v, hs])
    data = data.T
    model.fit(data)

    f = np.empty_like(hgrid)
    for i in range(hgrid.shape[0]):
        for j in range(hgrid.shape[1]):
            f[i, j] = model.pdf([vgrid[i, j], hgrid[i, j]])

    CS.append(
        ax.contour(
            vgrid,
            hgrid,
            f,
            levels=levels,
            zorder=2,
            colors="b",
            linestyles="--",
            linewidths=1,
        ))
    CS[-1].collections[0].set_label("Model, constant density")

    ax.legend(