d-pac.functions v2.2.2
d-pac.functions
Installation
$ npm install d-pac.functionsUsage
const funx = require('d-pac.functions');
funx.stat.square(10); //100
funx.pm.reliability(2.6246692913372702, 0.7615773105863908);// 0.9158064516129032const stat = require('d-pac.functions/stat');
stat.square(10); //100const pm = require('d-pac.functions/pm');
pm.reliability(2.6246692913372702, 0.7615773105863908);// 0.9158064516129032API
pm
reliability
Overall consistency of a measure
Parameters
Examples
pm.reliability(4, 2); //0.75Returns 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.05186688311688284Returns 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.401312339887548Returns number The Rasch probability
fisher
Fisher information
Parameters
Examples
pm.fisher(.3, .7); //0.24026074574152914pm.fisher(.3, .7, 4); //0.2403Returns number The fisher information
stat
square
Squares a number
Parameters
valueNumber a value
Examples
stat.square(10); //100Returns Number the squared value
sum
Addition of a sequence of numbers - ∑
Parameters
collectionArray set of numbers (optional, default[])fFunction? (optional) function used to retrieve the value (optional, defaultreturnValue)
Examples
stat.sum([1, 2, 3, 5, 8 ]); //19stat.sum([{v:1}, {v:2}, {v:3}, {v:5}, {v:8}], (item)=> item.v); //19Returns Number the sum of all values
mean
Arithmetic mean, sum of a sequence of numbers divided by sequence length
Parameters
collectionArray set of numbers (optional, default[])fFunction? (optional) function used to retrieve the value (optional, defaultreturnValue)
Examples
stat.mean([1, 2, 3, 5, 8 ]); //3.8stat.mean([{v:1}, {v:2}, {v:3}, {v:5}, {v:8}], (item)=> item.v); //3.8Returns Number the arithmetic mean
variance
The distance between numbers in a set
Parameters
collectionArray set of numbers (optional, default[])fFunction? (optional) function used to retrieve the value (optional, defaultreturnValue)
Examples
stat.variance([1, 2, 3, 5, 8 ]); //6.16stat.variance([{v:1}, {v:2}, {v:3}, {v:5}, {v:8}], (item)=> item.v); //6.16Returns Number the distance between numbers in a set
sd
Standard deviation - σ
Parameters
collectionArray set of numbers (optional, default[])fFunction? (optional) function used to retrieve the value (optional, defaultreturnValue)
Examples
stat.sd([1, 2, 3, 5, 8 ]); //2.4819347291981715stat.sd([{v:1}, {v:2}, {v:3}, {v:5}, {v:8}], (item)=> item.v); //2.4819347291981715Returns Number the standard deviation
rms
Root mean square, quadratic mean
Parameters
collectionArray set of numbers (optional, default[])fFunction? (optional) function used to retrieve the value (optional, defaultreturnValue)
Examples
stat.rms([1, 2, 3, 5, 8 ]); //4.538722287164087stat.rms([{v:1}, {v:2}, {v:3}, {v:5}, {v:8}], (item)=> item.v); //4.538722287164087Returns Number the root mean square
median
Returns the median of the set
Parameters
collectionArray set of numbers (optional, default[])fFunction? (optional) function used to retrieve the value (optional, defaultreturnValue)
Examples
stat.median([2, 5, 19, 3, -100]); //3stat.median([{v:2}, {v:5}, {v:19}, {v:3}, {v:-100}], (item)=> item.v); // 3Returns Number the median
standardize
calculate standard scores of z scores: z= (x - mu)/sigma
Parameters
collectionArray set of numbers (optional, default[])getterFunction? (optional) function used to retrieve the value (optional, defaultreturnValue)setterFunction? (optional) function used to set the standardized value. Obviously could have side-effects when used. (optional, defaultnull)
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 ]