def test_log_normal_pdf_compare_with_scipy(self): """Check the derivations of the log_normal_pdf.""" from mixture_model.gaussian_mixture import _log_normal_pdf # Smoke test random_errors = np.random.rand(1, 2) unit_vars = np.array([2, 3]) attempt_random_result = _log_normal_pdf(random_errors**2, unit_vars) assert attempt_random_result is not None # Comparison with a zero-mean normal distribution. errors = np.arange(-1, 1, 0.01) goal_values = norm.logpdf(errors, loc=0, scale=1) attempt_values = _log_normal_pdf(errors**2, 1) assert_almost_equal(goal_values, attempt_values) # Comparison with a zero-mean wide normal distribution. goal_values = norm.logpdf(errors, loc=0, scale=4) attempt_values = _log_normal_pdf(errors**2, 4**2) assert_almost_equal(goal_values, attempt_values)
def test_log_normal_pdf_is_isotropic(self): """Test whether the log_normal_pdf .""" from mixture_model.gaussian_mixture import _log_normal_pdf # Smoke test random_errors = np.random.rand(1, 2) unit_vars = np.array([2, 3]) attempt_random_result = _log_normal_pdf(random_errors**2, unit_vars) assert attempt_random_result is not None # Test isotropic property random_goal_values = \ norm.logpdf(random_errors, loc=[0, 0], scale=np.sqrt(unit_vars)) assert_almost_equal(random_goal_values, attempt_random_result)