def test_KMN_with_2d_gaussian_2(self):
        mu = 200
        std = 23
        X, Y = self.get_samples(mu=mu, std=std)

        for method in ["agglomerative"]:
            with tf.Session() as sess:
                model = KernelMixtureNetwork("kmn2_" + method,
                                             1,
                                             1,
                                             center_sampling_method=method,
                                             n_centers=10,
                                             hidden_sizes=(16, 16),
                                             init_scales=np.array([1.0]),
                                             train_scales=True,
                                             data_normalization=True)
                model.fit(X, Y)

                y = np.arange(mu - 3 * std, mu + 3 * std, 6 * std / 20)
                x = np.asarray([mu for i in range(y.shape[0])])
                p_est = model.pdf(x, y)
                p_true = norm.pdf(y, loc=mu, scale=std)
                self.assertLessEqual(np.mean(np.abs(p_true - p_est)), 0.1)

                p_est = model.cdf(x, y)
                p_true = norm.cdf(y, loc=mu, scale=std)
                self.assertLessEqual(np.mean(np.abs(p_true - p_est)), 0.1)
density_simulator = SkewNormal(random_seed=seed)
X, Y = density_simulator.simulate(n_samples=3000)
""" fit density model """
model = KernelMixtureNetwork("KDE_demo",
                             ndim_x=1,
                             ndim_y=1,
                             n_centers=50,
                             x_noise_std=0.2,
                             y_noise_std=0.1,
                             random_seed=22)
model.fit(X, Y)
""" query the conditional pdf and cdf"""
x_cond = np.zeros((1, 1))
y_query = np.ones((1, 1)) * 0.1
prob = model.pdf(x_cond, y_query)
cum_prob = model.cdf(x_cond, y_query)
""" compute conditional moments & VaR  """
x_cond = np.zeros((1, 1))

mean = model.mean_(x_cond)[0][0]
std = model.std_(x_cond)[0][0]
skewness = model.skewness(x_cond)[0]
VaR = model.value_at_risk(x_cond, alpha=0.01)[0]

print("Mean:", mean)
print("Std:", std)
print("Skewness:", skewness)
print("Value-at-Risk", VaR)
""" plot the fitted distribution """
x_cond_plot = np.array([-0.5, 0, 0.5])
model.plot2d(x_cond_plot, ylim=(-0.25, 0.15), show=True)