Guest User

Untitled

a guest
Nov 18th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. // example of extreme value
  2. var extremeValues = {burden: 50,
  3. prob: .00001,
  4. quanta: 1500000}
  5.  
  6. var options = {method: 'forward', samples: 25000}
  7.  
  8. // The naive standard for reasonableness
  9. var handPolicy = function(burden, prob, quanta) {
  10. return (burden < (prob * quanta) ?
  11. 'take precaution' :
  12. 'do what you want' );
  13. }
  14.  
  15. // Might expect unreasonable people to just act randomly
  16. // TODO: might add prior here (i.e. more likely to do what you want a priori)
  17. // or replace with some other assumption, e.g. acting maliciously?
  18. var randomPolicy = function(burn, prob, quanta) {
  19. return flip() ? 'take precaution' : 'do what you want';
  20. }
  21.  
  22. // Generative model of an agent's behavior given their reasonableness,
  23. // the facts of the situation, and the rule they're using to make a decision
  24. var agent = function(reasonable, values, rule) {
  25. return Infer(options, function() {
  26. var burden = gaussian(values.burden, 45) // very uncertain about cost of burden
  27. var prob = beta(1, 0.1) // probability of harm
  28. var quanta = 100 // harm is 100
  29. return (reasonable ?
  30. rule(burden, prob, quanta) : // hand formula
  31. randomPolicy(burden, prob, quanta))
  32. })
  33. }
  34.  
  35. // Jury sees defendent take action and uses some information about the situation
  36. // and a rule for what constitutes reasonableness to make their judgement
  37. var factFinder = function(actualAction, values, rule) {
  38. return Infer({method: 'enumerate'}, function() {
  39. // Jury's job is to infer whether defendent acted reasonably
  40. var reasonableness = flip();
  41. // Run a generative model of reasonableness (or not) under some rule
  42. var expectedAction = agent(reasonableness, values, rule)
  43. // Condition on the actual action coming from this distribution
  44. observe(expectedAction, actualAction);
  45. // Return their reasonableness
  46. return reasonableness;
  47. })
  48. }
  49.  
  50. viz(factFinder('do what you want', extremeValues, handPolicy))
  51. viz(factFinder('take precaution', extremeValues, handPolicy))
Add Comment
Please, Sign In to add comment