@forecasting/laplace
v1.0.3
Published
Probability of an action happening per Laplace's rule of succession
Maintainers
Readme
About
This package contains a simple function to
Built with
- vanilla javascript
- Best readme template
- lerna
Getting started
Installation
npm install @forecasting/laplaceUsage
import {
laplace
} from "@forecasting/laplace";
// Chance of a ceasefire between Israel and Hamas in the next 30 days
let num_past_successes = 1 // one previous ceasefire
let num_past_trials = 608 // 638 since the start of the war - 30 days of previous ceasefire
let num_future_trials = 30 // opportunities for a not ceasefire => ceasefire transition
let p = laplace(num_past_successes, num_past_trials, num_future_trials)
if (p == -1) {
console.log("Error in some of the inputs")
} else {
console.log("Probability per Laplace's rule of succession: ", p )
}Roadmap
- [x] validate probability (must be 0<= p <=1)
- [x] Decide on a return type if probabilities are not validated (-1? / null?)
- [x] Write wrapper code for validation
- [x] Validate that array.length > 0
- [ ] add weighting? by recency?
- [ ] filter outliers?
