npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fit-beta

v2.0.3

Published

Find a beta distribution which fits a confidence interval

Downloads

22

Readme

Fit beta

About

This package provides code for finding a beta distribution whose confidence interval is the one you desire

Installation

yarn add fit-beta
# npm install fit-beta

Usage

Usage in Nodejs.

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)

Advanced usage

Besides find_beta_from_ci, this package also exports find_beta_from_ci_nelder_mead and find_beta_from_ci_cache, over find_beta_from_ci is just a thin wrapper:

export const find_beta_from_ci = ({ci_lower, ci_upper, ci_length}) => {
  let cache_answer = find_beta_from_ci_cache({ci_lower, ci_upper, ci_length})
  if(cache_answer != null ){
    return cache_answer
  } else {
    let nelder_mead_answer = find_beta_from_ci_nelder_mead({ci_lower, ci_upper, ci_length})
    return nelder_mead_answer
  }
}

find_beta_from_ci_cache is basically instantaneous, but only resolves when ci_lower and ci_upper are in (0.01, 0.02, 0.03, ..., 0.97, 0.98, 0.99, 1), and ci_length is 0.9 (i.e., 90%). find_nelder_mead uses the Nelder Mead algorithm, and will take a bit longer.

Usage in the browser

When using in the browser, you could:

  • Translate this npm package to use web imports and syntax, etc. The problem with this is that it imports parts of stdlib, which is heavy and from which it is difficult to extract only a small part, because its code is very interconnected.
  • Run this in a server, and query the server (this is what I am doing here

Usage in other languages

  • R: See here
  • Python: to do?
  • If you are a friend: I'm happy to share an endpoint, i.e., a website url that you can call with the desired confidence intervals and get back the beta parameters.

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. I also used that package to populate the cache (see below).

For the Nelder Mead method, I am using this implementation (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 all of its functions are fairly intertwined.

To do

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.