dit.util.testing.distributions()

# Finding Examples¶

What if you’d like to find a distribution that has a particular property? For example, what if I’d like to find a distribution with a coinformation less that $$-0.5$$? This is where Hypothesis comes in:

In : from hypothesis import find

In : from dit.utils.testing import distributions

In : find(distributions(3, 2), lambda d: dit.multivariate.coinformation(d) < -0.5)
Out:
Class:          Distribution
Alphabet:       (0, 1) for all rvs
Base:           linear
Outcome Class:  tuple
Outcome Length: 3
RV Names:       None

x           p(x)
(0, 0, 0)   1/5
(0, 1, 1)   1/5
(1, 0, 0)   1/5
(1, 0, 1)   1/5
(1, 1, 0)   1/5


What hypothesis has done is use the distributions() strategy to randomly test distributions. Once it finds a distribution satisfying the criteria we specified (coinformation less than $$-0.5$$) it then simplifies the example as much as possible. Here, we see that even though it could have found any distribution, it found the exclusive or distribution, and simplified the probabilities to be uniform.