MCPcopy
hub / github.com/numpy/numpy / test_dirichlet

Method test_dirichlet

numpy/random/tests/test_randomstate.py:789–806  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

787 assert_array_almost_equal(actual, desired, decimal=13)
788
789 def test_dirichlet(self):
790 rng = random.RandomState(self.seed)
791 alpha = np.array([51.72840233779265162, 39.74494232180943953])
792 actual = rng.dirichlet(alpha, size=(3, 2))
793 desired = np.array([[[0.54539444573611562, 0.45460555426388438],
794 [0.62345816822039413, 0.37654183177960598]],
795 [[0.55206000085785778, 0.44793999914214233],
796 [0.58964023305154301, 0.41035976694845688]],
797 [[0.59266909280647828, 0.40733090719352177],
798 [0.56974431743975207, 0.43025568256024799]]])
799 assert_array_almost_equal(actual, desired, decimal=15)
800 bad_alpha = np.array([5.4e-01, -1.0e-16])
801 assert_raises(ValueError, random.dirichlet, bad_alpha)
802
803 rng = random.RandomState(self.seed)
804 alpha = np.array([51.72840233779265162, 39.74494232180943953])
805 actual = rng.dirichlet(alpha)
806 assert_array_almost_equal(actual, desired[0, 0], decimal=15)
807
808 def test_dirichlet_size(self):
809 # gh-3173

Callers

nothing calls this directly

Calls 2

assert_raisesFunction · 0.90

Tested by

no test coverage detected