Skip to content

Instantly share code, notes, and snippets.

@hawkrobe
Created November 16, 2017 07:05
Show Gist options
  • Select an option

  • Save hawkrobe/ed8eccb3b339bc8360cdc7d95e793e25 to your computer and use it in GitHub Desktop.

Select an option

Save hawkrobe/ed8eccb3b339bc8360cdc7d95e793e25 to your computer and use it in GitHub Desktop.
Working example of juror reasoning about reasonableness
// 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))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment