function M(e){if(e.length===0)return 0;var t=e[0],n=0,r;if(typeof t!="number")return Number.NaN;for(var a=1;a<e.length;a++){if(typeof e[a]!="number")return Number.NaN;r=t+e[a],Math.abs(t)>=Math.abs(e[a])?n+=t-r+e[a]:n+=e[a]-r+t,t=r}return t+n}function b(e){if(e.length===0)throw new Error("mean requires at least one data point");return M(e)/e.length}function S(e,t){var n=b(e),r=0,a,o;for(o=0;o<e.length;o++)a=e[o]-n,r+=a*a;return r}function V(e){if(e.length===0)throw new Error("min requires at least one data point");for(var t=e[0],n=1;n<e.length;n++)e[n]<t&&(t=e[n]);return t}function N(e){if(e.length===0)throw new Error("max requires at least one data point");for(var t=e[0],n=1;n<e.length;n++)e[n]>t&&(t=e[n]);return t}function m(e,t){var n=e.length*t;if(e.length===0)throw new Error("quantile requires at least one data point.");if(t<0||t>1)throw new Error("quantiles must be between 0 and 1");return t===1?e[e.length-1]:t===0?e[0]:n%1!==0?e[Math.ceil(n)-1]:e.length%2===0?(e[n-1]+e[n])/2:e[n]}function c(e,t,n,r){for(n=n||0,r=r||e.length-1;r>n;){if(r-n>600){var a=r-n+1,o=t-n+1,l=Math.log(a),i=.5*Math.exp(2*l/3),v=.5*Math.sqrt(l*i*(a-i)/a);o-a/2<0&&(v*=-1);var g=Math.max(n,Math.floor(t-o*i/a+v)),p=Math.min(r,Math.floor(t+(a-o)*i/a+v));c(e,t,g,p)}var h=e[t],s=n,u=r;for(f(e,n,t),e[r]>h&&f(e,n,r);s<u;){for(f(e,s,u),s++,u--;e[s]<h;)s++;for(;e[u]>h;)u--}e[n]===h?f(e,n,u):(u++,f(e,u,r)),u<=t&&(n=u+1),t<=u&&(r=u-1)}}function f(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function E(e,t){var n=e.slice();if(Array.isArray(t)){y(n,t);for(var r=[],a=0;a<t.length;a++)r[a]=m(n,t[a]);return r}else{var o=d(n.length,t);return w(n,o,0,n.length-1),m(n,t)}}function w(e,t,n,r){t%1===0?c(e,t,n,r):(t=Math.floor(t),c(e,t,n,r),c(e,t+1,t+1,r))}function y(e,t){for(var n=[0],r=0;r<t.length;r++)n.push(d(e.length,t[r]));n.push(e.length-1),n.sort(D);for(var a=[0,n.length-1];a.length;){var o=Math.ceil(a.pop()),l=Math.floor(a.pop());if(!(o-l<=1)){var i=Math.floor((l+o)/2);w(e,n[i],Math.floor(n[l]),Math.ceil(n[o])),a.push(l,i,i,o)}}}function D(e,t){return e-t}function d(e,t){var n=e*t;return t===1?e-1:t===0?0:n%1!==0?Math.ceil(n)-1:e%2===0?n-.5:n}function A(e){return+E(e,.5)}function q(e){if(e.length<2)throw new Error("sampleVariance requires at least two data points");var t=S(e),n=e.length-1;return t/n}function C(e){var t=q(e);return Math.sqrt(t)}const I=e=>V(e),P=e=>N(e),Q=e=>A(e),X=e=>C(e??[]),B=e=>q(e),F=e=>M(e);export{Q as M,X as S,B as V,F as a,P as b,I as c};
