Let's say I have two arrays:
a=[168, 76, 62, 86]
b=[168, 80, 65, 90]
[166.5, 75.5, 62, 86]
You could collect the absolute deltas and choose the one with the smaller error.
var array1 = [168, 76, 62, 86],
array2 = [168, 80, 65, 90],
input = [166.5, 75.5, 62, 86],
error = [array1, array2].map(function (a) {
return input.reduce(function (r, b, i) {
return r + Math.abs(a[i] -b);
}, 0);
});
console.log(error); // [2, 13] take the first one with smaller error.