New "such_that" method to build CPT verifying given conditions

Issue #79 resolved
Pierre Denis repo owner created an issue

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)

  1. Pierre Denis 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>>

  2. Log in to comment