Numpy-based ScalarDistribution¶
ScalarDistributions are used to represent distributions over real numbers, for example a six-sided die or the number of heads when flipping 100 coins.
Playing with ScalarDistributions¶
First we will enable two optional features: printing fractions by default, and using __str__()
as __repr__()
. Be careful using either of these options, they can incur significant performance hits on some distributions.
In [1]: In [1]: dit.ditParams['print.exact'] = dit.ditParams['repr.print'] = True
We next construct a six-sided die:
In [2]: In [2]: from dit.example_dists import uniform
We can perform standard mathematical operations with scalars, such as adding, subtracting from or by, multiplying, taking the modulo, or testing inequalities.
In [3]: In [5]: d6 + 3
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-3-e5c29798e750> in <module>
----> 1 d6 + 3
NameError: name 'd6' is not defined
In [4]: Class: ScalarDistribution