SciPy

prob140.Table.toJoint

Table.toJoint(table, X_column_label=None, Y_column_label=None, probability_column_label=None, reverse=True)

Converts a table of probabilities associated with two variables into a JointDistribution object

Parameters:

table : Table

You can either call pass in a Table directly or call the toJoint() method of that Table. See examples

X_column_label (optional) : String

Label for the first variable. Defaults to the same label as that of first variable of Table

Y_column_label (optional) : String

Label for the second variable. Defaults to the same label as that of second variable of Table

probability_column_label (optional) : String

Label for probabilities reverse (optional) : Boolean If True, the vertical values will be reversed

Returns:

JointDistribution

A JointDistribution object

Examples

>>> dist1 = Table().values([0,1],[2,3])
>>> dist1['Probability'] = make_array(0.1, 0.2, 0.3, 0.4)
>>> dist1.toJoint()
     X=0  X=1
Y=3  0.2  0.4
Y=2  0.1  0.3
>>> dist2 = Table().values("Coin1",['H','T'], "Coin2", ['H','T'])
>>> dist2['Probability'] = np.array([0.4*0.6, 0.6*0.6, 0.4*0.4, 0.6*0.4])
>>> dist2.toJoint()
         Coin1=H  Coin1=T
Coin2=T     0.36     0.24
Coin2=H     0.24     0.16