This package provides code for obtaining the parameters of a beta distribution which will make it fit a given 90% confidence interval.
Although it is fast in terms of human usage (it takes half a second), it is not recommended for usage inside another project, like Squiggle, because 0.5s here and 0.5s there add up fairly fast. Rather, the code should be called, and the parameters included in the second program.
Code for this repository is inspired by this package for R. In particular, that package uses R's powerful optim
function, and I bothered looking up what optim
uses as a default: the Nelder Mead method. From that R package, I am also using the default initial search point of a=50, b=50, though I add a grid search in case that fails.
For the Nelder Mead method, I am using this implementation of the Nelder Mead method (I tried other algorithms, like BFGS, and implemented a version of backtracking line search, but Nelder Mead proved to just be better). See the nelderMead
folder.
For various functions, I am using stdlib. I tried to extract the core code from them, but sadly they are all fairly intertwined.
yarn add fit-beta
# npm install fit-beta
Set "type": "module",
in your package json, then:
import {find_beta_from_ci} from 'fit-beta'
let result1 = find_beta_from_ci({ci_lower: 0.3, ci_upper: 0.8})
console.log(result1)
- R: See here
- Python: to do.
- Add test coverage
- Add a frontend to this
- ...
Contributions are welcome.
Distributed under the MIT license, except for src/nelderMead
, which is distributed under the BSD-3-Clause license, which is satisfied by including the BSD-3-Clause license in the src/nelderMead
folder.