Extend is_any_of and is_none_of methods

Issue #80 resolved
Pierre Denis repo owner created an issue

Currently, the methods any_of and is_none_of work with fixed values as arguments, not Lea instances. It would be interesting to extend these to accept Lea instances as arguments.

Examples:

c1, c2, c3 = vals("H","T").new(3)
P(c1.is_any_of(c2,c3))
# -> 3/4
P(c1.is_none_of(c2,c3))
# -> 1/4
joint(c1,c2,c3).given(c1.is_any_of(c2,c3))
# -> ('H', 'H', 'H') : 1/6
#    ('H', 'H', 'T') : 1/6
#    ('H', 'T', 'H') : 1/6
#    ('T', 'H', 'T') : 1/6
#    ('T', 'T', 'H') : 1/6
#    ('T', 'T', 'T') : 1/6
joint(c1,c2,c3).given(c1.is_none_of(c2,c3))
#    ('H', 'T', 'T') : 1/2
#    ('T', 'H', 'H') : 1/2

Of course, the referential consistency shall be kept:

P(c1.is_any_of(c1,c2,c3))
# -> 1
P(c1.is_any_of(c1+"_"))
# -> 0
P(c1.is_none_of(c1+"_"))
# -> 1
P(c1.is_none_of(c1+"_",c2,c3))
# -> 1/4

Comments (2)

  1. Log in to comment