Ch06: condition in "Thinking About Assembly Lines"
Closed this issue · 5 comments
Hi,
there is the line " condition(_.isEqual([.6, .7, .8], goodWidgetSeq))". I don't understand why the sequence of good widgets should have an ascending order. Isn't it sufficient that all members of the good widgets are above the sampled threshold of the widget tester ?
Best, Claus
I don't understand why the sequence of good widgets should have an ascending order
There's nothing significant about the fact that the observed good widgets happen to be in ascending order.
Isn't it sufficient that all members of the good widgets are above the sampled threshold of the widget tester ?
IIRC the threshold is unknown. All we observe are the good widgets. The goal is to infer the distribution over the threshold, given the good widgets.
if the order of the good widgets is unimportant because the size of the widgets is exchangeable, the condition should be "condition(0.5 < min(goodWidgetSeq))". I'll have to test whether this is syntactically correct. But you know what I mean. In this case you get the posterior P(Threshold | 0.5 < WidgetSize).
Here is the modified condition for exchangeable widget-sizes. The condition checks whether all three members of the goodWidgetSeq are above or equal 0.6. Only in this case the threshold value is saved for the posterior distribution. As you can see, the results are even better than before:
var widgetDist = Infer({method: 'rejection', samples: 300, maxScore: -0.0}, function() {
var threshold = sample(thresholdPrior);
var goodWidgetSeq = makeWidgetSeq(3, threshold);
// condition(_.isEqual([.6, .7, .8], goodWidgetSeq)) // original code
condition(3*0.6 <= sum(goodWidgetSeq)) // new improved condition
return [threshold].join("");
})
small error on my side :( of course the condition has on my side has to be:
var widgetDist = Infer({method: 'rejection', samples: 300}, function() {
var threshold = sample(thresholdPrior);
var goodWidgetSeq = makeWidgetSeq(3, threshold);
// condition(_.isEqual([.6, .7, .8], goodWidgetSeq))
condition(Math.pow(0.6, 3) <= product(goodWidgetSeq)) // new condition
return [threshold].join("");
})
my last word:
var widgetDist = Infer({method: 'rejection', samples: 300}, function() {
var threshold = sample(thresholdPrior);
var goodWidgetSeq = makeWidgetSeq(3, threshold);
// condition(_.isEqual([.6, .7, .8], goodWidgetSeq))
condition(all(function(goodWidget){0.6 <= goodWidget}, goodWidgetSeq))
return [threshold].join("");
})