Single-variable Distributions (datascience.tables.Table)¶
Constucting¶
In [1]: from prob140 import *
In [2]: dist1 = Table().values(np.array([2, 3, 5])).probability(np.array([0.25, 0.5, 0.25]))
In [3]: print(dist1)
Value | Probability
2 | 0.25
3 | 0.5
5 | 0.25
In [4]: dist2 = Table().values(np.arange(1, 8, 2)).probability_function(lambda x: 1/4)
In [5]: print(dist2)
Value | Probability
1 | 0.25
3 | 0.25
5 | 0.25
7 | 0.25
Table.values(*args) |
|
Table.probability(values) |
Assigns probabilities to domain values. |
Table.probability_function(pfunc) |
Assigns probabilities to a Distribution via a probability function. |
Utitilies¶
Table.prob_event(x) |
Finds the probability of an event x. |
Table.event(x) |
Shows the probability that distribution takes on value x or list of values x. |
Table.cdf(x) |
Finds the cdf of the distribution |
Table.ev() |
Finds expected value of distribution |
Table.sd() |
Finds standard deviation of Distribution. |
Table.var() |
Finds variance of distribution |
Table.normalized() |
Returns the distribution by making the proabilities sum to 1 |
Table.sample_from_dist([n]) |
Randomly samples from the distribution. |
emp_dist(values) |
Takes an array of values and returns an empirical distribution |
