$ npm install d-pac.functions
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
Overall consistency of a measure
Parameters
Examples
pm.reliability(4, 2); //0.75
Returns number The reliability
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 probability or Bradley-Terry-Luce probability
Parameters
Examples
pm.rasch(.3, .7); //0.401312339887548
Returns number The Rasch probability
Fisher information
Parameters
aF
number param AbF
number param Bdigits
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
Squares a number
Parameters
value
Number a value
Examples
stat.square(10); //100
Returns Number the squared value
Addition of a sequence of numbers - ∑
Parameters
collection
Array set of numbers (optional, default[]
)f
Function? (optional) function used to retrieve the value (optional, defaultreturnValue
)
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
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, defaultreturnValue
)
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
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, defaultreturnValue
)
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
Standard deviation - σ
Parameters
collection
Array set of numbers (optional, default[]
)f
Function? (optional) function used to retrieve the value (optional, defaultreturnValue
)
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
Root mean square, quadratic mean
Parameters
collection
Array set of numbers (optional, default[]
)f
Function? (optional) function used to retrieve the value (optional, defaultreturnValue
)
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
Returns the median of the set
Parameters
collection
Array set of numbers (optional, default[]
)f
Function? (optional) function used to retrieve the value (optional, defaultreturnValue
)
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
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, defaultreturnValue
)setter
Function? (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 ]