prob140.JointDistribution.conditional_dist¶
-
JointDistribution.
conditional_dist
(label, given='', show_ev=False)[source]¶ Given the random variable label, finds the conditional distribution of the other variable
Parameters: label : String
given variable
Returns: JointDistribution Table
Examples
>>> coins = Table().values("Coin1",['H','T'],"Coin2", ['H','T']).probability(np.array([0.24, 0.36, 0.16,0.24])).toJoint() >>> coins.conditional_dist("Coin1","Coin2") Coin1=H Coin1=T Sum Dist. of Coin1 | Coin2=H 0.6 0.4 1.0 Dist. of Coin1 | Coin2=T 0.6 0.4 1.0 Marginal of Coin1 0.6 0.4 1.0 >>> coins.conditional_dist("Coin2","Coin1") Dist. of Coin2 | Coin1=H Dist. of Coin2 | Coin1=T Marginal of Coin2 Coin2=H 0.4 0.4 0.4 Coin2=T 0.6 0.6 0.6 Sum 1.0 1.0 1.0