@decidables/prospectable-math

0.2.9 • Public • Published

`@decidables/prospectable-math`Equations for Calculating Cumulative Prospect Theory in prospectαbλe

Helper functions for calculations related to Cumulative Prospect Theory for prospectαbλe.

Usage

Install

`yarn add @decidables/prospectable-math`

Use

`import CPTMath from '@decidables/prospectable-math';`

A class providing static functions for calculating Signal Detection Theory equations

Contents

`CPTMath`

Single class exposing static functions for CPT calculations. Each function takes values for one or more variables and returns the value of another variable. The functions are named with a list of the input variables followed by a '2' followed by the output variable, in camelcase. For example, `hM2Hr` takes as input the number of hits, `H`, and the number of misses, `M`, and outputs the hit rate, `HR`

Variable names

• x = objective value
• p = probability
• v = subjective value
• w = decision weight
• u = subjective utility
• a = α (alpha, diminishing marginal utility)
• l = λ (lambda, loss aversion)
• g = γ (gamma, probability distortion)

Methods w/implemented equations

• `xal2v(x, a, l)`
• v = if (x >= 0) x^a; if (x < 0) -l * (-x)^a
• `xlv2a(x, l, v)`
• a = if (x >= 0) log(v) / log(x); if (x < 0) (log(-v) - log(l)) / log(-x)
• `xav2l(x, a, v)`
• a = if (x >= 0) 1; if (x < 0) -v / (-x)^a
• `pg2w(p, g)`
• w = p^g / (p^g + (1 - p)^g)^(1 / g)
• `vw2u(v, w)`
• u = Sum_n(v_n * w_n)
• Accepts numbers or equal-length arrays of numbers

Development

Package Scripts

• `yarn lint`
• Lints markdown, scripts and styles
• `yarn test`
• Runs all tests and reports coverage in `test/coverage/`
• `yarn test:watch`
• Runs all tests in watch mode and reports coverage in `test/coverage/`
• `yarn test:file <filename>`
• Runs tests for a single file and reports coverage in `test/coverage/`
• `yarn build`
• Builds bundles from `src/` to `lib/`

File Organization

• `prospectable-elements/`
• `lib/` (Bundles created from `src/` by `build`) [autogenerated]
• `src/` (Source files)
• `test/` (Testing files)
• `coverage/` (Code coverage results) [autogenerated]
• `CHANGELOG.md` (Based on conventional commits) [autogenerated]
• `gulpfile.js` (Tasks for gulp)
• `package.json` (Package config for yarn and npm)
• `README.md` (This file)
• `rollup-stats.html` (Report on js bundle composition and size) [autogenerated]

Package Sidebar

Install

`npm i @decidables/prospectable-math`

4

Version

0.2.9

CC-BY-SA-4.0 AND GPL-3.0-or-later

82.4 kB

15