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

d-pac.functions

v2.2.2

Published

Statistical and psychometic helper functions used in d-pac

Downloads

7

Readme

NPM version Build Status Dependency Status

d-pac.functions

Installation

$ npm install d-pac.functions

Usage

const funx = require('d-pac.functions');

funx.stat.square(10); //100
funx.pm.reliability(2.6246692913372702, 0.7615773105863908);// 0.9158064516129032
const stat = require('d-pac.functions/stat');
stat.square(10); //100
const pm = require('d-pac.functions/pm');
pm.reliability(2.6246692913372702, 0.7615773105863908);// 0.9158064516129032

API

pm

reliability

Overall consistency of a measure

Parameters

Examples

pm.reliability(4, 2); //0.75

Returns number The reliability

reliabilityFunctor

Creates a function by taking two getters, which can be used to calculate the reliability of a set of values and SE's

Parameters

Examples

const list = [{v:1, se:4}, {v:2, se:2}, {v:3, se:0}, {v:5, se:0.45}, {v:8, se:3}];
const f = pm.reliabilityFunctor((item)=>item.v, (item)=>item.se);
f(list); //0.05186688311688284

Returns Function Function to be used on a list to calculate the reliability

rasch

Rasch probability or Bradley-Terry-Luce probability

Parameters

Examples

pm.rasch(.3, .7); //0.401312339887548

Returns number The Rasch probability

fisher

Fisher information

Parameters

  • aF number param A
  • bF number param B
  • digits number? number of digits to appear after the decimal point

Examples

pm.fisher(.3, .7); //0.24026074574152914
pm.fisher(.3, .7, 4); //0.2403

Returns number The fisher information

stat

square

Squares a number

Parameters

Examples

stat.square(10); //100

Returns Number the squared value

sum

Addition of a sequence of numbers - ∑

Parameters

  • collection Array set of numbers (optional, default [])
  • f Function? (optional) function used to retrieve the value (optional, default returnValue)

Examples

stat.sum([1, 2, 3, 5, 8 ]); //19
stat.sum([{v:1}, {v:2}, {v:3}, {v:5}, {v:8}], (item)=> item.v); //19

Returns Number the sum of all values

mean

Arithmetic mean, sum of a sequence of numbers divided by sequence length

Parameters

  • collection Array set of numbers (optional, default [])
  • f Function? (optional) function used to retrieve the value (optional, default returnValue)

Examples

stat.mean([1, 2, 3, 5, 8 ]); //3.8
stat.mean([{v:1}, {v:2}, {v:3}, {v:5}, {v:8}], (item)=> item.v); //3.8

Returns Number the arithmetic mean

variance

The distance between numbers in a set

Parameters

  • collection Array set of numbers (optional, default [])
  • f Function? (optional) function used to retrieve the value (optional, default returnValue)

Examples

stat.variance([1, 2, 3, 5, 8 ]); //6.16
stat.variance([{v:1}, {v:2}, {v:3}, {v:5}, {v:8}], (item)=> item.v); //6.16

Returns Number the distance between numbers in a set

sd

Standard deviation - σ

Parameters

  • collection Array set of numbers (optional, default [])
  • f Function? (optional) function used to retrieve the value (optional, default returnValue)

Examples

stat.sd([1, 2, 3, 5, 8 ]); //2.4819347291981715
stat.sd([{v:1}, {v:2}, {v:3}, {v:5}, {v:8}], (item)=> item.v); //2.4819347291981715

Returns Number the standard deviation

rms

Root mean square, quadratic mean

Parameters

  • collection Array set of numbers (optional, default [])
  • f Function? (optional) function used to retrieve the value (optional, default returnValue)

Examples

stat.rms([1, 2, 3, 5, 8 ]); //4.538722287164087
stat.rms([{v:1}, {v:2}, {v:3}, {v:5}, {v:8}], (item)=> item.v); //4.538722287164087

Returns Number the root mean square

median

Returns the median of the set

Parameters

  • collection Array set of numbers (optional, default [])
  • f Function? (optional) function used to retrieve the value (optional, default returnValue)

Examples

stat.median([2, 5, 19, 3, -100]); //3
stat.median([{v:2}, {v:5}, {v:19}, {v:3}, {v:-100}], (item)=> item.v); // 3

Returns Number the median

standardize

calculate standard scores of z scores: z= (x - mu)/sigma

Parameters

  • collection Array set of numbers (optional, default [])
  • getter Function? (optional) function used to retrieve the value (optional, default returnValue)
  • setter Function? (optional) function used to set the standardized value. Obviously could have side-effects when used. (optional, default null)

Examples

stat.standardize([ 2, 5, 19, -5, 3, -100, -27, -2 ]);
// [ 0.4326093777237974,  0.5184161964458729,  0.918848017148892,  0.23239346737228786,  0.4612116506311559, -2.4848224588267702, -0.39685653658959924,  0.31820028609436335 ]
stat.standardize([{v:2}, {v:5}, {v:19}, {v:3}, {v:-100}, {v:-27}, {v:-2}], (item)=> item.v);
// [ 0.4326093777237974,  0.5184161964458729,  0.918848017148892,  0.23239346737228786,  0.4612116506311559, -2.4848224588267702, -0.39685653658959924,  0.31820028609436335 ]

Returns Array<Number> an array of standardized z scores