New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

resample

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

resample

Resample functions

latest
Source
npmnpm
Version
0.0.2
Version published
Maintainers
1
Created
Source

resample

Resampling methods for variance and bias estimation. Currently implemented such techniques:

  • Resample
  • Shuffle
  • Bootstrap
  • Jackknife

no tests yet

resample generates new samples from an input array and applies to them passed function to generate multiple estimation replicates. Then those replicates are used to calculate mean, bias and standard error of an estimate

Install

npm i -S resample

Usage

var { bootstrap, jackknife } = require('resample')

function mean (array) {
  return array.reduce((a, b) => a + b) / array.length
}

bootstrap([1, 2, 3, 4, 5, 6, 40], mean)
// { observed: 8.71, mean: 8.74, se: 4.84, bias: 0.029, replicates: [...], samples: [...] }

The bootstrap method supports an extra parameter that sets number of samples/iterations (default: 10000)

bootstrap([1, 2, 3, 4, 5, 6, 40], mean, 10000)

Passing only number of samples without the estimator function return raw samples with replacement

bootstrap([1, 2, 3, 4, 5, 6, 40], 2))
// [[ 2, 40, 1, 1, 5, 2, 6], [2, 3, 4, 4, 2, 40, 6]]

Keywords

resample

FAQs

Package last updated on 24 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts