(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?module.exports=factory():typeof define==="function"&&define.amd?define(factory):global.mahalanobis=factory()})(this,function(){"use strict";function mean(arr){return sum(arr)/arr.length}function sum(arr){return arr.reduce(function(a,b){return a+b})}function isNumeric(n){return typeof n==="number"&&!isNaN(n)}function sum$1(arr){return arr.reduce(function(a,b){return a+b})}function isNumeric$1(n){return typeof n==="number"&&!isNaN(n)}function dot$1(a,b){if(a.length!==b.length){throw new TypeError("Vectors are of different sizes")}return sum$1(a.map(function(x,i){return x*b[i]}))}function multiply$1(a,b){var aSize=a.every(isNumeric$1)?1:a.length,bSize=b.every(isNumeric$1)?1:b.length;if(aSize===1){if(bSize===1){return dot$1(a,b)}return b.map(function(row){return dot$1(a,row)})}if(bSize===1){return a.map(function(row){return dot$1(row,b)})}return a.map(function(x){return transpose$1(b).map(function(y){return dot$1(x,y)})})}function transpose$1(matrix){return matrix[0].map(function(d,i){return matrix.map(function(row){return row[i]})})}function cov$1(columns,means){return columns.map(function(c1,i){return columns.map(function(c2,j){var terms=c1.map(function(x,k){return(x-means[i])*(c2[k]-means[j])});return sum$1(terms)/(c1.length-1)})})}function invert$1(matrix){var size=matrix.length,base,swap,augmented;augmented=matrix.map(function(row,i){return row.slice(0).concat(row.slice(0).map(function(d,j){return j===i?1:0}))});for(var r=0;r