Skip to content

quantified-uncertainty/fit-beta

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Extract the parameters for a beta distribution from its 90% confidence interval

About

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.

Technical details

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.

Installation

yarn add fit-beta
# npm install fit-beta

Usage

Usage in Javascript

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)

Usage in other languages

  • R: See here
  • Python: to do.

To do

  • Add test coverage
  • Add a frontend to this
  • ...

Contributions

Contributions are welcome.

License

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •