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