unable to directly obtain probability masses of joint distributions
Issue #20
closed
when i define a multivariate distribution as
joint = lea.Lea.fromValFreqs( ((1,2),10), ((1,3),9), ((2,2),8) ).asJoint('A','B')
i cannot use the pmf or p method since something like
joint.pmf((1,3))
raises an error. instead i currently use
joint.B.given(self.joint.A==1).pmf(3) * A.pmf(1)
should the pmf and p methods be able to handle multivariate arguments or is there another way to directly access the probability masses of multivariate distributions?
Comments (7)
-
repo owner -
repo owner - changed status to open
-
repo owner -
assigned issue to
-
assigned issue to
-
repo owner Use namedtuple to implement asJoint method, remove Olea class (refs
#20)→ <<cset c45023788d37>>
-
repo owner - changed status to resolved
Done. asJoint is now implemented with namedtuple (see comment above). Shall be available in Lea 2.2.
-
repo owner - changed status to closed
-
repo owner Use namedtuple to implement asJoint method, remove Olea class (refs
#20)→ <<cset 937dec461bd6>>
- Log in to comment
Thank you for reporting! There are two cleaner ways to solve this issue, with the current version of Lea (2.1.2 or before):
1) use Lea cartesian product method to get tuples:
2) (preferred) use Python's named tuples instead of Lea's joint:
Note that the
joint
variable works as before (i.e you can accessjoint.A
andjoint.B
)In forthcoming version of Lea, I will most probably change the implementation of
asJoint
method such that it uses Python's named tuples. Then, your expressionjoint.pmf((1,3))
will work fine.