Exemplo n.º 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]
     )
Exemplo n.º 2
0
def test_single_dirichlet_is_always_one():
    assert dist.dirichlet(random, [11]) == [1.0]
Exemplo n.º 3
0
 def produce_parameter(self, random):
     n = len(self.elements)
     if n == 1:
         return
     return chooser(dist.dirichlet(random, [sqrt(n)] * n))
Exemplo n.º 4
0
def test_zeros_in_dirichlet_are_invalid():
    with pytest.raises(InvalidArgument):
        dist.dirichlet(random, [0.0, 1.0])
Exemplo n.º 5
0
def test_dirichlet_biases_towaards_weights():
    t = dist.dirichlet(random, [10000000000, 1, 1])
    assert t[0] >= 0.8
Exemplo n.º 6
0
def test_empty_dirichlet_is_invalid():
    with pytest.raises(InvalidArgument):
        dist.dirichlet(random, [])
Exemplo n.º 7
0
def test_single_dirichlet_is_always_one():
    assert dist.dirichlet(random, [11]) == [1.0]
Exemplo n.º 8
0
def test_dirichlet_biases_towaards_weights():
    t = dist.dirichlet(random, [10000000000, 1, 1])
    assert t[0] >= 0.8
Exemplo n.º 9
0
def test_zeros_in_dirichlet_are_invalid():
    with pytest.raises(InvalidArgument):
        dist.dirichlet(random, [0.0, 1.0])
Exemplo n.º 10
0
def test_empty_dirichlet_is_invalid():
    with pytest.raises(InvalidArgument):
        dist.dirichlet(random, [])