Пример #1
0
 def produce_parameter(self, random):
     n = len(self.element_strategies)
     return self.Parameter(
         chooser=chooser(
             dirichlet(random, [1.0 / n] * n)),
         child_parameters=[
             s.draw_parameter(random) for s in self.element_strategies]
     )
Пример #2
0
def test_single_dirichlet_is_always_one():
    assert dist.dirichlet(random, [11]) == [1.0]
Пример #3
0
 def produce_parameter(self, random):
     n = len(self.elements)
     if n == 1:
         return
     return chooser(dist.dirichlet(random, [sqrt(n)] * n))
Пример #4
0
def test_zeros_in_dirichlet_are_invalid():
    with pytest.raises(InvalidArgument):
        dist.dirichlet(random, [0.0, 1.0])
Пример #5
0
def test_dirichlet_biases_towaards_weights():
    t = dist.dirichlet(random, [10000000000, 1, 1])
    assert t[0] >= 0.8
Пример #6
0
def test_empty_dirichlet_is_invalid():
    with pytest.raises(InvalidArgument):
        dist.dirichlet(random, [])
Пример #7
0
def test_single_dirichlet_is_always_one():
    assert dist.dirichlet(random, [11]) == [1.0]
Пример #8
0
def test_dirichlet_biases_towaards_weights():
    t = dist.dirichlet(random, [10000000000, 1, 1])
    assert t[0] >= 0.8
Пример #9
0
def test_zeros_in_dirichlet_are_invalid():
    with pytest.raises(InvalidArgument):
        dist.dirichlet(random, [0.0, 1.0])
Пример #10
0
def test_empty_dirichlet_is_invalid():
    with pytest.raises(InvalidArgument):
        dist.dirichlet(random, [])