Giter Club home page Giter Club logo

expected-utility's Introduction

nm.utility.core

A compact Clojure library to calcuate expected utility.

Expected utility: You multiply the probability of winning by the potential gains and multiply the probability of losing by the potential losses. Adding the two gives you the expected utility of the gamble.

The concept was originated by John von Neumann and Oskar Morgenstern and is explained in the book The Theory of Games and Economic Behavior.

Rationale

Expected utility can be used in decision making on whether, or not, to make a gamble on the probability of an outcome happening.

Expected Utility

Usage

The library is available on Clojars. So you can add it to your project.clj file.

[nm.utility.core "0.1.0-SNAPSHOT"]

Or with Maven:

<dependency>
  <groupId>nm.utility.core</groupId>
  <artifactId>nm.utility.core</artifactId>
  <version>0.1.0-SNAPSHOT</version>
</dependency>

Once installed the library is very straightforward to use. It only requires three variables.

  • The potential gain if the outcome happens.
  • The potential loss if the outcome doesn't happen.
  • The chance (probility) of the outcome happening.

The function call is (expected-utility gain loss probability-percent). A map will be returned with the outcome and if expected utility is greater than the status quo (zero) then the :execute-decision key will be true.

user> (require '[nm.utility.core :as nm])

user> (nm/expected-utility 80 10 12.5)

user> {:gain-utility 10.0, :loss-utility 8.75, :gain-probability 0.125, :chance-of-loss 0.875, :expected-utility 1.25, :execute-descion true}

user> (clojure.pprint/pprint *1)
{:gain-utility 10.0,
 :loss-utility 8.75,
 :gain-probability 0.125,
 :chance-of-loss 0.875,
 :expected-utility 1.25,
 :execute-descion true}

License

Copyright © 2018 Jason Bell

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

expected-utility's People

Contributors

jasebell avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.