Beispiel #1
0
    def test_extract(self):
        """run and test the extract methods"""

        m = self.data
        assert m.extract_convolution() == ExtractDistribution(m, "Convolution")
        assert m.extract(1) == Binomial(0, 10, 0.5)
        assert m.extract(2) == NegativeBinomial(0, 1, 0.1)
        assert ExtractDistribution(m, "Elementary", 1) == Binomial(0, 10, 0.5)
        assert ExtractDistribution(m, "Elementary", 2) == \
            NegativeBinomial(0, 1, 0.1)
Beispiel #2
0
 def test_extract(self):
     """run and test the extract methods"""
     m = self.data
     assert m.extract_compound() == ExtractDistribution(m, "Compound")
     assert m.extract_sum() == Binomial(2, 5, 0.5)
     assert m.extract_sum() == ExtractDistribution(m, "Sum")
     assert m.extract_elementary() == NegativeBinomial(0, 2, 0.5)
     assert m.extract_elementary() == ExtractDistribution(m, "Elementary")
    def test_neg_binomial(self):

        d = Distribution("NEGATIVE_BINOMIAL", 0, 1, 0.5)
        assert list(d.simulate(1000))
        assert d.get_sup_bound == -1
        assert d.get_inf_bound == 0
        assert d.get_probability == 0.5
        assert d.get_parameter == 1
        assert d.get_ident() == 3
        d = NegativeBinomial(0, 1, 0.5)
        assert list(d.simulate(1000))

        m = d.simulate(1000).extract_model()
        assert isinstance(m, _DiscreteParametricModel)
Beispiel #4
0
 def test_constructor_from_dists_and_threshold(self):
     compound1 = self.data
     compound2 = Compound(Binomial(2, 5, 0.5),
                          NegativeBinomial(0, 2, 0.5),
                          Threshold=0.99999)
     assert str(compound1) == str(compound2)
Beispiel #5
0
 def build_data(self):
     d1 = Binomial(2, 5, 0.5)
     d2 = NegativeBinomial(0, 2, 0.5)
     comp = Compound(d1, d2)
     return comp
Beispiel #6
0
 def build_data(self):
     d1 = Binomial(0, 10, 0.5)
     d2 = NegativeBinomial(0, 1, 0.1)
     conv = Convolution(d1, d2, d1, d2)
     conv = Convolution(d1, d2)
     return conv
 def conv(self):
     d1 = Binomial(0, 10, 0.5)
     d2 = NegativeBinomial(0, 1, 0.1)
     m = Convolution(d1, d2)
     return m
 def comp(self):
     d1 = Binomial(2, 5, 0.5)
     d2 = NegativeBinomial(0, 2, 0.5)
     c = Compound(d1, d2)
     return c
 def mixt_data(self):
     d1 = Binomial(0, 10, 0.5)
     d2 = NegativeBinomial(0, 1, 0.1)
     mixt = Mixture(0.1, d1, 0.4, d2)
     mixt_data = mixt.simulate(self.N)
     return mixt_data
 def conv_data(self):
     d1 = Binomial(0, 10, 0.5)
     d2 = NegativeBinomial(0, 1, 0.1)
     conv = Convolution(d1, d2)
     conv_data = conv.simulate(self.N)
     return conv_data
 def comp_data(self):
     d1 = Binomial(0, 10, 0.5)
     d2 = NegativeBinomial(0, 1, 0.1)
     comp = Compound(d1, d2)
     comp_data = comp.simulate(self.N)
     return comp_data