def test_empirical_pdf(smi, u, log): cop = EmpiricalCopula(4, smi, smoothing="beta") pdf = cop.pdf(u, log) if log else np.log(cop.pdf(u)) expected = [-38.968738, -7.304777, -14.892165, -5.423080, -24.478464] assert_almost_equal(pdf, expected, decimal=6)
def test_empirical_to_margins(): data = load_marginal_data() cop = EmpiricalCopula(data) test_input = pseudo_obs(data)[:6] output = cop.to_marginals(test_input) assert_almost_equal(output, data.iloc[:6].to_numpy())
def copula(): data = load_marginal_data() return EmpiricalCopula(data)
def test_empirical_summary(smi): cop = EmpiricalCopula(data=smi) assert isinstance(cop.summary(), Summary)
def test_empirical_random(smi, seed): cop = EmpiricalCopula(data=smi) rvs = cop.random(5, seed) assert rvs.shape == (5, smi.shape[1])
def test_empirical_param_returns_none(smi): cop = EmpiricalCopula(data=smi) assert cop.params is None
def test_empirical_cdf(u, smi, smoothing, expected): cop = EmpiricalCopula(data=smi, smoothing=smoothing) assert_almost_equal(cop.cdf(u), expected)
def test_empirical_non_applicable_methods_raises_error(smi, func): cop = EmpiricalCopula(data=smi) with pytest.raises(NotApplicableError): eval(func)