charles-river-analytics / figaro

Figaro Programming Language and Core Libraries
Other
757 stars 153 forks source link

Request for example #744

Open PaulAtBanno opened 6 years ago

PaulAtBanno commented 6 years ago

Hi team,

I just wrote this wiki entry, but I'm not sure whether that results in a notification to any committers, so I wanted to bring it to your attention more explicitly. My apologies if this isn't the appropriate process!

apfeffer commented 6 years ago

Hi Paul,

This is an interesting question. As it happens, the answer to the original Monty Hall problem is not as clear cut as you might think, and therein lies the clue to your problem. In Monty Hall, we really need to know Monty’s policy. If we assume he always chooses a door at random, then the answer is as usually given. But if Monty has a policy of always opening door C if it has a goat (your wife was always going to tell you that taco C has beans), then that changes the answer. If we assume that.

We can model this situation in Figaro with something like this (apologies for incorrect syntax – I’m typing this into an email)

// This particular policy is deterministic, but in general it could be stochastic, so montyPolicy returns an element. def montyPolicy(steak : Int, guess : Int): Element[Boolean] = if (steak != 3) then Constant(3) else Constant(1) val steak = FromRange(1,4) val firstGuess = FromRange(1,4) val monty = Chain(steak, firstGuess, montyPolicy) val known = firstGuess ^^ monty // makes a pair val secondGuess = Decision(known, [1,2,3]) val utility = Apply(secondGuess, steak, (i1: Int, i2: Int) => if (i1==i2) then 1 else 0)

Avi

From: Paul Snively notifications@github.com Reply-To: p2t2/figaro reply@reply.github.com Date: Saturday, May 26, 2018 at 9:43 AM To: p2t2/figaro figaro@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [p2t2/figaro] Request for example (#744)

Hi tea

I just wrote this wiki entryhttps://github.com/p2t2/figaro/wiki/Discuss-Demonstrations-and-Examples, but I'm not sure whether that results in a notification to any committers, so I wanted to bring it to your attention more explicitly. My apologies if this isn't the appropriate process!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/p2t2/figaro/issues/744, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AFJkd9h4XvgCjsyFqsCTGbKFUD8Spuxlks5t2VvhgaJpZM4UO62f.