Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
25 lines (22 sloc) 748 Bytes
a := 0;
b := 1;
actionPrior := [0.5, 0.5];
def vendingMachine(action: R, aEffects: R[], bEffects: R[]){
if(action == a) {return categorical(aEffects);}
else if(action == b){return categorical(bEffects);}
else{return 2;}
}
def chooseAction(goal: R, aEffects: R[], bEffects: R[]){
action := categorical(actionPrior);
observe(goal == vendingMachine(action, aEffects, bEffects));
return action;
}
def main(){
aEffects := [beta(1,1), 0];
bEffects := [beta(1,1), 0];
aEffects[1] = 1-aEffects[0];
bEffects[1] = 1-bEffects[0];
goal := flip(0.5);
observe(goal == 1 && sample(Marginal(chooseAction(goal, aEffects, bEffects)== b)));
return bEffects[0];
}