prob140.Table.sample¶
-
Table.
sample
(n=1)¶ Randomly samples from the distribution
Parameters: n : int
Number of times to sample from the distribution (default: 1)
Returns: float or array
Samples from the distribution
>>> dist = Table().with_columns('Value',make_array(2, 3, 4),'Probability',make_array(0.25, 0.5, 0.25))
>>> dist.sample()
3
>>> dist.sample()
2
>>> dist.sample(10)
array([3, 2, 2, 4, 3, 4, 3, 4, 3, 3])