예제 #1
0
def test_cdf(xscale: Scale):
    scipydist_normed = scipy.stats.logistic(0.5, 0.05)
    true_loc = xscale.denormalize_point(0.5)
    true_s = 0.05 * xscale.width

    ergodist = Logistic(loc=true_loc, s=true_s, scale=xscale)

    for x in np.linspace(0, 1, 10):
        assert scipydist_normed.cdf(x) == pytest.approx(float(
            ergodist.cdf(xscale.denormalize_point(x))),
                                                        rel=1e-3)

    # TODO: consider a better approach for log scale
    if isinstance(xscale, LogScale):
        for x in np.linspace(xscale.low, xscale.high, 10):
            assert scipydist_normed.cdf(
                xscale.normalize_point(x)) == pytest.approx(float(
                    ergodist.cdf(x)),
                                                            rel=1e-3)
    else:
        scipydist_true = scipy.stats.logistic(true_loc, true_s)
        for x in np.linspace(xscale.low, xscale.high, 10):
            assert scipydist_true.cdf(x) == pytest.approx(float(
                ergodist.cdf(x)),
                                                          rel=1e-3)
예제 #2
0
파일: test_logistic.py 프로젝트: ghabs/ergo
def test_cdf():
    jax_dist = Logistic(loc=10, scale=1)
    original_dist = jax_dist.rv()
    for x in range(5, 15):
        assert jax_dist.cdf(x) == pytest.approx(original_dist.cdf(x), rel=0.1)