def test_random_seed(self): sim_model1 = EconDensity(random_seed=22) X1, Y1 = sim_model1.simulate(n_samples=100) sim_model2 = EconDensity(random_seed=22) X2, Y2 = sim_model2.simulate(n_samples=100) diff_x = np.sum(np.abs(X1[:100] - X2[:])) diff_y = np.sum(np.abs(Y1[:100] - Y2[:])) self.assertAlmostEquals(diff_x, 0, places=2) self.assertAlmostEquals(diff_y, 0, places=2)
def generate_report(): econ_density = EconDensity() X, Y = econ_density.simulate(n_samples=1000) nke = NeighborKernelDensityEstimation() nke.fit_by_cv(X, Y) n_samples = 500 X_test = np.asarray([1 for _ in range(n_samples)]) Y_test = np.linspace(0, 8, num=n_samples) Z = nke.pdf(X_test, Y_test)