@decidables/prospectable-math

0.2.8 • Public • Published

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

npm version license

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

Features/Bugs/Notes

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]

License

The content of this project is licensed under Creative Commons Attribution-ShareAlike 4.0 International License (CC-BY-SA-4.0) and the source code of this project is licensed under GNU General Public License v3.0 or any later version (GPL-3.0-or-later).

Package Sidebar

Install

npm i @decidables/prospectable-math

Weekly Downloads

1

Version

0.2.8

License

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

Unpacked Size

82.2 kB

Total Files

15

Last publish

Collaborators

  • akrawitz