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

wilson-interval

v4.0.5

Published

Used to calculate the high bound, low bound, and center of a Wilson score interval. Features support for continuity correction and Singleton's adjustment.

Downloads

44

Readme

Wilson Interval

license npm npm CircleCI Coveralls

Pull Requests Welcome

A comprehensive module used to calculate the high bound, low bound, and center of a Wilson score interval. Features support for known populations (i.e. Singleton's adjustment).

Popularized by Reddit's Comment/Best Sort and similar voting algorithms.

Install

npm install wilson-interval

Include

import wilson from 'wilson-interval';

Usage

wilson(observed, sample[, population ][, options ]);

  • observed - Number of observed positive outcomes.

  • sample - Size of sample.

Optional arguments:

  • population - Default false. Total population from which sample was taken (to use Singleton's adjustment[1]).

  • options - Default {}. Options object. Available parameters:

    • confidence - Default 0.95. Desired confidence level of interval.
    • precision - Default 20. Number of significant figures to use in calculations and output.

Example

return wilson(5, 100);

returns

{
  "center": "0.066647073981204927863",
  "high": "0.11175046869375655694",
  "low": "0.021543679268653298792",
}

Use cases

Low bound sorting

Most often, the low bound of the interval will be used as the sorting parameter (e.g. Reddit's Comment/Best Sort). This places more importance on confidence than total score.

Even if a ranked item has 100% positive responses, this ensures it won't be ranked at the top until enough data has been gathered for the algorithm to be confident that that ratio is what it really deserves.

Singleton's adjustment

Uses a known, finite population size to inform the degree of uncertainty of the prediction.

Singleton's adjustment

Descriptive statistics summarises the sample as if it were the entire population (left), whereas inferential statistics assumes the sample is a tiny subset of the population (right). If the sample is a large part of the population the confidence interval on observations is reduced (middle).[1]

USE WHEN:

  1. Your sample size represents a significant portion of the population.
  2. You have an imperfect original sample, from which you can only verify a subsample. The original sample can serve as a "population" to produce a verification interval to be combined with the first.[2]

Sources

[1] Wallis, Sean 2012. Inferential Statistics — and other animals. London: Survey of English Usage, UCL.

[2] Wallis, Sean 2014. Coping with imperfect data. London: Survey of English Usage, UCL.


Special thanks to Sean Wallis—Senior Research Fellow, Survey of English Usage—for his aid in transcribing equations, and for his blog posts which inspired many of the features of this module.