Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // example of extreme value
- var extremeValues = {burden: 50,
- prob: .00001,
- quanta: 1500000}
- var options = {method: 'forward', samples: 25000}
- // The naive standard for reasonableness
- var handPolicy = function(burden, prob, quanta) {
- return (burden < (prob * quanta) ?
- 'take precaution' :
- 'do what you want' );
- }
- // Might expect unreasonable people to just act randomly
- // TODO: might add prior here (i.e. more likely to do what you want a priori)
- // or replace with some other assumption, e.g. acting maliciously?
- var randomPolicy = function(burn, prob, quanta) {
- return flip() ? 'take precaution' : 'do what you want';
- }
- // Generative model of an agent's behavior given their reasonableness,
- // the facts of the situation, and the rule they're using to make a decision
- var agent = function(reasonable, values, rule) {
- return Infer(options, function() {
- var burden = gaussian(values.burden, 45) // very uncertain about cost of burden
- var prob = beta(1, 0.1) // probability of harm
- var quanta = 100 // harm is 100
- return (reasonable ?
- rule(burden, prob, quanta) : // hand formula
- randomPolicy(burden, prob, quanta))
- })
- }
- // Jury sees defendent take action and uses some information about the situation
- // and a rule for what constitutes reasonableness to make their judgement
- var factFinder = function(actualAction, values, rule) {
- return Infer({method: 'enumerate'}, function() {
- // Jury's job is to infer whether defendent acted reasonably
- var reasonableness = flip();
- // Run a generative model of reasonableness (or not) under some rule
- var expectedAction = agent(reasonableness, values, rule)
- // Condition on the actual action coming from this distribution
- observe(expectedAction, actualAction);
- // Return their reasonableness
- return reasonableness;
- })
- }
- viz(factFinder('do what you want', extremeValues, handPolicy))
- viz(factFinder('take precaution', extremeValues, handPolicy))
Add Comment
Please, Sign In to add comment