New "such_that" method to build CPT verifying given conditions
The Monty hall problem can be solved in Lea by building a CPT, as explained here.
However, the two proposed solutions are not fully satisfying from a user's point of view. The first solution (joint
+ switch
) is cumbersome, whilst the second (joint
+ switch_func
) is difficult to understand.
It is proposed to introduce a new method, such_that
, offering an easier way to build such CPT. The such_that
is quite similar to given
method, enforcing the conditions expressed in its arguments. In contrast to given
method, such_that
shall build a CPT that returns independent distributions (Alea instances).
Then, the Monty-Hall can be solved as follows:
lea.set_prob_type("r")
door = "door " + lea.vals(*"ABC")
prize = door.new()
choice1 = door.new()
goat = door.such_that(door != choice1, door != prize)
choice2 = door.such_that(door != choice1, door != goat)
P(choice2 == prize)
# -> 2/3
which is more declarative and intuitive than the other solutions.
Comments (7)
-
reporter -
reporter Fix Lea.such_that method by adding restricted arguments to Lea.get_leaves_set and Lea._get_lea_children methods (refs
#79)→ <<cset 068b038054ef>>
-
reporter Add tests for Lea.given and Lea.such_that methods (refs
#79)→ <<cset e0b9049154ae>>
-
reporter - changed status to resolved
Done in Lea 4
-
reporter - changed status to open
-
reporter Update Lea.such_that method, add Lea.as_depending_on and Lea.is_defined_using methods, rename Lea.is_certain_value method to Lea.is_certain, fix UT (refs
#79)→ <<cset ce8a5a617569>>
-
reporter - changed status to resolved
- Log in to comment
Add Lea.such_that method, change Tlea to avoid exception if value missing in CPT (refs
#79)→ <<cset 51df9b048a85>>