コード例 #1
0
ファイル: test_logistic.py プロジェクト: wjurayj/ergo
def test_logistic_mixture_normalization():
    scale = Scale(-50, 50)
    scalex2 = Scale(-100, 100)
    mixture = LogisticMixture(
        components=[Logistic(-40, 1, scale),
                    Logistic(50, 10, scale)],
        probs=[0.5, 0.5],
    )

    mixturex2 = LogisticMixture(
        components=[Logistic(-80, 2, scalex2),
                    Logistic(100, 20, scalex2)],
        probs=[0.5, 0.5],
    )

    assert mixturex2 == mixture.normalize().denormalize(scalex2)
    assert mixture == mixturex2.normalize().denormalize(scale)

    normalized = (mixture.normalize()
                  )  # not necessary to normalize but here for readability

    assert normalized == LogisticMixture(
        [Logistic(0.1, 0.01, Scale(0, 1)),
         Logistic(1, 0.1, Scale(0, 1))],
        [0.5, 0.5],
    )
コード例 #2
0
ファイル: test_logistic.py プロジェクト: ghabs/ergo
def test_logistic_mixture_normalization():
    mixture = LogisticMixture([Logistic(-40, 1), Logistic(50, 10)], [0.5, 0.5])

    for scale_min, scale_max in [(0, 10), (10, 100), (-10, 10), (-100, -10)]:
        assert (mixture.normalize(scale_min,
                                  scale_max).denormalize(scale_min,
                                                         scale_max) == mixture)

    normalized = mixture.normalize(-50, 50)
    assert normalized == LogisticMixture(
        [Logistic(0.1, 0.01), Logistic(1, 0.1)], [0.5, 0.5])