node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »



screen shot 2016-04-27 at 14 52 43

Sample Sizer uses Student's T-Distribution to identify minimum sample sizes. If you find yourself asking the question, "do I have enough data?" you'll be able to answer your question with this tool.

Minimum Sample Sizes

The calculation of a minimum sample size a function of your samples Degrees of Freedom, Standard Deviation, and T-Critical Value, which is a function of those Degrees of Freedom and your desired Confidence level.


When you call the main function in index.js, you'll need to provide a sample (array), a confidence value (float), and an error tolerance (int).

The following code asks the question, "If this is my sample, how many observations do I need to estimate the population average +/- 3, with 90% confidence.

var sizer = require('sample-sizer');
var minimumSize1 = sizer([1,2,3,2,1,2,3,99], .9, 3);

If the number you get is less than the length of your sample array, you need to increase your sample size! You can't be (as) confident (as you want to be) that your data is representative of the population.