Skip to content

d-pac/d-pac.functions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

  • getAbility Function getter for ability
  • getSE Function getter for standard error

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

About

Statistical and psychometric helper functions used in d-pac

Resources

License

Stars

Watchers

Forks

Packages

No packages published