def test_tuple_ml(): """ Test ML parameter estimation under the tuple distribution. """ from cargo.numpy import tolist_deeply model = Tuple([(Binomial(estimation_n=1), 2), (Binomial(estimation_n=1), 1)]) engine = ModelEngine(model) assert_almost_equal_deep( tolist_deeply( engine.ml( [([0, 1], [0])] * 2500 + [([1, 0], [1])] * 7500, numpy.ones(10000), ), ), ([(0.75, 1), (0.25, 1)], [(0.75, 1)]), ) assert_almost_equal_deep( tolist_deeply( engine.ml( [([0, 1], [0])] * 1000 + [([1, 0], [1])] * 1000, [1.00] * 1000 + [3.00] * 1000, ), ), ([(0.75, 1), (0.25, 1)], [(0.75, 1)]), )
def test_tuple_ml(): """ Test ML parameter estimation under the tuple distribution. """ from cargo.numpy import tolist_deeply model = Tuple([(Binomial(estimation_n = 1), 2), (Binomial(estimation_n = 1), 1)]) engine = ModelEngine(model) assert_almost_equal_deep( tolist_deeply( engine.ml( [([0, 1], [0])] * 2500 + [([1, 0], [1])] * 7500, numpy.ones(10000), ), ), ([(0.75, 1), (0.25, 1)], [(0.75, 1)]), ) assert_almost_equal_deep( tolist_deeply( engine.ml( [([0, 1], [0])] * 1000 + [([1, 0], [1])] * 1000, [1.00] * 1000 + [3.00] * 1000, ), ), ([(0.75, 1), (0.25, 1)], [(0.75, 1)]), )
def test_mixed_binomial_ml(): """ Test max-likelihood estimation under the mixed binomial distribution. """ me = ModelEngine(MixedBinomial()) assert_almost_equal_deep( me.ml( [[(1, 2), (4, 5)], [(3, 4), (8, 8)]], numpy.ones((2, 2)), ), [5.0 / 7.0, 11.0 / 12.0], )
def test_binomial_ml(): """ Test max-likelihood estimation under the binomial distribution. """ me = ModelEngine(Binomial(estimation_n=2)) assert_almost_equal_deep( me.ml( [[1, 2], [2, 0]], numpy.ones((2, 2)), ) \ .tolist(), [(0.75, 2), (0.50, 2)], )
def test_binomial_ml(): """ Test max-likelihood estimation under the binomial distribution. """ me = ModelEngine(Binomial(estimation_n = 2)) assert_almost_equal_deep( me.ml( [[1, 2], [2, 0]], numpy.ones((2, 2)), ) \ .tolist(), [(0.75, 2), (0.50, 2)], )