Skip to content

Commit 3d916bb

Browse files
committed
tweak: add README.md, reorg
1 parent 018a0a6 commit 3d916bb

File tree

7 files changed

+24
-0
lines changed

7 files changed

+24
-0
lines changed

README.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Extract the parameters for a beta distribution from its 90% confidence interval
2+
====================
3+
4+
## About
5+
6+
This package provides code for obtaining the parameters of a beta distribution which will make it fit a given 90% confidence interval.
7+
8+
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.
9+
10+
Code for this repository is inspired by [this package for R](https://github.com/gitMarcH/bootComb). In particular, it 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.
11+
12+
For the Nelder Mead method, I am using [this implementation](https://github.com/benfred/fmin/blob/master/src/nelderMead.js) of the [Nelder Mead method](https://en.wikipedia.org/wiki/Nelder%E2%80%93Mead_method) (I tried other algorithms, like [BFGS](https://en.wikipedia.org/wiki/Broyden%E2%80%93Fletcher%E2%80%93Goldfarb%E2%80%93Shanno_algorithm), and implemented a version of [backtracking line search](https://en.wikipedia.org/wiki/Backtracking_line_search), but Nelder Mead proved to just be better). See the `nelderMead` folder.
13+
14+
For various functions, I am using [stdlib](https://stdlib.io/). I tried to extract them, but sadly they are all fairly intertwined.
15+
16+
##

src/R/beta.R

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# install.packages('bootComb')
2+
library(bootComb)
3+
4+
params <- getBetaFromCI(qLow=0.2,qUpp=0.3,alpha=0.1)$pars
5+
params
6+
# ^ get the parameters of a beta distribution
7+
# whose 90% (1-alpha) confidence interval
8+
# is 0.2 to 0.8

index.js src/index.js

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

test.js src/test.js

File renamed without changes.

0 commit comments

Comments
 (0)