True if `X` contains probabilities that sum to 1 along the columns
(X)
| 28 | |
| 29 | |
| 30 | def is_stochastic(X): |
| 31 | """True if `X` contains probabilities that sum to 1 along the columns""" |
| 32 | msg = "Array should be stochastic along the columns" |
| 33 | assert len(X[X < 0]) == len(X[X > 1]) == 0, msg |
| 34 | assert np.allclose(np.sum(X, axis=1), np.ones(X.shape[0])), msg |
| 35 | return True |
| 36 | |
| 37 | |
| 38 | def is_number(a): |