linear-autoscale

Automatically scale a dataset to fit in a certain interval. Also generates the inverse.

npm install linear-autoscale
4 downloads in the last month

linear-autoscale

example

example.js:

var autoscale = require('./index');

var t = autoscale();

var dataset = [-50, 12, 40, 26];

console.log('d: %j', dataset);
console.log('f(d): %j', t(dataset));
console.log('f_inv(f(d)): %j (expect some numerical decay here)',
  t(dataset).inv(t(dataset))
);

output:

$ node example.js 
d: [-50,12,40,26]
f(d): [0,0.6888888888888889,1,0.8444444444444446]
f_inv(f(d)): [-50,11.999999999999996,39.99999999999999,26.000000000000007]
josh@onix:/tmp/scale$ node example.js 
d: [-50,12,40,26]
f(d): [0,0.6888888888888889,1,0.8444444444444446]
f_inv(f(d)): [-50,11.999999999999996,39.99999999999999,26.000000000000007] (expect some numerical decay here)
$

license

MIT/X11

npm loves you