@datagrok/curves 1.2.16 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/package.js CHANGED
@@ -1,2 +1,2 @@
1
- var curves;(()=>{var __webpack_modules__={78:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{"use strict";function copyInto(r,n){for(var e=0;e<n.length;e++)r[e]=n[e]}function limitedMemoryBFGS(r,n){var e=+new Date,t=n.length,o=numeric.rep([t],0);r.getGradient(n,o);var i=numeric.clone(o),u=numeric.clone(n),a=numeric.clone(o);numeric.diveq(a,numeric.norm2(a));var s=[],c=[],l=[],f=(backtrackingLineSearch(r,a,o,n),r.getValue(n));o=r.getGradient(n,o);for(var m=f,h=0;h<100;h++){var p;if(new Date,s.length<4)s.unshift(numeric.sub(n,u)),c.unshift(numeric.sub(o,i));else{for(var d=s.pop(),g=c.pop(),v=0;v<t;v++)d[v]=n[v]-u[v],g[v]=o[v]-i[v];s.unshift(d),c.unshift(g)}copyInto(u,n),copyInto(i,o);var y=0,x=0;for(v=0;v<t;v++)y+=s[0][v]*c[0][v],x+=c[0][v]*c[0][v];var w=y/x;l.unshift(1/y),copyInto(a,o);for(var b=[],T=0;T<s.length;T++){var _=0;for(v=0;v<t;v++)_+=s[T][v]*a[v];for(_*=l[T],b.push(_),v=0;v<t;v++)a[v]+=c[T][v]*-_}for(v=0;v<t;v++)a[v]*=w;for(T=s.length-1;T>=0;T--){var M=0;for(v=0;v<t;v++)M+=c[T][v]*a[v];for(M*=l[T],_=b[T],v=0;v<t;v++)a[v]+=s[T][v]*(_-M)}for(v=0;v<t;v++)a[v]=-a[v];if(backtrackingLineSearch(r,a,o,n),f=r.getValue(n),o=r.getGradient(n,o),2*(f-m)<=1e-4*(Math.abs(f)+Math.abs(m)+1e-5))return p=+new Date,!0;var A=numeric.norm2(o);if(A<.001)return p=+new Date,!0;if(0==A)return p=+new Date,!0;m=f}return p=+new Date,console.log("Finished iterations "+(p-e)),!0}function backtrackingLineSearch(r,n,e,t){var o=t.length,i=0,u=1,a=0,s=r.getValue(t),c=s,l=numeric.norm2(n);l>100&&numeric.muleq(n,100/l);for(var f=0,m=0;m<o;m++)f+=e[m]*n[m];var h=0;for(m=0;m<o;m++){var p=Math.abs(n[m]/Math.max(Math.abs(t[m]),1));p>h&&(h=p)}for(var d=1e-4/h,g=0;g<25;g++){for(m=0;m<o;m++)t[m]+=(u-i)*n[m];if(u<d)return 0;var v=r.getValue(t);if(v>=s+1e-4*u*f)return u;if(isFinite(v))if(1==u)a=-f/(2*(v-s-f));else{var y=v-s-u*f,x=c-s-i*f,w=1/(u*u),b=1/(i*i),T=1/(u-i),_=T*(y*w-x*b),M=T*(-y*i*w+x*u*b);if(0==_)a=-f/(2*M);else{var A=M*M-3*_*f;a=A<0?.5*u:M<=0?(-M+Math.sqrt(A))/(3*_):-f/(M+Math.sqrt(A))}a>.5*u&&(a=.5*u)}else a=.2*u;c=v,i=u,u=Math.max(a,.1*u)}}__webpack_require__.d(__webpack_exports__,{U:()=>limitedMemoryBFGS});var quadratic={getValue:function(r){var n=r[0],e=r[1];return-3*n*n-4*e*e+2*n-4*e+18},getGradient:function(r,n){return n[0]=-6*r[0]+2,n[1]=-8*r[1]-4,n}};function doubleExp(r){for(var n=Array(r),e=0;e<r;e++)n[e]=Math.log(Math.random())*(Math.random()>.5?1:-1);return n}var ridgeRegression={covariates:[],responses:[],originalParameters:doubleExp(100),sample:function(r,n){for(var e=0;e<r;e++){var t=doubleExp(100);this.responses.push(numeric.dot(t,this.originalParameters)+n()),this.covariates.push(t)}},getValue:function(r){for(var n=0,e=0;e<this.covariates.length;e++){var t=this.responses[e]-numeric.dot(this.covariates[e],r);n+=-.5*t*t}return n},getGradient:function(r,n){for(var e=0;e<this.covariates.length;e++){var t=this.responses[e]-numeric.dot(this.covariates[e],r);numeric.addeq(n,numeric.mul(this.covariates[e],t))}return n}},numeric="undefined"==typeof exports?function(){}:exports;void 0!==__webpack_require__.g&&(__webpack_require__.g.numeric=numeric),numeric.version="1.2.6",numeric.bench=function(r,n){var e,t,o;for(void 0===n&&(n=15),t=.5,e=new Date;;){for(o=t*=2;o>3;o-=4)r(),r(),r(),r();for(;o>0;)r(),o--;if(new Date-e>n)break}for(o=t;o>3;o-=4)r(),r(),r(),r();for(;o>0;)r(),o--;return 1e3*(3*t-1)/(new Date-e)},numeric._myIndexOf=function(r){var n,e=this.length;for(n=0;n<e;++n)if(this[n]===r)return n;return-1},numeric.myIndexOf=Array.prototype.indexOf?Array.prototype.indexOf:numeric._myIndexOf,numeric.Function=Function,numeric.precision=4,numeric.largeArray=50,numeric.prettyPrint=function(r){function n(r){if(0===r)return"0";if(isNaN(r))return"NaN";if(r<0)return"-"+n(-r);if(isFinite(r)){var e=Math.floor(Math.log(r)/Math.log(10)),t=r/Math.pow(10,e),o=t.toPrecision(numeric.precision);return 10===parseFloat(o)&&(e++,o=(t=1).toPrecision(numeric.precision)),parseFloat(o).toString()+"e"+e.toString()}return"Infinity"}var e=[];return function r(t){var o;if(void 0===t)return e.push(Array(numeric.precision+8).join(" ")),!1;if("string"==typeof t)return e.push('"'+t+'"'),!1;if("boolean"==typeof t)return e.push(t.toString()),!1;if("number"==typeof t){var i=n(t),u=t.toPrecision(numeric.precision),a=parseFloat(t.toString()).toString(),s=[i,u,a,parseFloat(u).toString(),parseFloat(a).toString()];for(o=1;o<s.length;o++)s[o].length<i.length&&(i=s[o]);return e.push(Array(numeric.precision+8-i.length).join(" ")+i),!1}if(null===t)return e.push("null"),!1;if("function"==typeof t){e.push(t.toString());var c=!1;for(o in t)t.hasOwnProperty(o)&&(c?e.push(",\n"):e.push("\n{"),c=!0,e.push(o),e.push(": \n"),r(t[o]));return c&&e.push("}\n"),!0}if(t instanceof Array){if(t.length>numeric.largeArray)return e.push("...Large Array..."),!0;for(c=!1,e.push("["),o=0;o<t.length;o++)o>0&&(e.push(","),c&&e.push("\n ")),c=r(t[o]);return e.push("]"),!0}for(o in e.push("{"),c=!1,t)t.hasOwnProperty(o)&&(c&&e.push(",\n"),c=!0,e.push(o),e.push(": \n"),r(t[o]));return e.push("}"),!0}(r),e.join("")},numeric.parseDate=function(r){return function r(n){if("string"==typeof n)return Date.parse(n.replace(/-/g,"/"));if(n instanceof Array){var e,t=[];for(e=0;e<n.length;e++)t[e]=r(n[e]);return t}throw new Error("parseDate: parameter must be arrays of strings")}(r)},numeric.parseFloat=function(r){return function r(n){if("string"==typeof n)return parseFloat(n);if(n instanceof Array){var e,t=[];for(e=0;e<n.length;e++)t[e]=r(n[e]);return t}throw new Error("parseFloat: parameter must be arrays of strings")}(r)},numeric.parseCSV=function(r){var n,e,t,o=r.split("\n"),i=[],u=/(([^'",]*)|('[^']*')|("[^"]*")),/g,a=/^\s*(([+-]?[0-9]+(\.[0-9]*)?(e[+-]?[0-9]+)?)|([+-]?[0-9]*(\.[0-9]+)?(e[+-]?[0-9]+)?))\s*$/,s=0;for(e=0;e<o.length;e++){var c,l=(o[e]+",").match(u);if(l.length>0){for(i[s]=[],n=0;n<l.length;n++)c=(t=l[n]).substr(0,t.length-1),a.test(c)?i[s][n]=parseFloat(c):i[s][n]=c;s++}}return i},numeric.toCSV=function(r){var n,e,t,o,i,u=numeric.dim(r);for(t=u[0],u[1],i=[],n=0;n<t;n++){for(o=[],e=0;e<t;e++)o[e]=r[n][e].toString();i[n]=o.join(", ")}return i.join("\n")+"\n"},numeric.getURL=function(r){var n=new XMLHttpRequest;return n.open("GET",r,!1),n.send(),n},numeric.imageURL=function(r){function n(r,n,e){void 0===n&&(n=0),void 0===e&&(e=r.length);var t,o=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117],i=-1;for(r.length,t=n;t<e;t++)i=i>>>8^o[255&(i^r[t])];return-1^i}var e,t,o,i,u,a,s,c,l,f,m=r[0].length,h=r[0][0].length,p=[137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,h>>24&255,h>>16&255,h>>8&255,255&h,m>>24&255,m>>16&255,m>>8&255,255&m,8,2,0,0,0,-1,-2,-3,-4,-5,-6,-7,-8,73,68,65,84,8,29];for(f=n(p,12,29),p[29]=f>>24&255,p[30]=f>>16&255,p[31]=f>>8&255,p[32]=255&f,e=1,t=0,s=0;s<m;s++){for(s<m-1?p.push(0):p.push(1),u=3*h+1+(0===s)&255,a=3*h+1+(0===s)>>8&255,p.push(u),p.push(a),p.push(255&~u),p.push(255&~a),0===s&&p.push(0),c=0;c<h;c++)for(o=0;o<3;o++)t=(t+(e=(e+(u=(u=r[o][s][c])>255?255:u<0?0:Math.round(u)))%65521))%65521,p.push(u);p.push(0)}return l=(t<<16)+e,p.push(l>>24&255),p.push(l>>16&255),p.push(l>>8&255),p.push(255&l),i=p.length-41,p[33]=i>>24&255,p[34]=i>>16&255,p[35]=i>>8&255,p[36]=255&i,f=n(p,37),p.push(f>>24&255),p.push(f>>16&255),p.push(f>>8&255),p.push(255&f),p.push(0),p.push(0),p.push(0),p.push(0),p.push(73),p.push(69),p.push(78),p.push(68),p.push(174),p.push(66),p.push(96),p.push(130),"data:image/png;base64,"+function(r){var n,e,t,o,i,u,a,s=r.length,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l="";for(n=0;n<s;n+=3)i=((3&(e=r[n]))<<4)+((t=r[n+1])>>4),u=((15&t)<<2)+((o=r[n+2])>>6),a=63&o,n+1>=s?u=a=64:n+2>=s&&(a=64),l+=c.charAt(e>>2)+c.charAt(i)+c.charAt(u)+c.charAt(a);return l}(p)},numeric._dim=function(r){for(var n=[];"object"==typeof r;)n.push(r.length),r=r[0];return n},numeric.dim=function(r){var n;return"object"==typeof r?"object"==typeof(n=r[0])?"object"==typeof n[0]?numeric._dim(r):[r.length,n.length]:[r.length]:[]},numeric.mapreduce=function(r,n){return Function("x","accum","_s","_k",'if(typeof accum === "undefined") accum = '+n+';\nif(typeof x === "number") { var xi = x; '+r+'; return accum; }\nif(typeof _s === "undefined") _s = numeric.dim(x);\nif(typeof _k === "undefined") _k = 0;\nvar _n = _s[_k];\nvar i,xi;\nif(_k < _s.length-1) {\n for(i=_n-1;i>=0;i--) {\n accum = arguments.callee(x[i],accum,_s,_k+1);\n } return accum;\n}\nfor(i=_n-1;i>=1;i-=2) { \n xi = x[i];\n '+r+";\n xi = x[i-1];\n "+r+";\n}\nif(i === 0) {\n xi = x[i];\n "+r+"\n}\nreturn accum;")},numeric.mapreduce2=function(r,n){return Function("x","var n = x.length;\nvar i,xi;\n"+n+";\nfor(i=n-1;i!==-1;--i) { \n xi = x[i];\n "+r+";\n}\nreturn accum;")},numeric.same=function r(n,e){var t,o;if(n instanceof Array&&e instanceof Array){if((o=n.length)!==e.length)return!1;for(t=0;t<o;t++)if(n[t]!==e[t]){if("object"!=typeof n[t])return!1;if(!r(n[t],e[t]))return!1}return!0}return!1},numeric.rep=function(r,n,e){void 0===e&&(e=0);var t,o=r[e],i=Array(o);if(e===r.length-1){for(t=o-2;t>=0;t-=2)i[t+1]=n,i[t]=n;return-1===t&&(i[0]=n),i}for(t=o-1;t>=0;t--)i[t]=numeric.rep(r,n,e+1);return i},numeric.dotMMsmall=function(r,n){var e,t,o,i,u,a,s,c,l,f,m;for(i=r.length,u=n.length,a=n[0].length,s=Array(i),e=i-1;e>=0;e--){for(c=Array(a),l=r[e],o=a-1;o>=0;o--){for(f=l[u-1]*n[u-1][o],t=u-2;t>=1;t-=2)m=t-1,f+=l[t]*n[t][o]+l[m]*n[m][o];0===t&&(f+=l[0]*n[0][o]),c[o]=f}s[e]=c}return s},numeric._getCol=function(r,n,e){var t;for(t=r.length-1;t>0;--t)e[t]=r[t][n],e[--t]=r[t][n];0===t&&(e[0]=r[0][n])},numeric.dotMMbig=function(r,n){var e,t,o,i=numeric._getCol,u=n.length,a=Array(u),s=r.length,c=n[0].length,l=new Array(s),f=numeric.dotVV;for(--u,t=--s;-1!==t;--t)l[t]=Array(c);for(t=--c;-1!==t;--t)for(i(n,t,a),o=s;-1!==o;--o)e=r[o],l[o][t]=f(e,a);return l},numeric.dotMV=function(r,n){var e,t=r.length,o=(n.length,Array(t)),i=numeric.dotVV;for(e=t-1;e>=0;e--)o[e]=i(r[e],n);return o},numeric.dotVM=function(r,n){var e,t,o,i,u,a,s;for(o=r.length,i=n[0].length,u=Array(i),t=i-1;t>=0;t--){for(a=r[o-1]*n[o-1][t],e=o-2;e>=1;e-=2)s=e-1,a+=r[e]*n[e][t]+r[s]*n[s][t];0===e&&(a+=r[0]*n[0][t]),u[t]=a}return u},numeric.dotVV=function(r,n){var e,t,o=r.length,i=r[o-1]*n[o-1];for(e=o-2;e>=1;e-=2)t=e-1,i+=r[e]*n[e]+r[t]*n[t];return 0===e&&(i+=r[0]*n[0]),i},numeric.dot=function(r,n){var e=numeric.dim;switch(1e3*e(r).length+e(n).length){case 2002:return n.length<10?numeric.dotMMsmall(r,n):numeric.dotMMbig(r,n);case 2001:return numeric.dotMV(r,n);case 1002:return numeric.dotVM(r,n);case 1001:return numeric.dotVV(r,n);case 1e3:return numeric.mulVS(r,n);case 1:return numeric.mulSV(r,n);case 0:return r*n;default:throw new Error("numeric.dot only works on vectors and matrices")}},numeric.diag=function(r){var n,e,t,o,i=r.length,u=Array(i);for(n=i-1;n>=0;n--){for(o=Array(i),e=n+2,t=i-1;t>=e;t-=2)o[t]=0,o[t-1]=0;for(t>n&&(o[t]=0),o[n]=r[n],t=n-1;t>=1;t-=2)o[t]=0,o[t-1]=0;0===t&&(o[0]=0),u[n]=o}return u},numeric.getDiag=function(r){var n,e=Math.min(r.length,r[0].length),t=Array(e);for(n=e-1;n>=1;--n)t[n]=r[n][n],t[--n]=r[n][n];return 0===n&&(t[0]=r[0][0]),t},numeric.identity=function(r){return numeric.diag(numeric.rep([r],1))},numeric.pointwise=function(r,n,e){void 0===e&&(e="");var t,o,i=[],u=/\[i\]$/,a="",s=!1;for(t=0;t<r.length;t++)u.test(r[t])?a=o=r[t].substring(0,r[t].length-3):o=r[t],"ret"===o&&(s=!0),i.push(o);return i[r.length]="_s",i[r.length+1]="_k",i[r.length+2]='if(typeof _s === "undefined") _s = numeric.dim('+a+');\nif(typeof _k === "undefined") _k = 0;\nvar _n = _s[_k];\nvar i'+(s?"":", ret = Array(_n)")+";\nif(_k < _s.length-1) {\n for(i=_n-1;i>=0;i--) ret[i] = arguments.callee("+r.join(",")+",_s,_k+1);\n return ret;\n}\n"+e+"\nfor(i=_n-1;i!==-1;--i) {\n "+n+"\n}\nreturn ret;",Function.apply(null,i)},numeric.pointwise2=function(r,n,e){void 0===e&&(e="");var t,o,i=[],u=/\[i\]$/,a="",s=!1;for(t=0;t<r.length;t++)u.test(r[t])?a=o=r[t].substring(0,r[t].length-3):o=r[t],"ret"===o&&(s=!0),i.push(o);return i[r.length]="var _n = "+a+".length;\nvar i"+(s?"":", ret = Array(_n)")+";\n"+e+"\nfor(i=_n-1;i!==-1;--i) {\n"+n+"\n}\nreturn ret;",Function.apply(null,i)},numeric._biforeach=function r(n,e,t,o,i){var u;if(o!==t.length-1)for(u=t[o]-1;u>=0;u--)r("object"==typeof n?n[u]:n,"object"==typeof e?e[u]:e,t,o+1,i);else i(n,e)},numeric._biforeach2=function r(n,e,t,o,i){if(o===t.length-1)return i(n,e);var u,a=t[o],s=Array(a);for(u=a-1;u>=0;--u)s[u]=r("object"==typeof n?n[u]:n,"object"==typeof e?e[u]:e,t,o+1,i);return s},numeric._foreach=function r(n,e,t,o){var i;if(t!==e.length-1)for(i=e[t]-1;i>=0;i--)r(n[i],e,t+1,o);else o(n)},numeric._foreach2=function r(n,e,t,o){if(t===e.length-1)return o(n);var i,u=e[t],a=Array(u);for(i=u-1;i>=0;i--)a[i]=r(n[i],e,t+1,o);return a},numeric.ops2={add:"+",sub:"-",mul:"*",div:"/",mod:"%",and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">=",band:"&",bor:"|",bxor:"^",lshift:"<<",rshift:">>",rrshift:">>>"},numeric.opseq={addeq:"+=",subeq:"-=",muleq:"*=",diveq:"/=",modeq:"%=",lshifteq:"<<=",rshifteq:">>=",rrshifteq:">>>=",bandeq:"&=",boreq:"|=",bxoreq:"^="},numeric.mathfuns=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan","isNaN","isFinite"],numeric.mathfuns2=["atan2","pow","max","min"],numeric.ops1={neg:"-",not:"!",bnot:"~",clone:""},numeric.mapreducers={any:["if(xi) return true;","var accum = false;"],all:["if(!xi) return false;","var accum = true;"],sum:["accum += xi;","var accum = 0;"],prod:["accum *= xi;","var accum = 1;"],norm2Squared:["accum += xi*xi;","var accum = 0;"],norminf:["accum = max(accum,abs(xi));","var accum = 0, max = Math.max, abs = Math.abs;"],norm1:["accum += abs(xi)","var accum = 0, abs = Math.abs;"],sup:["accum = max(accum,xi);","var accum = -Infinity, max = Math.max;"],inf:["accum = min(accum,xi);","var accum = Infinity, min = Math.min;"]},function(){var r,n;for(r=0;r<numeric.mathfuns2.length;++r)n=numeric.mathfuns2[r],numeric.ops2[n]=n;for(r in numeric.ops2)if(numeric.ops2.hasOwnProperty(r)){n=numeric.ops2[r];var e,t,o="";-1!==numeric.myIndexOf.call(numeric.mathfuns2,r)?(o="var "+n+" = Math."+n+";\n",e=function(r,e,t){return r+" = "+n+"("+e+","+t+")"},t=function(r,e){return r+" = "+n+"("+r+","+e+")"}):(e=function(r,e,t){return r+" = "+e+" "+n+" "+t},t=numeric.opseq.hasOwnProperty(r+"eq")?function(r,e){return r+" "+n+"= "+e}:function(r,e){return r+" = "+r+" "+n+" "+e}),numeric[r+"VV"]=numeric.pointwise2(["x[i]","y[i]"],e("ret[i]","x[i]","y[i]"),o),numeric[r+"SV"]=numeric.pointwise2(["x","y[i]"],e("ret[i]","x","y[i]"),o),numeric[r+"VS"]=numeric.pointwise2(["x[i]","y"],e("ret[i]","x[i]","y"),o),numeric[r]=Function("var n = arguments.length, i, x = arguments[0], y;\nvar VV = numeric."+r+"VV, VS = numeric."+r+"VS, SV = numeric."+r+'SV;\nvar dim = numeric.dim;\nfor(i=1;i!==n;++i) { \n y = arguments[i];\n if(typeof x === "object") {\n if(typeof y === "object") x = numeric._biforeach2(x,y,dim(x),0,VV);\n else x = numeric._biforeach2(x,y,dim(x),0,VS);\n } else if(typeof y === "object") x = numeric._biforeach2(x,y,dim(y),0,SV);\n else '+t("x","y")+"\n}\nreturn x;\n"),numeric[n]=numeric[r],numeric[r+"eqV"]=numeric.pointwise2(["ret[i]","x[i]"],t("ret[i]","x[i]"),o),numeric[r+"eqS"]=numeric.pointwise2(["ret[i]","x"],t("ret[i]","x"),o),numeric[r+"eq"]=Function("var n = arguments.length, i, x = arguments[0], y;\nvar V = numeric."+r+"eqV, S = numeric."+r+'eqS\nvar s = numeric.dim(x);\nfor(i=1;i!==n;++i) { \n y = arguments[i];\n if(typeof y === "object") numeric._biforeach(x,y,s,0,V);\n else numeric._biforeach(x,y,s,0,S);\n}\nreturn x;\n')}for(r=0;r<numeric.mathfuns2.length;++r)n=numeric.mathfuns2[r],delete numeric.ops2[n];for(r=0;r<numeric.mathfuns.length;++r)n=numeric.mathfuns[r],numeric.ops1[n]=n;for(r in numeric.ops1)numeric.ops1.hasOwnProperty(r)&&(o="",n=numeric.ops1[r],-1!==numeric.myIndexOf.call(numeric.mathfuns,r)&&Math.hasOwnProperty(n)&&(o="var "+n+" = Math."+n+";\n"),numeric[r+"eqV"]=numeric.pointwise2(["ret[i]"],"ret[i] = "+n+"(ret[i]);",o),numeric[r+"eq"]=Function("x",'if(typeof x !== "object") return '+n+"x\nvar i;\nvar V = numeric."+r+"eqV;\nvar s = numeric.dim(x);\nnumeric._foreach(x,s,0,V);\nreturn x;\n"),numeric[r+"V"]=numeric.pointwise2(["x[i]"],"ret[i] = "+n+"(x[i]);",o),numeric[r]=Function("x",'if(typeof x !== "object") return '+n+"(x)\nvar i;\nvar V = numeric."+r+"V;\nvar s = numeric.dim(x);\nreturn numeric._foreach2(x,s,0,V);\n"));for(r=0;r<numeric.mathfuns.length;++r)n=numeric.mathfuns[r],delete numeric.ops1[n];for(r in numeric.mapreducers)numeric.mapreducers.hasOwnProperty(r)&&(n=numeric.mapreducers[r],numeric[r+"V"]=numeric.mapreduce2(n[0],n[1]),numeric[r]=Function("x","s","k",n[1]+'if(typeof x !== "object") { xi = x;\n'+n[0]+';\n return accum;\n}if(typeof s === "undefined") s = numeric.dim(x);\nif(typeof k === "undefined") k = 0;\nif(k === s.length-1) return numeric.'+r+"V(x);\nvar xi;\nvar n = x.length, i;\nfor(i=n-1;i!==-1;--i) {\n xi = arguments.callee(x[i]);\n"+n[0]+";\n}\nreturn accum;\n"))}(),numeric.truncVV=numeric.pointwise(["x[i]","y[i]"],"ret[i] = round(x[i]/y[i])*y[i];","var round = Math.round;"),numeric.truncVS=numeric.pointwise(["x[i]","y"],"ret[i] = round(x[i]/y)*y;","var round = Math.round;"),numeric.truncSV=numeric.pointwise(["x","y[i]"],"ret[i] = round(x/y[i])*y[i];","var round = Math.round;"),numeric.trunc=function(r,n){return"object"==typeof r?"object"==typeof n?numeric.truncVV(r,n):numeric.truncVS(r,n):"object"==typeof n?numeric.truncSV(r,n):Math.round(r/n)*n},numeric.inv=function(r){var n,e,t,o,i,u,a,s=numeric.dim(r),c=Math.abs,l=s[0],f=s[1],m=numeric.clone(r),h=numeric.identity(l);for(u=0;u<f;++u){var p=-1,d=-1;for(i=u;i!==l;++i)(a=c(m[i][u]))>d&&(p=i,d=a);for(e=m[p],m[p]=m[u],m[u]=e,o=h[p],h[p]=h[u],h[u]=o,r=e[u],a=u;a!==f;++a)e[a]/=r;for(a=f-1;-1!==a;--a)o[a]/=r;for(i=l-1;-1!==i;--i)if(i!==u){for(n=m[i],t=h[i],r=n[u],a=u+1;a!==f;++a)n[a]-=e[a]*r;for(a=f-1;a>0;--a)t[a]-=o[a]*r,t[--a]-=o[a]*r;0===a&&(t[0]-=o[0]*r)}}return h},numeric.det=function(r){var n=numeric.dim(r);if(2!==n.length||n[0]!==n[1])throw new Error("numeric: det() only works on square matrices");var e,t,o,i,u,a,s,c,l=n[0],f=1,m=numeric.clone(r);for(t=0;t<l-1;t++){for(o=t,e=t+1;e<l;e++)Math.abs(m[e][t])>Math.abs(m[o][t])&&(o=e);for(o!==t&&(s=m[o],m[o]=m[t],m[t]=s,f*=-1),i=m[t],e=t+1;e<l;e++){for(a=(u=m[e])[t]/i[t],o=t+1;o<l-1;o+=2)c=o+1,u[o]-=i[o]*a,u[c]-=i[c]*a;o!==l&&(u[o]-=i[o]*a)}if(0===i[t])return 0;f*=i[t]}return f*m[t][t]},numeric.transpose=function(r){var n,e,t,o,i,u=r.length,a=r[0].length,s=Array(a);for(e=0;e<a;e++)s[e]=Array(u);for(n=u-1;n>=1;n-=2){for(o=r[n],t=r[n-1],e=a-1;e>=1;--e)(i=s[e])[n]=o[e],i[n-1]=t[e],(i=s[--e])[n]=o[e],i[n-1]=t[e];0===e&&((i=s[0])[n]=o[0],i[n-1]=t[0])}if(0===n){for(t=r[0],e=a-1;e>=1;--e)s[e][0]=t[e],s[--e][0]=t[e];0===e&&(s[0][0]=t[0])}return s},numeric.negtranspose=function(r){var n,e,t,o,i,u=r.length,a=r[0].length,s=Array(a);for(e=0;e<a;e++)s[e]=Array(u);for(n=u-1;n>=1;n-=2){for(o=r[n],t=r[n-1],e=a-1;e>=1;--e)(i=s[e])[n]=-o[e],i[n-1]=-t[e],(i=s[--e])[n]=-o[e],i[n-1]=-t[e];0===e&&((i=s[0])[n]=-o[0],i[n-1]=-t[0])}if(0===n){for(t=r[0],e=a-1;e>=1;--e)s[e][0]=-t[e],s[--e][0]=-t[e];0===e&&(s[0][0]=-t[0])}return s},numeric._random=function r(n,e){var t,o,i=n[e],u=Array(i);if(e===n.length-1){for(o=Math.random,t=i-1;t>=1;t-=2)u[t]=o(),u[t-1]=o();return 0===t&&(u[0]=o()),u}for(t=i-1;t>=0;t--)u[t]=r(n,e+1);return u},numeric.random=function(r){return numeric._random(r,0)},numeric.norm2=function(r){return Math.sqrt(numeric.norm2Squared(r))},numeric.linspace=function(r,n,e){if(void 0===e&&(e=Math.max(Math.round(n-r)+1,1)),e<2)return 1===e?[r]:[];var t,o=Array(e);for(t=--e;t>=0;t--)o[t]=(t*n+(e-t)*r)/e;return o},numeric.getBlock=function(r,n,e){var t=numeric.dim(r);return function r(o,i){var u,a=n[i],s=e[i]-a,c=Array(s);if(i===t.length-1){for(u=s;u>=0;u--)c[u]=o[u+a];return c}for(u=s;u>=0;u--)c[u]=r(o[u+a],i+1);return c}(r,0)},numeric.setBlock=function(r,n,e,t){var o=numeric.dim(r);return function r(t,i,u){var a,s=n[u],c=e[u]-s;if(u===o.length-1)for(a=c;a>=0;a--)t[a+s]=i[a];for(a=c;a>=0;a--)r(t[a+s],i[a],u+1)}(r,t,0),r},numeric.getRange=function(r,n,e){var t,o,i,u,a=n.length,s=e.length,c=Array(a);for(t=a-1;-1!==t;--t)for(c[t]=Array(s),i=c[t],u=r[n[t]],o=s-1;-1!==o;--o)i[o]=u[e[o]];return c},numeric.blockMatrix=function(r){var n=numeric.dim(r);if(n.length<4)return numeric.blockMatrix([r]);var e,t,o,i,u,a=n[0],s=n[1];for(e=0,t=0,o=0;o<a;++o)e+=r[o][0].length;for(i=0;i<s;++i)t+=r[0][i][0].length;var c=Array(e);for(o=0;o<e;++o)c[o]=Array(t);var l,f,m,h,p,d=0;for(o=0;o<a;++o){for(l=t,i=s-1;-1!==i;--i)for(l-=(u=r[o][i])[0].length,m=u.length-1;-1!==m;--m)for(p=u[m],f=c[d+m],h=p.length-1;-1!==h;--h)f[l+h]=p[h];d+=r[o][0].length}return c},numeric.tensor=function(r,n){if("number"==typeof r||"number"==typeof n)return numeric.mul(r,n);var e=numeric.dim(r),t=numeric.dim(n);if(1!==e.length||1!==t.length)throw new Error("numeric: tensor product is only defined for vectors");var o,i,u,a,s=e[0],c=t[0],l=Array(s);for(i=s-1;i>=0;i--){for(o=Array(c),a=r[i],u=c-1;u>=3;--u)o[u]=a*n[u],o[--u]=a*n[u],o[--u]=a*n[u],o[--u]=a*n[u];for(;u>=0;)o[u]=a*n[u],--u;l[i]=o}return l},numeric.T=function(r,n){this.x=r,this.y=n},numeric.t=function(r,n){return new numeric.T(r,n)},numeric.Tbinop=function(r,n,e,t,o){var i;if(numeric.indexOf,"string"!=typeof o)for(i in o="",numeric)numeric.hasOwnProperty(i)&&(r.indexOf(i)>=0||n.indexOf(i)>=0||e.indexOf(i)>=0||t.indexOf(i)>=0)&&i.length>1&&(o+="var "+i+" = numeric."+i+";\n");return Function(["y"],"var x = this;\nif(!(y instanceof numeric.T)) { y = new numeric.T(y); }\n"+o+"\nif(x.y) { if(y.y) { return new numeric.T("+t+");\n }\n return new numeric.T("+e+");\n}\nif(y.y) {\n return new numeric.T("+n+");\n}\nreturn new numeric.T("+r+");\n")},numeric.T.prototype.add=numeric.Tbinop("add(x.x,y.x)","add(x.x,y.x),y.y","add(x.x,y.x),x.y","add(x.x,y.x),add(x.y,y.y)"),numeric.T.prototype.sub=numeric.Tbinop("sub(x.x,y.x)","sub(x.x,y.x),neg(y.y)","sub(x.x,y.x),x.y","sub(x.x,y.x),sub(x.y,y.y)"),numeric.T.prototype.mul=numeric.Tbinop("mul(x.x,y.x)","mul(x.x,y.x),mul(x.x,y.y)","mul(x.x,y.x),mul(x.y,y.x)","sub(mul(x.x,y.x),mul(x.y,y.y)),add(mul(x.x,y.y),mul(x.y,y.x))"),numeric.T.prototype.reciprocal=function(){var r=numeric.mul,n=numeric.div;if(this.y){var e=numeric.add(r(this.x,this.x),r(this.y,this.y));return new numeric.T(n(this.x,e),n(numeric.neg(this.y),e))}return new T(n(1,this.x))},numeric.T.prototype.div=function(r){if(r instanceof numeric.T||(r=new numeric.T(r)),r.y)return this.mul(r.reciprocal());var n=numeric.div;return this.y?new numeric.T(n(this.x,r.x),n(this.y,r.x)):new numeric.T(n(this.x,r.x))},numeric.T.prototype.dot=numeric.Tbinop("dot(x.x,y.x)","dot(x.x,y.x),dot(x.x,y.y)","dot(x.x,y.x),dot(x.y,y.x)","sub(dot(x.x,y.x),dot(x.y,y.y)),add(dot(x.x,y.y),dot(x.y,y.x))"),numeric.T.prototype.transpose=function(){var r=numeric.transpose,n=this.x,e=this.y;return e?new numeric.T(r(n),r(e)):new numeric.T(r(n))},numeric.T.prototype.transjugate=function(){var r=numeric.transpose,n=this.x,e=this.y;return e?new numeric.T(r(n),numeric.negtranspose(e)):new numeric.T(r(n))},numeric.Tunop=function(r,n,e){return"string"!=typeof e&&(e=""),Function("var x = this;\n"+e+"\nif(x.y) { "+n+";\n}\n"+r+";\n")},numeric.T.prototype.exp=numeric.Tunop("return new numeric.T(ex)","return new numeric.T(mul(cos(x.y),ex),mul(sin(x.y),ex))","var ex = numeric.exp(x.x), cos = numeric.cos, sin = numeric.sin, mul = numeric.mul;"),numeric.T.prototype.conj=numeric.Tunop("return new numeric.T(x.x);","return new numeric.T(x.x,numeric.neg(x.y));"),numeric.T.prototype.neg=numeric.Tunop("return new numeric.T(neg(x.x));","return new numeric.T(neg(x.x),neg(x.y));","var neg = numeric.neg;"),numeric.T.prototype.sin=numeric.Tunop("return new numeric.T(numeric.sin(x.x))","return x.exp().sub(x.neg().exp()).div(new numeric.T(0,2));"),numeric.T.prototype.cos=numeric.Tunop("return new numeric.T(numeric.cos(x.x))","return x.exp().add(x.neg().exp()).div(2);"),numeric.T.prototype.abs=numeric.Tunop("return new numeric.T(numeric.abs(x.x));","return new numeric.T(numeric.sqrt(numeric.add(mul(x.x,x.x),mul(x.y,x.y))));","var mul = numeric.mul;"),numeric.T.prototype.log=numeric.Tunop("return new numeric.T(numeric.log(x.x));","var theta = new numeric.T(numeric.atan2(x.y,x.x)), r = x.abs();\nreturn new numeric.T(numeric.log(r.x),theta.x);"),numeric.T.prototype.norm2=numeric.Tunop("return numeric.norm2(x.x);","var f = numeric.norm2Squared;\nreturn Math.sqrt(f(x.x)+f(x.y));"),numeric.T.prototype.inv=function(){var r=this;if(void 0===r.y)return new numeric.T(numeric.inv(r.x));var n,e,t,o,i,u,a,s,c,l,f,m,h,p,d,g,v,y,x=r.x.length,w=numeric.identity(x),b=numeric.rep([x,x],0),T=numeric.clone(r.x),_=numeric.clone(r.y);for(c=0;c<x;c++){for(m=(p=T[c][c])*p+(d=_[c][c])*d,f=c,l=c+1;l<x;l++)(h=(p=T[l][c])*p+(d=_[l][c])*d)>m&&(f=l,m=h);for(f!==c&&(y=T[c],T[c]=T[f],T[f]=y,y=_[c],_[c]=_[f],_[f]=y,y=w[c],w[c]=w[f],w[f]=y,y=b[c],b[c]=b[f],b[f]=y),n=T[c],e=_[c],i=w[c],u=b[c],p=n[c],d=e[c],l=c+1;l<x;l++)g=n[l],v=e[l],n[l]=(g*p+v*d)/m,e[l]=(v*p-g*d)/m;for(l=0;l<x;l++)g=i[l],v=u[l],i[l]=(g*p+v*d)/m,u[l]=(v*p-g*d)/m;for(l=c+1;l<x;l++){for(t=T[l],o=_[l],a=w[l],s=b[l],p=t[c],d=o[c],f=c+1;f<x;f++)g=n[f],v=e[f],t[f]-=g*p-v*d,o[f]-=v*p+g*d;for(f=0;f<x;f++)g=i[f],v=u[f],a[f]-=g*p-v*d,s[f]-=v*p+g*d}}for(c=x-1;c>0;c--)for(i=w[c],u=b[c],l=c-1;l>=0;l--)for(a=w[l],s=b[l],p=T[l][c],d=_[l][c],f=x-1;f>=0;f--)g=i[f],v=u[f],a[f]-=p*g-d*v,s[f]-=p*v+d*g;return new numeric.T(w,b)},numeric.T.prototype.get=function(r){var n,e=this.x,t=this.y,o=0,i=r.length;if(t){for(;o<i;)e=e[n=r[o]],t=t[n],o++;return new numeric.T(e,t)}for(;o<i;)e=e[n=r[o]],o++;return new numeric.T(e)},numeric.T.prototype.set=function(r,n){var e,t=this.x,o=this.y,i=0,u=r.length,a=n.x,s=n.y;if(0===u)return s?this.y=s:o&&(this.y=void 0),this.x=t,this;if(s){for(o||(o=numeric.rep(numeric.dim(t),0),this.y=o);i<u-1;)t=t[e=r[i]],o=o[e],i++;return t[e=r[i]]=a,o[e]=s,this}if(o){for(;i<u-1;)t=t[e=r[i]],o=o[e],i++;return t[e=r[i]]=a,o[e]=a instanceof Array?numeric.rep(numeric.dim(a),0):0,this}for(;i<u-1;)t=t[e=r[i]],i++;return t[e=r[i]]=a,this},numeric.T.prototype.getRows=function(r,n){var e,t,o=n-r+1,i=Array(o),u=this.x,a=this.y;for(e=r;e<=n;e++)i[e-r]=u[e];if(a){for(t=Array(o),e=r;e<=n;e++)t[e-r]=a[e];return new numeric.T(i,t)}return new numeric.T(i)},numeric.T.prototype.setRows=function(r,n,e){var t,o=this.x,i=this.y,u=e.x,a=e.y;for(t=r;t<=n;t++)o[t]=u[t-r];if(a)for(i||(i=numeric.rep(numeric.dim(o),0),this.y=i),t=r;t<=n;t++)i[t]=a[t-r];else if(i)for(t=r;t<=n;t++)i[t]=numeric.rep([u[t-r].length],0);return this},numeric.T.prototype.getRow=function(r){var n=this.x,e=this.y;return e?new numeric.T(n[r],e[r]):new numeric.T(n[r])},numeric.T.prototype.setRow=function(r,n){var e=this.x,t=this.y,o=n.x,i=n.y;return e[r]=o,i?(t||(t=numeric.rep(numeric.dim(e),0),this.y=t),t[r]=i):t&&(t=numeric.rep([o.length],0)),this},numeric.T.prototype.getBlock=function(r,n){var e=this.x,t=this.y,o=numeric.getBlock;return t?new numeric.T(o(e,r,n),o(t,r,n)):new numeric.T(o(e,r,n))},numeric.T.prototype.setBlock=function(r,n,e){e instanceof numeric.T||(e=new numeric.T(e));var t=this.x,o=this.y,i=numeric.setBlock,u=e.x,a=e.y;if(a)return o||(this.y=numeric.rep(numeric.dim(this),0),o=this.y),i(t,r,n,u),i(o,r,n,a),this;i(t,r,n,u),o&&i(o,r,n,numeric.rep(numeric.dim(u),0))},numeric.T.rep=function(r,n){var e=numeric.T;n instanceof e||(n=new e(n));var t=n.x,o=n.y,i=numeric.rep;return o?new e(i(r,t),i(r,o)):new e(i(r,t))},numeric.T.diag=function(r){r instanceof numeric.T||(r=new numeric.T(r));var n=r.x,e=r.y,t=numeric.diag;return e?new numeric.T(t(n),t(e)):new numeric.T(t(n))},numeric.T.eig=function(){if(this.y)throw new Error("eig: not implemented for complex matrices.");return numeric.eig(this.x)},numeric.T.identity=function(r){return new numeric.T(numeric.identity(r))},numeric.T.prototype.getDiag=function(){var r=numeric,n=this.x,e=this.y;return e?new r.T(r.getDiag(n),r.getDiag(e)):new r.T(r.getDiag(n))},numeric.house=function(r){var n=numeric.clone(r),e=(r[0]>=0?1:-1)*numeric.norm2(r);n[0]+=e;var t=numeric.norm2(n);if(0===t)throw new Error("eig: internal error");return numeric.div(n,t)},numeric.toUpperHessenberg=function(r){var n=numeric.dim(r);if(2!==n.length||n[0]!==n[1])throw new Error("numeric: toUpperHessenberg() only works on square matrices");var e,t,o,i,u,a,s,c,l,f,m=n[0],h=numeric.clone(r),p=numeric.identity(m);for(t=0;t<m-2;t++){for(i=Array(m-t-1),e=t+1;e<m;e++)i[e-t-1]=h[e][t];if(numeric.norm2(i)>0){for(u=numeric.house(i),a=numeric.getBlock(h,[t+1,t],[m-1,m-1]),s=numeric.tensor(u,numeric.dot(u,a)),e=t+1;e<m;e++)for(c=h[e],l=s[e-t-1],o=t;o<m;o++)c[o]-=2*l[o-t];for(a=numeric.getBlock(h,[0,t+1],[m-1,m-1]),s=numeric.tensor(numeric.dot(a,u),u),e=0;e<m;e++)for(c=h[e],l=s[e],o=t+1;o<m;o++)c[o]-=2*l[o-t-1];for(a=Array(m-t-1),e=t+1;e<m;e++)a[e-t-1]=p[e];for(s=numeric.tensor(u,numeric.dot(u,a)),e=t+1;e<m;e++)for(f=p[e],l=s[e-t-1],o=0;o<m;o++)f[o]-=2*l[o]}}return{H:h,Q:p}},numeric.epsilon=2220446049250313e-31,numeric.QRFrancis=function(r,n){void 0===n&&(n=1e4),r=numeric.clone(r),numeric.clone(r);var e,t,o,i,u,a,s,c,l,f,m,h,p,d,g,v,y,x,w=numeric.dim(r)[0],b=numeric.identity(w);if(w<3)return{Q:b,B:[[0,w-1]]};var T=numeric.epsilon;for(x=0;x<n;x++){for(v=0;v<w-1;v++)if(Math.abs(r[v+1][v])<T*(Math.abs(r[v][v])+Math.abs(r[v+1][v+1]))){var _=numeric.QRFrancis(numeric.getBlock(r,[0,0],[v,v]),n),M=numeric.QRFrancis(numeric.getBlock(r,[v+1,v+1],[w-1,w-1]),n);for(h=Array(v+1),g=0;g<=v;g++)h[g]=b[g];for(p=numeric.dot(_.Q,h),g=0;g<=v;g++)b[g]=p[g];for(h=Array(w-v-1),g=v+1;g<w;g++)h[g-v-1]=b[g];for(p=numeric.dot(M.Q,h),g=v+1;g<w;g++)b[g]=p[g-v-1];return{Q:b,B:_.B.concat(numeric.add(M.B,v+1))}}var A,C,S;for(o=r[w-2][w-2],i=r[w-2][w-1],u=r[w-1][w-2],c=o+(a=r[w-1][w-1]),s=o*a-i*u,l=numeric.getBlock(r,[0,0],[2,2]),c*c>=4*s?(A=.5*(c+Math.sqrt(c*c-4*s)),C=.5*(c-Math.sqrt(c*c-4*s)),l=numeric.add(numeric.sub(numeric.dot(l,l),numeric.mul(l,A+C)),numeric.diag(numeric.rep([3],A*C)))):l=numeric.add(numeric.sub(numeric.dot(l,l),numeric.mul(l,c)),numeric.diag(numeric.rep([3],s))),e=[l[0][0],l[1][0],l[2][0]],t=numeric.house(e),h=[r[0],r[1],r[2]],p=numeric.tensor(t,numeric.dot(t,h)),g=0;g<3;g++)for(m=r[g],d=p[g],y=0;y<w;y++)m[y]-=2*d[y];for(h=numeric.getBlock(r,[0,0],[w-1,2]),p=numeric.tensor(numeric.dot(h,t),t),g=0;g<w;g++)for(m=r[g],d=p[g],y=0;y<3;y++)m[y]-=2*d[y];for(h=[b[0],b[1],b[2]],p=numeric.tensor(t,numeric.dot(t,h)),g=0;g<3;g++)for(f=b[g],d=p[g],y=0;y<w;y++)f[y]-=2*d[y];for(v=0;v<w-2;v++){for(y=v;y<=v+1;y++)if(Math.abs(r[y+1][y])<T*(Math.abs(r[y][y])+Math.abs(r[y+1][y+1]))){for(_=numeric.QRFrancis(numeric.getBlock(r,[0,0],[y,y]),n),M=numeric.QRFrancis(numeric.getBlock(r,[y+1,y+1],[w-1,w-1]),n),h=Array(y+1),g=0;g<=y;g++)h[g]=b[g];for(p=numeric.dot(_.Q,h),g=0;g<=y;g++)b[g]=p[g];for(h=Array(w-y-1),g=y+1;g<w;g++)h[g-y-1]=b[g];for(p=numeric.dot(M.Q,h),g=y+1;g<w;g++)b[g]=p[g-y-1];return{Q:b,B:_.B.concat(numeric.add(M.B,y+1))}}for(S=Math.min(w-1,v+3),e=Array(S-v),g=v+1;g<=S;g++)e[g-v-1]=r[g][v];for(t=numeric.house(e),h=numeric.getBlock(r,[v+1,v],[S,w-1]),p=numeric.tensor(t,numeric.dot(t,h)),g=v+1;g<=S;g++)for(m=r[g],d=p[g-v-1],y=v;y<w;y++)m[y]-=2*d[y-v];for(h=numeric.getBlock(r,[0,v+1],[w-1,S]),p=numeric.tensor(numeric.dot(h,t),t),g=0;g<w;g++)for(m=r[g],d=p[g],y=v+1;y<=S;y++)m[y]-=2*d[y-v-1];for(h=Array(S-v),g=v+1;g<=S;g++)h[g-v-1]=b[g];for(p=numeric.tensor(t,numeric.dot(t,h)),g=v+1;g<=S;g++)for(f=b[g],d=p[g-v-1],y=0;y<w;y++)f[y]-=2*d[y]}}throw new Error("numeric: eigenvalue iteration does not converge -- increase maxiter?")},numeric.eig=function(r,n){var e,t,o,i,u,a,s,c,l,f,m,h,p,d,g,v,y=numeric.toUpperHessenberg(r),x=numeric.QRFrancis(y.H,n),w=numeric.T,b=r.length,T=x.B,_=numeric.dot(x.Q,numeric.dot(y.H,numeric.transpose(x.Q))),M=new w(numeric.dot(x.Q,y.Q)),A=T.length,C=Math.sqrt;for(t=0;t<A;t++)if((e=T[t][0])!==T[t][1]){if(i=e+1,u=_[e][e],a=_[e][i],s=_[i][e],c=_[i][i],0===a&&0===s)continue;(f=(l=-u-c)*l-4*(u*c-a*s))>=0?((g=(u-(m=l<0?-.5*(l-C(f)):-.5*(l+C(f))))*(u-m)+a*a)>(v=s*s+(c-m)*(c-m))?(p=(u-m)/(g=C(g)),d=a/g):(p=s/(v=C(v)),d=(c-m)/v),o=new w([[d,-p],[p,d]]),M.setRows(e,i,o.dot(M.getRows(e,i)))):(m=-.5*l,h=.5*C(-f),(g=(u-m)*(u-m)+a*a)>(v=s*s+(c-m)*(c-m))?(p=(u-m)/(g=C(g+h*h)),d=a/g,m=0,h/=g):(p=s/(v=C(v+h*h)),d=(c-m)/v,m=h/v,h=0),o=new w([[d,-p],[p,d]],[[m,h],[h,-m]]),M.setRows(e,i,o.dot(M.getRows(e,i))))}var S=M.dot(r).dot(M.transjugate()),k=(b=r.length,numeric.T.identity(b));for(i=0;i<b;i++)if(i>0)for(t=i-1;t>=0;t--){var O=S.get([t,t]),P=S.get([i,i]);numeric.neq(O.x,P.x)||numeric.neq(O.y,P.y)?(m=S.getRow(t).getBlock([t],[i-1]),h=k.getRow(i).getBlock([t],[i-1]),k.set([i,t],S.get([t,i]).neg().sub(m.dot(h)).div(O.sub(P)))):k.setRow(i,k.getRow(t))}for(i=0;i<b;i++)m=k.getRow(i),k.setRow(i,m.div(m.norm2()));return k=k.transpose(),k=M.transjugate().dot(k),{lambda:S.getDiag(),E:k}},numeric.ccsSparse=function(r){var n,e,t,o=r.length,i=[];for(e=o-1;-1!==e;--e)for(t in n=r[e]){for(t=parseInt(t);t>=i.length;)i[i.length]=0;0!==n[t]&&i[t]++}var u=i.length,a=Array(u+1);for(a[0]=0,e=0;e<u;++e)a[e+1]=a[e]+i[e];var s=Array(a[u]),c=Array(a[u]);for(e=o-1;-1!==e;--e)for(t in n=r[e])0!==n[t]&&(i[t]--,s[a[t]+i[t]]=e,c[a[t]+i[t]]=n[t]);return[a,s,c]},numeric.ccsFull=function(r){var n,e,t,o,i=r[0],u=r[1],a=r[2],s=numeric.ccsDim(r),c=s[0],l=s[1],f=numeric.rep([c,l],0);for(n=0;n<l;n++)for(t=i[n],o=i[n+1],e=t;e<o;++e)f[u[e]][n]=a[e];return f},numeric.ccsTSolve=function(r,n,e,t,o){function i(r){var n;if(0===e[r]){for(e[r]=1,n=h[r];n<h[r+1];++n)i(p[n]);o[y]=r,++y}}var u,a,s,c,l,f,m,h=r[0],p=r[1],d=r[2],g=h.length-1,v=Math.max,y=0;for(void 0===t&&(e=numeric.rep([g],0)),void 0===t&&(t=numeric.linspace(0,e.length-1)),void 0===o&&(o=[]),u=t.length-1;-1!==u;--u)i(t[u]);for(o.length=y,u=o.length-1;-1!==u;--u)e[o[u]]=0;for(u=t.length-1;-1!==u;--u)a=t[u],e[a]=n[a];for(u=o.length-1;-1!==u;--u){for(a=o[u],s=h[a],c=v(h[a+1],s),l=s;l!==c;++l)if(p[l]===a){e[a]/=d[l];break}for(m=e[a],l=s;l!==c;++l)(f=p[l])!==a&&(e[f]-=m*d[l])}return e},numeric.ccsDFS=function(r){this.k=Array(r),this.k1=Array(r),this.j=Array(r)},numeric.ccsDFS.prototype.dfs=function(r,n,e,t,o,i){var u,a,s,c=0,l=o.length,f=this.k,m=this.k1,h=this.j;if(0===t[r])for(t[r]=1,h[0]=r,f[0]=a=n[r],m[0]=s=n[r+1];;)if(a>=s){if(o[l]=h[c],0===c)return;++l,a=f[--c],s=m[c]}else 0===t[u=i[e[a]]]?(t[u]=1,f[c]=a,h[++c]=u,a=n[u],m[c]=s=n[u+1]):++a},numeric.ccsLPSolve=function(r,n,e,t,o,i,u){var a,s,c,l,f,m,h,p,d,g=r[0],v=r[1],y=r[2],x=(g.length,n[0]),w=n[1],b=n[2];for(s=x[o],c=x[o+1],t.length=0,a=s;a<c;++a)u.dfs(i[w[a]],g,v,e,t,i);for(a=t.length-1;-1!==a;--a)e[t[a]]=0;for(a=s;a!==c;++a)e[l=i[w[a]]]=b[a];for(a=t.length-1;-1!==a;--a){for(f=g[l=t[a]],m=g[l+1],h=f;h<m;++h)if(i[v[h]]===l){e[l]/=y[h];break}for(d=e[l],h=f;h<m;++h)(p=i[v[h]])!==l&&(e[p]-=d*y[h])}return e},numeric.ccsLUP1=function(r,n){var e,t,o,i,u,a,s,c=r[0].length-1,l=[numeric.rep([c+1],0),[],[]],f=[numeric.rep([c+1],0),[],[]],m=l[0],h=l[1],p=l[2],d=f[0],g=f[1],v=f[2],y=numeric.rep([c],0),x=numeric.rep([c],0),w=numeric.ccsLPSolve,b=(Math.max,Math.abs),T=numeric.linspace(0,c-1),_=numeric.linspace(0,c-1),M=new numeric.ccsDFS(c);for(void 0===n&&(n=1),e=0;e<c;++e){for(w(l,r,y,x,e,_,M),i=-1,u=-1,t=x.length-1;-1!==t;--t)(o=x[t])<=e||(a=b(y[o]))>i&&(u=o,i=a);for(b(y[e])<n*i&&(t=T[e],i=T[u],T[e]=i,_[i]=e,T[u]=t,_[t]=u,i=y[e],y[e]=y[u],y[u]=i),i=m[e],u=d[e],s=y[e],h[i]=T[e],p[i]=1,++i,t=x.length-1;-1!==t;--t)a=y[o=x[t]],x[t]=0,y[o]=0,o<=e?(g[u]=o,v[u]=a,++u):(h[i]=T[o],p[i]=a/s,++i);m[e+1]=i,d[e+1]=u}for(t=h.length-1;-1!==t;--t)h[t]=_[h[t]];return{L:l,U:f,P:T,Pinv:_}},numeric.ccsDFS0=function(r){this.k=Array(r),this.k1=Array(r),this.j=Array(r)},numeric.ccsDFS0.prototype.dfs=function(r,n,e,t,o,i,u){var a,s,c,l=0,f=o.length,m=this.k,h=this.k1,p=this.j;if(0===t[r])for(t[r]=1,p[0]=r,m[0]=s=n[i[r]],h[0]=c=n[i[r]+1];;){if(isNaN(s))throw new Error("Ow!");if(s>=c){if(o[f]=i[p[l]],0===l)return;++f,s=m[--l],c=h[l]}else 0===t[a=e[s]]?(t[a]=1,m[l]=s,p[++l]=a,s=n[a=i[a]],h[l]=c=n[a+1]):++s}},numeric.ccsLPSolve0=function(r,n,e,t,o,i,u,a){var s,c,l,f,m,h,p,d,g,v=r[0],y=r[1],x=r[2],w=(v.length,n[0]),b=n[1],T=n[2];for(c=w[o],l=w[o+1],t.length=0,s=c;s<l;++s)a.dfs(b[s],v,y,e,t,i,u);for(s=t.length-1;-1!==s;--s)e[u[f=t[s]]]=0;for(s=c;s!==l;++s)e[f=b[s]]=T[s];for(s=t.length-1;-1!==s;--s){for(d=u[f=t[s]],m=v[f],h=v[f+1],p=m;p<h;++p)if(y[p]===d){e[d]/=x[p];break}for(g=e[d],p=m;p<h;++p)e[y[p]]-=g*x[p];e[d]=g}},numeric.ccsLUP0=function(r,n){var e,t,o,i,u,a,s,c=r[0].length-1,l=[numeric.rep([c+1],0),[],[]],f=[numeric.rep([c+1],0),[],[]],m=l[0],h=l[1],p=l[2],d=f[0],g=f[1],v=f[2],y=numeric.rep([c],0),x=numeric.rep([c],0),w=numeric.ccsLPSolve0,b=(Math.max,Math.abs),T=numeric.linspace(0,c-1),_=numeric.linspace(0,c-1),M=new numeric.ccsDFS0(c);for(void 0===n&&(n=1),e=0;e<c;++e){for(w(l,r,y,x,e,_,T,M),i=-1,u=-1,t=x.length-1;-1!==t;--t)(o=x[t])<=e||(a=b(y[T[o]]))>i&&(u=o,i=a);for(b(y[T[e]])<n*i&&(t=T[e],i=T[u],T[e]=i,_[i]=e,T[u]=t,_[t]=u),i=m[e],u=d[e],s=y[T[e]],h[i]=T[e],p[i]=1,++i,t=x.length-1;-1!==t;--t)a=y[T[o=x[t]]],x[t]=0,y[T[o]]=0,o<=e?(g[u]=o,v[u]=a,++u):(h[i]=T[o],p[i]=a/s,++i);m[e+1]=i,d[e+1]=u}for(t=h.length-1;-1!==t;--t)h[t]=_[h[t]];return{L:l,U:f,P:T,Pinv:_}},numeric.ccsLUP=numeric.ccsLUP0,numeric.ccsDim=function(r){return[numeric.sup(r[1])+1,r[0].length-1]},numeric.ccsGetBlock=function(r,n,e){var t=numeric.ccsDim(r),o=t[0],i=t[1];void 0===n?n=numeric.linspace(0,o-1):"number"==typeof n&&(n=[n]),void 0===e?e=numeric.linspace(0,i-1):"number"==typeof e&&(e=[e]);var u,a,s,c,l=n.length,f=e.length,m=numeric.rep([i],0),h=[],p=[],d=[m,h,p],g=r[0],v=r[1],y=r[2],x=numeric.rep([o],0),w=0,b=numeric.rep([o],0);for(a=0;a<f;++a){var T=g[c=e[a]],_=g[c+1];for(u=T;u<_;++u)b[s=v[u]]=1,x[s]=y[u];for(u=0;u<l;++u)b[n[u]]&&(h[w]=u,p[w]=x[n[u]],++w);for(u=T;u<_;++u)b[s=v[u]]=0;m[a+1]=w}return d},numeric.ccsDot=function(r,n){var e,t,o,i,u,a,s,c,l,f,m,h=r[0],p=r[1],d=r[2],g=n[0],v=n[1],y=n[2],x=numeric.ccsDim(r),w=numeric.ccsDim(n),b=x[0],T=(x[1],w[1]),_=numeric.rep([b],0),M=numeric.rep([b],0),A=Array(b),C=numeric.rep([T],0),S=[],k=[],O=[C,S,k];for(o=0;o!==T;++o){for(i=g[o],u=g[o+1],l=0,t=i;t<u;++t)for(f=v[t],m=y[t],a=h[f],s=h[f+1],e=a;e<s;++e)0===M[c=p[e]]&&(A[l]=c,M[c]=1,l+=1),_[c]=_[c]+d[e]*m;for(u=(i=C[o])+l,C[o+1]=u,t=l-1;-1!==t;--t)m=i+t,e=A[t],S[m]=e,k[m]=_[e],M[e]=0,_[e]=0;C[o+1]=C[o]+l}return O},numeric.ccsLUPSolve=function(r,n){var e=r.L,t=r.U,o=(r.P,n[0]),i=!1;"object"!=typeof o&&(o=(n=[[0,n.length],numeric.linspace(0,n.length-1),n])[0],i=!0);var u,a,s,c,l,f,m=n[1],h=n[2],p=e[0].length-1,d=o.length-1,g=numeric.rep([p],0),v=Array(p),y=numeric.rep([p],0),x=Array(p),w=numeric.rep([d+1],0),b=[],T=[],_=numeric.ccsTSolve,M=0;for(u=0;u<d;++u){for(l=0,s=o[u],c=o[u+1],a=s;a<c;++a)f=r.Pinv[m[a]],x[l]=f,y[f]=h[a],++l;for(x.length=l,_(e,y,g,x,v),a=x.length-1;-1!==a;--a)y[x[a]]=0;if(_(t,g,y,v,x),i)return y;for(a=v.length-1;-1!==a;--a)g[v[a]]=0;for(a=x.length-1;-1!==a;--a)f=x[a],b[M]=f,T[M]=y[f],y[f]=0,++M;w[u+1]=M}return[w,b,T]},numeric.ccsbinop=function(r,n){return void 0===n&&(n=""),Function("X","Y","var Xi = X[0], Xj = X[1], Xv = X[2];\nvar Yi = Y[0], Yj = Y[1], Yv = Y[2];\nvar n = Xi.length-1,m = Math.max(numeric.sup(Xj),numeric.sup(Yj))+1;\nvar Zi = numeric.rep([n+1],0), Zj = [], Zv = [];\nvar x = numeric.rep([m],0),y = numeric.rep([m],0);\nvar xk,yk,zk;\nvar i,j,j0,j1,k,p=0;\n"+n+"for(i=0;i<n;++i) {\n j0 = Xi[i]; j1 = Xi[i+1];\n for(j=j0;j!==j1;++j) {\n k = Xj[j];\n x[k] = 1;\n Zj[p] = k;\n ++p;\n }\n j0 = Yi[i]; j1 = Yi[i+1];\n for(j=j0;j!==j1;++j) {\n k = Yj[j];\n y[k] = Yv[j];\n if(x[k] === 0) {\n Zj[p] = k;\n ++p;\n }\n }\n Zi[i+1] = p;\n j0 = Xi[i]; j1 = Xi[i+1];\n for(j=j0;j!==j1;++j) x[Xj[j]] = Xv[j];\n j0 = Zi[i]; j1 = Zi[i+1];\n for(j=j0;j!==j1;++j) {\n k = Zj[j];\n xk = x[k];\n yk = y[k];\n"+r+"\n Zv[j] = zk;\n }\n j0 = Xi[i]; j1 = Xi[i+1];\n for(j=j0;j!==j1;++j) x[Xj[j]] = 0;\n j0 = Yi[i]; j1 = Yi[i+1];\n for(j=j0;j!==j1;++j) y[Yj[j]] = 0;\n}\nreturn [Zi,Zj,Zv];")},function(){var k,A,B,C;for(k in numeric.ops2)A=isFinite(eval("1"+numeric.ops2[k]+"0"))?"[Y[0],Y[1],numeric."+k+"(X,Y[2])]":"NaN",B=isFinite(eval("0"+numeric.ops2[k]+"1"))?"[X[0],X[1],numeric."+k+"(X[2],Y)]":"NaN",C=isFinite(eval("1"+numeric.ops2[k]+"0"))&&isFinite(eval("0"+numeric.ops2[k]+"1"))?"numeric.ccs"+k+"MM(X,Y)":"NaN",numeric["ccs"+k+"MM"]=numeric.ccsbinop("zk = xk "+numeric.ops2[k]+"yk;"),numeric["ccs"+k]=Function("X","Y",'if(typeof X === "number") return '+A+';\nif(typeof Y === "number") return '+B+";\nreturn "+C+";\n")}(),numeric.ccsScatter=function(r){var n,e=r[0],t=r[1],o=r[2],i=numeric.sup(t)+1,u=e.length,a=numeric.rep([i],0),s=Array(u),c=Array(u),l=numeric.rep([i],0);for(n=0;n<u;++n)l[t[n]]++;for(n=0;n<i;++n)a[n+1]=a[n]+l[n];var f,m,h=a.slice(0);for(n=0;n<u;++n)s[f=h[m=t[n]]]=e[n],c[f]=o[n],h[m]=h[m]+1;return[a,s,c]},numeric.ccsGather=function(r){var n,e,t,o,i,u=r[0],a=r[1],s=r[2],c=u.length-1,l=a.length,f=Array(l),m=Array(l),h=Array(l);for(i=0,n=0;n<c;++n)for(t=u[n],o=u[n+1],e=t;e!==o;++e)m[i]=n,f[i]=a[e],h[i]=s[e],++i;return[f,m,h]},numeric.sdim=function r(n,e,t){if(void 0===e&&(e=[]),"object"!=typeof n)return e;var o;for(o in void 0===t&&(t=0),t in e||(e[t]=0),n.length>e[t]&&(e[t]=n.length),n)n.hasOwnProperty(o)&&r(n[o],e,t+1);return e},numeric.sclone=function r(n,e,t){void 0===e&&(e=0),void 0===t&&(t=numeric.sdim(n).length);var o,i=Array(n.length);if(e===t-1){for(o in n)n.hasOwnProperty(o)&&(i[o]=n[o]);return i}for(o in n)n.hasOwnProperty(o)&&(i[o]=r(n[o],e+1,t));return i},numeric.sdiag=function(r){var n,e,t=r.length,o=Array(t);for(n=t-1;n>=1;n-=2)e=n-1,o[n]=[],o[n][n]=r[n],o[e]=[],o[e][e]=r[e];return 0===n&&(o[0]=[],o[0][0]=r[n]),o},numeric.sidentity=function(r){return numeric.sdiag(numeric.rep([r],1))},numeric.stranspose=function(r){var n,e,t,o=[];for(n in r.length,r)if(r.hasOwnProperty(n))for(e in t=r[n])t.hasOwnProperty(e)&&("object"!=typeof o[e]&&(o[e]=[]),o[e][n]=t[e]);return o},numeric.sLUP=function(r,n){throw new Error("The function numeric.sLUP had a bug in it and has been removed. Please use the new numeric.ccsLUP function instead.")},numeric.sdotMM=function(r,n){var e,t,o,i,u,a,s,c=r.length,l=(n.length,numeric.stranspose(n)),f=l.length,m=Array(c);for(o=c-1;o>=0;o--){for(s=[],e=r[o],u=f-1;u>=0;u--){for(i in a=0,t=l[u],e)e.hasOwnProperty(i)&&i in t&&(a+=e[i]*t[i]);a&&(s[u]=a)}m[o]=s}return m},numeric.sdotMV=function(r,n){var e,t,o,i,u=r.length,a=Array(u);for(t=u-1;t>=0;t--){for(o in i=0,e=r[t])e.hasOwnProperty(o)&&n[o]&&(i+=e[o]*n[o]);i&&(a[t]=i)}return a},numeric.sdotVM=function(r,n){var e,t,o,i,u=[];for(e in r)if(r.hasOwnProperty(e))for(t in o=n[e],i=r[e],o)o.hasOwnProperty(t)&&(u[t]||(u[t]=0),u[t]+=i*o[t]);return u},numeric.sdotVV=function(r,n){var e,t=0;for(e in r)r[e]&&n[e]&&(t+=r[e]*n[e]);return t},numeric.sdot=function(r,n){var e=numeric.sdim(r).length,t=numeric.sdim(n).length;switch(1e3*e+t){case 0:return r*n;case 1001:return numeric.sdotVV(r,n);case 2001:return numeric.sdotMV(r,n);case 1002:return numeric.sdotVM(r,n);case 2002:return numeric.sdotMM(r,n);default:throw new Error("numeric.sdot not implemented for tensors of order "+e+" and "+t)}},numeric.sscatter=function(r){var n,e,t,o,i=r[0].length,u=r.length,a=[];for(e=i-1;e>=0;--e)if(r[u-1][e]){for(o=a,t=0;t<u-2;t++)o[n=r[t][e]]||(o[n]=[]),o=o[n];o[r[t][e]]=r[t+1][e]}return a},numeric.sgather=function r(n,e,t){var o,i,u;for(i in void 0===e&&(e=[]),void 0===t&&(t=[]),o=t.length,n)if(n.hasOwnProperty(i))if(t[o]=parseInt(i),"number"==typeof(u=n[i])){if(u){if(0===e.length)for(i=o+1;i>=0;--i)e[i]=[];for(i=o;i>=0;--i)e[i].push(t[i]);e[o+1].push(u)}}else r(u,e,t);return t.length>o&&t.pop(),e},numeric.cLU=function(r){var n,e,t,o,i,u,a=r[0],s=r[1],c=r[2],l=a.length,f=0;for(n=0;n<l;n++)a[n]>f&&(f=a[n]);f++;var m,h=Array(f),p=Array(f),d=numeric.rep([f],1/0),g=numeric.rep([f],-1/0);for(t=0;t<l;t++)n=a[t],(e=s[t])<d[n]&&(d[n]=e),e>g[n]&&(g[n]=e);for(n=0;n<f-1;n++)g[n]>g[n+1]&&(g[n+1]=g[n]);for(n=f-1;n>=1;n--)d[n]<d[n-1]&&(d[n-1]=d[n]);for(n=0;n<f;n++)p[n]=numeric.rep([g[n]-d[n]+1],0),h[n]=numeric.rep([n-d[n]],0),d[n],g[n];for(t=0;t<l;t++)p[n=a[t]][s[t]-d[n]]=c[t];for(n=0;n<f-1;n++)for(o=n-d[n],x=p[n],e=n+1;d[e]<=n&&e<f;e++)if(i=n-d[e],u=g[n]-n,m=(w=p[e])[i]/x[o]){for(t=1;t<=u;t++)w[t+i]-=m*x[t+o];h[e][n-d[e]]=m}var v,y,x=[],w=[],b=[],T=[],_=[],M=[];for(l=0,v=0,n=0;n<f;n++){for(o=d[n],i=g[n],y=p[n],e=n;e<=i;e++)y[e-o]&&(x[l]=n,w[l]=e,b[l]=y[e-o],l++);for(y=h[n],e=o;e<n;e++)y[e-o]&&(T[v]=n,_[v]=e,M[v]=y[e-o],v++);T[v]=n,_[v]=n,M[v]=1,v++}return{U:[x,w,b],L:[T,_,M]}},numeric.cLUsolve=function(r,n){var e,t,o=r.L,i=r.U,u=numeric.clone(n),a=o[0],s=o[1],c=o[2],l=i[0],f=i[1],m=i[2],h=l.length,p=(a.length,u.length);for(t=0,e=0;e<p;e++){for(;s[t]<e;)u[e]-=c[t]*u[s[t]],t++;t++}for(t=h-1,e=p-1;e>=0;e--){for(;f[t]>e;)u[e]-=m[t]*u[f[t]],t--;u[e]/=m[t],t--}return u},numeric.cgrid=function(r,n){"number"==typeof r&&(r=[r,r]);var e,t,o,i=numeric.rep(r,-1);for("function"!=typeof n&&(n="L"===n?function(n,e){return n>=r[0]/2||e<r[1]/2}:function(r,n){return!0}),o=0,e=1;e<r[0]-1;e++)for(t=1;t<r[1]-1;t++)n(e,t)&&(i[e][t]=o,o++);return i},numeric.cdelsq=function(r){var n,e,t,o,i,u=[[-1,0],[0,-1],[0,1],[1,0]],a=numeric.dim(r),s=a[0],c=a[1],l=[],f=[],m=[];for(n=1;n<s-1;n++)for(e=1;e<c-1;e++)if(!(r[n][e]<0)){for(t=0;t<4;t++)o=n+u[t][0],i=e+u[t][1],r[o][i]<0||(l.push(r[n][e]),f.push(r[o][i]),m.push(-1));l.push(r[n][e]),f.push(r[n][e]),m.push(4)}return[l,f,m]},numeric.cdotMV=function(r,n){var e,t,o,i=r[0],u=r[1],a=r[2],s=i.length;for(o=0,t=0;t<s;t++)i[t]>o&&(o=i[t]);for(o++,e=numeric.rep([o],0),t=0;t<s;t++)e[i[t]]+=a[t]*n[u[t]];return e},numeric.Spline=function(r,n,e,t,o){this.x=r,this.yl=n,this.yr=e,this.kl=t,this.kr=o},numeric.Spline.prototype._at=function(r,n){var e,t,o,i=this.x,u=this.yl,a=this.yr,s=this.kl,c=this.kr,l=numeric.add,f=numeric.sub,m=numeric.mul;e=f(m(s[n],i[n+1]-i[n]),f(a[n+1],u[n])),t=l(m(c[n+1],i[n]-i[n+1]),f(a[n+1],u[n]));var h=(o=(r-i[n])/(i[n+1]-i[n]))*(1-o);return l(l(l(m(1-o,u[n]),m(o,a[n+1])),m(e,h*(1-o))),m(t,h*o))},numeric.Spline.prototype.at=function(r){if("number"==typeof r){var n,e,t,o=this.x,i=o.length,u=Math.floor;for(n=0,e=i-1;e-n>1;)o[t=u((n+e)/2)]<=r?n=t:e=t;return this._at(r,n)}i=r.length;var a,s=Array(i);for(a=i-1;-1!==a;--a)s[a]=this.at(r[a]);return s},numeric.Spline.prototype.diff=function(){var r,n,e,t=this.x,o=this.yl,i=this.yr,u=this.kl,a=this.kr,s=o.length,c=u,l=a,f=Array(s),m=Array(s),h=numeric.add,p=numeric.mul,d=numeric.div,g=numeric.sub;for(r=s-1;-1!==r;--r)n=t[r+1]-t[r],e=g(i[r+1],o[r]),f[r]=d(h(p(e,6),p(u[r],-4*n),p(a[r+1],-2*n)),n*n),m[r+1]=d(h(p(e,-6),p(u[r],2*n),p(a[r+1],4*n)),n*n);return new numeric.Spline(t,c,l,f,m)},numeric.Spline.prototype.roots=function(){var r=[],n=this.x,e=this.yl,t=this.yr,o=this.kl,i=this.kr;"number"==typeof e[0]&&(e=[e],t=[t],o=[o],i=[i]);var u,a,s,c,l,f,m,h,p,d,g,v,y,x,w,b,T,_,M,A,C,S,k,O,P=e.length,N=n.length-1,j=(r=Array(P),Math.sqrt);for(u=0;u!==P;++u){for(c=e[u],l=t[u],f=o[u],m=i[u],h=[],a=0;a!==N;a++){for(a>0&&l[a]*c[a]<0&&h.push(n[a]),b=n[a+1]-n[a],n[a],g=c[a],v=l[a+1],p=f[a]/b,y=(d=m[a+1]/b)+3*g+2*p-3*v,x=3*(d+p+2*(g-v)),(w=(O=p-d+3*(g-v))*O+12*d*g)<=0?T=(_=y/x)>n[a]&&_<n[a+1]?[n[a],_,n[a+1]]:[n[a],n[a+1]]:(_=(y-j(w))/x,M=(y+j(w))/x,T=[n[a]],_>n[a]&&_<n[a+1]&&T.push(_),M>n[a]&&M<n[a+1]&&T.push(M),T.push(n[a+1])),C=T[0],_=this._at(C,a),s=0;s<T.length-1;s++)if(S=T[s+1],M=this._at(S,a),0!==_)if(0===M||_*M>0)C=S,_=M;else{for(var q=0;!((k=(_*S-M*C)/(_-M))<=C||k>=S);)if((A=this._at(k,a))*M>0)S=k,M=A,-1===q&&(_*=.5),q=-1;else{if(!(A*_>0))break;C=k,_=A,1===q&&(M*=.5),q=1}h.push(k),C=T[s+1],_=this._at(C,a)}else h.push(C),C=S,_=M;0===M&&h.push(S)}r[u]=h}return"number"==typeof this.yl[0]?r[0]:r},numeric.spline=function(r,n,e,t){var o,i=r.length,u=[],a=[],s=[],c=numeric.sub,l=numeric.mul,f=numeric.add;for(o=i-2;o>=0;o--)a[o]=r[o+1]-r[o],s[o]=c(n[o+1],n[o]);"string"!=typeof e&&"string"!=typeof t||(e=t="periodic");var m=[[],[],[]];switch(typeof e){case"undefined":u[0]=l(3/(a[0]*a[0]),s[0]),m[0].push(0,0),m[1].push(0,1),m[2].push(2/a[0],1/a[0]);break;case"string":u[0]=f(l(3/(a[i-2]*a[i-2]),s[i-2]),l(3/(a[0]*a[0]),s[0])),m[0].push(0,0,0),m[1].push(i-2,0,1),m[2].push(1/a[i-2],2/a[i-2]+2/a[0],1/a[0]);break;default:u[0]=e,m[0].push(0),m[1].push(0),m[2].push(1)}for(o=1;o<i-1;o++)u[o]=f(l(3/(a[o-1]*a[o-1]),s[o-1]),l(3/(a[o]*a[o]),s[o])),m[0].push(o,o,o),m[1].push(o-1,o,o+1),m[2].push(1/a[o-1],2/a[o-1]+2/a[o],1/a[o]);switch(typeof t){case"undefined":u[i-1]=l(3/(a[i-2]*a[i-2]),s[i-2]),m[0].push(i-1,i-1),m[1].push(i-2,i-1),m[2].push(1/a[i-2],2/a[i-2]);break;case"string":m[1][m[1].length-1]=0;break;default:u[i-1]=t,m[0].push(i-1),m[1].push(i-1),m[2].push(1)}u="number"!=typeof u[0]?numeric.transpose(u):[u];var h=Array(u.length);if("string"==typeof e)for(o=h.length-1;-1!==o;--o)h[o]=numeric.ccsLUPSolve(numeric.ccsLUP(numeric.ccsScatter(m)),u[o]),h[o][i-1]=h[o][0];else for(o=h.length-1;-1!==o;--o)h[o]=numeric.cLUsolve(numeric.cLU(m),u[o]);return h="number"==typeof n[0]?h[0]:numeric.transpose(h),new numeric.Spline(r,n,n,h,h)},numeric.fftpow2=function r(n,e){var t=n.length;if(1!==t){var o,i,u=Math.cos,a=Math.sin,s=Array(t/2),c=Array(t/2),l=Array(t/2),f=Array(t/2);for(i=t/2,o=t-1;-1!==o;--o)l[--i]=n[o],f[i]=e[o],--o,s[i]=n[o],c[i]=e[o];r(s,c),r(l,f),i=t/2;var m,h,p,d=-6.283185307179586/t;for(o=t-1;-1!==o;--o)-1==--i&&(i=t/2-1),h=u(m=d*o),p=a(m),n[o]=s[i]+h*l[i]-p*f[i],e[o]=c[i]+h*f[i]+p*l[i]}},numeric._ifftpow2=function r(n,e){var t=n.length;if(1!==t){var o,i,u=Math.cos,a=Math.sin,s=Array(t/2),c=Array(t/2),l=Array(t/2),f=Array(t/2);for(i=t/2,o=t-1;-1!==o;--o)l[--i]=n[o],f[i]=e[o],--o,s[i]=n[o],c[i]=e[o];r(s,c),r(l,f),i=t/2;var m,h,p,d=6.283185307179586/t;for(o=t-1;-1!==o;--o)-1==--i&&(i=t/2-1),h=u(m=d*o),p=a(m),n[o]=s[i]+h*l[i]-p*f[i],e[o]=c[i]+h*f[i]+p*l[i]}},numeric.ifftpow2=function(r,n){numeric._ifftpow2(r,n),numeric.diveq(r,r.length),numeric.diveq(n,n.length)},numeric.convpow2=function(r,n,e,t){var o,i,u,a,s;for(numeric.fftpow2(r,n),numeric.fftpow2(e,t),o=r.length-1;-1!==o;--o)i=r[o],a=n[o],u=e[o],s=t[o],r[o]=i*u-a*s,n[o]=i*s+a*u;numeric.ifftpow2(r,n)},numeric.T.prototype.fft=function(){var r,n,e=this.x,t=this.y,o=e.length,i=Math.log,u=i(2),a=Math.ceil(i(2*o-1)/u),s=Math.pow(2,a),c=numeric.rep([s],0),l=numeric.rep([s],0),f=Math.cos,m=Math.sin,h=-3.141592653589793/o,p=numeric.rep([s],0),d=numeric.rep([s],0);for(Math.floor(o/2),r=0;r<o;r++)p[r]=e[r];if(void 0!==t)for(r=0;r<o;r++)d[r]=t[r];for(c[0]=1,r=1;r<=s/2;r++)n=h*r*r,c[r]=f(n),l[r]=m(n),c[s-r]=f(n),l[s-r]=m(n);var g=new numeric.T(p,d),v=new numeric.T(c,l);return g=g.mul(v),numeric.convpow2(g.x,g.y,numeric.clone(v.x),numeric.neg(v.y)),(g=g.mul(v)).x.length=o,g.y.length=o,g},numeric.T.prototype.ifft=function(){var r,n,e=this.x,t=this.y,o=e.length,i=Math.log,u=i(2),a=Math.ceil(i(2*o-1)/u),s=Math.pow(2,a),c=numeric.rep([s],0),l=numeric.rep([s],0),f=Math.cos,m=Math.sin,h=3.141592653589793/o,p=numeric.rep([s],0),d=numeric.rep([s],0);for(Math.floor(o/2),r=0;r<o;r++)p[r]=e[r];if(void 0!==t)for(r=0;r<o;r++)d[r]=t[r];for(c[0]=1,r=1;r<=s/2;r++)n=h*r*r,c[r]=f(n),l[r]=m(n),c[s-r]=f(n),l[s-r]=m(n);var g=new numeric.T(p,d),v=new numeric.T(c,l);return g=g.mul(v),numeric.convpow2(g.x,g.y,numeric.clone(v.x),numeric.neg(v.y)),(g=g.mul(v)).x.length=o,g.y.length=o,g.div(o)},numeric.gradient=function(r,n){var e=n.length,t=r(n);if(isNaN(t))throw new Error("gradient: f(x) is a NaN!");var o,i,u,a,s,c,l,f,m,h=Math.max,p=numeric.clone(n),d=Array(e),g=(numeric.div,numeric.sub,h=Math.max,Math.abs),v=Math.min,y=0;for(o=0;o<e;o++)for(var x=h(1e-6*t,1e-8);;){if(++y>20)throw new Error("Numerical gradient fails");if(p[o]=n[o]+x,i=r(p),p[o]=n[o]-x,u=r(p),p[o]=n[o],isNaN(i)||isNaN(u))x/=16;else{if(d[o]=(i-u)/(2*x),a=n[o]-x,s=n[o],c=n[o]+x,l=(i-t)/x,f=(t-u)/x,m=h(g(d[o]),g(t),g(i),g(u),g(a),g(s),g(c),1e-8),!(v(h(g(l-d[o]),g(f-d[o]),g(l-f))/m,x/m)>.001))break;x/=16}}return d},numeric.uncmin=function(r,n,e,t,o,i,u){var a=numeric.gradient;void 0===u&&(u={}),void 0===e&&(e=1e-8),void 0===t&&(t=function(n){return a(r,n)}),void 0===o&&(o=1e3);var s,c,l=(n=numeric.clone(n)).length,f=r(n);if(isNaN(f))throw new Error("uncmin: f(x0) is a NaN!");var m=Math.max,h=numeric.norm2;e=m(e,numeric.epsilon);var p,d,g,v,y,x,w,b,T,_,M=u.Hinv||numeric.identity(l),A=numeric.dot,C=(numeric.inv,numeric.sub),S=numeric.add,k=numeric.tensor,O=numeric.div,P=numeric.mul,N=numeric.all,j=numeric.isFinite,q=numeric.neg,R=0,E="";for(d=t(n);R<o;){if("function"==typeof i&&i(R,n,f,d,M)){E="Callback returned true";break}if(!N(j(d))){E="Gradient has Infinity or NaN";break}if(!N(j(p=q(A(M,d))))){E="Search direction has Infinity or NaN";break}if((_=h(p))<e){E="Newton step smaller than tol";break}for(T=1,c=A(d,p),y=n;R<o&&!(T*_<e)&&(y=S(n,v=P(p,T)),(s=r(y))-f>=.1*T*c||isNaN(s));)T*=.5,++R;if(T*_<e){E="Line search step size smaller than tol";break}if(R===o){E="maxit reached during line search";break}b=A(x=C(g=t(y),d),v),w=A(M,x),M=C(S(M,P((b+A(x,w))/(b*b),k(v,v))),O(S(k(w,v),k(v,w)),b)),n=y,f=s,d=g,++R}return{solution:n,f,gradient:d,invHessian:M,iterations:R,message:E}},numeric.Dopri=function(r,n,e,t,o,i,u){this.x=r,this.y=n,this.f=e,this.ymid=t,this.iterations=o,this.events=u,this.message=i},numeric.Dopri.prototype._at=function(r,n){function e(r){return r*r}var t,o,i,u,a,s,c,l,f,m=this,h=m.x,p=m.y,d=m.f,g=m.ymid,v=(h.length,Math.floor,numeric.add),y=numeric.mul,x=numeric.sub;return t=h[n],o=h[n+1],u=p[n],a=p[n+1],i=t+.5*(o-t),s=g[n],c=x(d[n],y(u,1/(t-i)+2/(t-o))),l=x(d[n+1],y(a,1/(o-i)+2/(o-t))),v(v(v(v(y(u,(f=[e(r-o)*(r-i)/e(t-o)/(t-i),e(r-t)*e(r-o)/e(t-i)/e(o-i),e(r-t)*(r-i)/e(o-t)/(o-i),(r-t)*e(r-o)*(r-i)/e(t-o)/(t-i),(r-o)*e(r-t)*(r-i)/e(t-o)/(o-i)])[0]),y(s,f[1])),y(a,f[2])),y(c,f[3])),y(l,f[4]))},numeric.Dopri.prototype.at=function(r){var n,e,t,o=Math.floor;if("number"!=typeof r){var i=r.length,u=Array(i);for(n=i-1;-1!==n;--n)u[n]=this.at(r[n]);return u}var a=this.x;for(n=0,e=a.length-1;e-n>1;)a[t=o(.5*(n+e))]<=r?n=t:e=t;return this._at(r,n)},numeric.dopri=function(r,n,e,t,o,i,u){void 0===o&&(o=1e-6),void 0===i&&(i=1e3);var a,s,c,l,f,m,h,p,d,g,v,y,x,w=[r],b=[e],T=[t(r,e)],_=[],M=[.075,.225],A=[44/45,-56/15,32/9],C=[19372/6561,-25360/2187,64448/6561,-212/729],S=[9017/3168,-355/33,46732/5247,49/176,-5103/18656],k=[35/384,0,500/1113,125/192,-2187/6784,11/84],O=[.10013431883002395,0,.3918321794184259,-.02982460176594817,.05893268337240795,-.04497888809104361,.023904308236133973],P=[.2,.3,.8,8/9,1,1],N=[-71/57600,0,71/16695,-71/1920,17253/339200,-22/525,.025],j=0,q=(n-r)/10,R=0,E=numeric.add,Y=numeric.mul,V=(Math.max,Math.min),F=Math.abs,L=numeric.norminf,X=Math.pow,I=numeric.any,B=numeric.lt,D=numeric.and,G=(numeric.sub,new numeric.Dopri(w,b,T,_,-1,""));for("function"==typeof u&&(v=u(r,e));r<n&&R<i;)if(++R,r+q>n&&(q=n-r),a=t(r+P[0]*q,E(e,Y(.2*q,T[j]))),s=t(r+P[1]*q,E(E(e,Y(M[0]*q,T[j])),Y(M[1]*q,a))),c=t(r+P[2]*q,E(E(E(e,Y(A[0]*q,T[j])),Y(A[1]*q,a)),Y(A[2]*q,s))),l=t(r+P[3]*q,E(E(E(E(e,Y(C[0]*q,T[j])),Y(C[1]*q,a)),Y(C[2]*q,s)),Y(C[3]*q,c))),f=t(r+P[4]*q,E(E(E(E(E(e,Y(S[0]*q,T[j])),Y(S[1]*q,a)),Y(S[2]*q,s)),Y(S[3]*q,c)),Y(S[4]*q,l))),m=t(r+q,d=E(E(E(E(E(e,Y(T[j],q*k[0])),Y(s,q*k[2])),Y(c,q*k[3])),Y(l,q*k[4])),Y(f,q*k[5]))),(g="number"==typeof(h=E(E(E(E(E(Y(T[j],q*N[0]),Y(s,q*N[2])),Y(c,q*N[3])),Y(l,q*N[4])),Y(f,q*N[5])),Y(m,q*N[6])))?F(h):L(h))>o){if(r+(q=.2*q*X(o/g,.25))===r){G.msg="Step size became too small";break}}else{if(_[j]=E(E(E(E(E(E(e,Y(T[j],q*O[0])),Y(s,q*O[2])),Y(c,q*O[3])),Y(l,q*O[4])),Y(f,q*O[5])),Y(m,q*O[6])),w[++j]=r+q,b[j]=d,T[j]=m,"function"==typeof u){var U,W,H=r,$=r+.5*q;if(y=u($,_[j-1]),I(x=D(B(v,0),B(0,y)))||(H=$,v=y,y=u($=r+q,d),x=D(B(v,0),B(0,y))),I(x)){for(var z,K,Q=0,Z=1,J=1;;){if("number"==typeof v)W=(J*y*H-Z*v*$)/(J*y-Z*v);else for(W=$,p=v.length-1;-1!==p;--p)v[p]<0&&y[p]>0&&(W=V(W,(J*y[p]*H-Z*v[p]*$)/(J*y[p]-Z*v[p])));if(W<=H||W>=$)break;K=u(W,U=G._at(W,j-1)),I(z=D(B(v,0),B(0,K)))?($=W,y=K,x=z,J=1,-1===Q?Z*=.5:Z=1,Q=-1):(H=W,v=K,Z=1,1===Q?J*=.5:J=1,Q=1)}return d=G._at(.5*(r+W),j-1),G.f[j]=t(W,U),G.x[j]=W,G.y[j]=U,G.ymid[j-1]=d,G.events=x,G.iterations=R,G}}r+=q,e=d,v=y,q=V(.8*q*X(o/g,.25),4*q)}return G.iterations=R,G},numeric.LU=function(r,n){n=n||!1;var e,t,o,i,u,a,s,c,l,f=Math.abs,m=r.length,h=m-1,p=new Array(m);for(n||(r=numeric.clone(r)),o=0;o<m;++o){for(s=o,l=f((a=r[o])[o]),t=o+1;t<m;++t)l<(i=f(r[t][o]))&&(l=i,s=t);for(p[o]=s,s!=o&&(r[o]=r[s],r[s]=a,a=r[o]),u=a[o],e=o+1;e<m;++e)r[e][o]/=u;for(e=o+1;e<m;++e){for(c=r[e],t=o+1;t<h;++t)c[t]-=c[o]*a[t],c[++t]-=c[o]*a[t];t===h&&(c[t]-=c[o]*a[t])}}return{LU:r,P:p}},numeric.LUsolve=function(r,n){var e,t,o,i,u,a=r.LU,s=a.length,c=numeric.clone(n),l=r.P;for(e=s-1;-1!==e;--e)c[e]=n[e];for(e=0;e<s;++e)for(o=l[e],l[e]!==e&&(u=c[e],c[e]=c[o],c[o]=u),i=a[e],t=0;t<e;++t)c[e]-=c[t]*i[t];for(e=s-1;e>=0;--e){for(i=a[e],t=e+1;t<s;++t)c[e]-=c[t]*i[t];c[e]/=i[e]}return c},numeric.solve=function(r,n,e){return numeric.LUsolve(numeric.LU(r,e),n)},numeric.echelonize=function(r){var n,e,t,o,i,u,a,s,c=numeric.dim(r),l=c[0],f=c[1],m=numeric.identity(l),h=Array(l),p=Math.abs,d=numeric.diveq;for(r=numeric.clone(r),n=0;n<l;++n){for(t=0,i=r[n],u=m[n],e=1;e<f;++e)p(i[t])<p(i[e])&&(t=e);for(h[n]=t,d(u,i[t]),d(i,i[t]),e=0;e<l;++e)if(e!==n){for(s=(a=r[e])[t],o=f-1;-1!==o;--o)a[o]-=i[o]*s;for(a=m[e],o=l-1;-1!==o;--o)a[o]-=u[o]*s}}return{I:m,A:r,P:h}},numeric.__solveLP=function(r,n,e,t,o,i,u){var a,s,c,l,f=numeric.sum,m=(numeric.log,numeric.mul),h=numeric.sub,p=numeric.dot,d=numeric.div,g=numeric.add,v=r.length,y=e.length,x=!1,w=1,b=(numeric.transpose(n),numeric.svd,numeric.transpose),T=(numeric.leq,Math.sqrt),_=Math.abs,M=(numeric.muleq,numeric.norminf,numeric.any,Math.min),A=numeric.all,C=numeric.gt,S=Array(v),k=Array(y),O=(numeric.rep([y],1),numeric.solve),P=h(e,p(n,i)),N=p(r,r);for(c=0;c<o;++c){var j,q;for(j=y-1;-1!==j;--j)k[j]=d(n[j],P[j]);var R=b(k);for(j=v-1;-1!==j;--j)S[j]=f(R[j]);w=.25*_(N/p(r,S));var E=100*T(N/p(S,S));for((!isFinite(w)||w>E)&&(w=E),l=g(r,m(w,S)),s=p(R,k),j=v-1;-1!==j;--j)s[j][j]+=1;q=O(s,d(l,w),!0);var Y=d(P,p(n,q)),V=1;for(j=y-1;-1!==j;--j)Y[j]<0&&(V=M(V,-.999*Y[j]));if(a=h(i,m(q,V)),!A(C(P=h(e,p(n,a)),0)))return{solution:i,message:"",iterations:c};if(i=a,w<t)return{solution:a,message:"",iterations:c};if(u){var F=p(r,l),L=p(n,l);for(x=!0,j=y-1;-1!==j;--j)if(F*L[j]<0){x=!1;break}}else x=!(i[v-1]>=0);if(x)return{solution:a,message:"Unbounded",iterations:c}}return{solution:i,message:"maximum iteration count exceeded",iterations:c}},numeric._solveLP=function(r,n,e,t,o){var i=r.length,u=e.length,a=(numeric.sum,numeric.log,numeric.mul,numeric.sub),s=numeric.dot,c=(numeric.div,numeric.add,numeric.rep([i],0).concat([1])),l=numeric.rep([u,1],-1),f=numeric.blockMatrix([[n,l]]),m=e,h=numeric.rep([i],0).concat(Math.max(0,numeric.sup(numeric.neg(e)))+1),p=numeric.__solveLP(c,f,m,t,o,h,!1),d=numeric.clone(p.solution);if(d.length=i,numeric.inf(a(e,s(n,d)))<0)return{solution:NaN,message:"Infeasible",iterations:p.iterations};var g=numeric.__solveLP(r,n,e,t,o-p.iterations,d,!0);return g.iterations+=p.iterations,g},numeric.solveLP=function(r,n,e,t,o,i,u){if(void 0===u&&(u=1e3),void 0===i&&(i=numeric.epsilon),void 0===t)return numeric._solveLP(r,n,e,i,u);var a,s=t.length,c=t[0].length,l=n.length,f=numeric.echelonize(t),m=numeric.rep([c],0),h=f.P,p=[];for(a=h.length-1;-1!==a;--a)m[h[a]]=1;for(a=c-1;-1!==a;--a)0===m[a]&&p.push(a);var d=numeric.getRange,g=numeric.linspace(0,s-1),v=numeric.linspace(0,l-1),y=d(t,g,p),x=d(n,v,h),w=d(n,v,p),b=numeric.dot,T=numeric.sub,_=b(x,f.I),M=T(w,b(_,y)),A=T(e,b(_,o)),C=Array(h.length),S=Array(p.length);for(a=h.length-1;-1!==a;--a)C[a]=r[h[a]];for(a=p.length-1;-1!==a;--a)S[a]=r[p[a]];var k=T(S,b(C,b(f.I,y))),O=numeric._solveLP(k,M,A,i,u),P=O.solution;if(P!=P)return O;var N=b(f.I,T(o,b(y,P))),j=Array(r.length);for(a=h.length-1;-1!==a;--a)j[h[a]]=N[a];for(a=p.length-1;-1!==a;--a)j[p[a]]=P[a];return{solution:j,message:O.message,iterations:O.iterations}},numeric.MPStoLP=function(r){function n(n){throw new Error("MPStoLP: "+n+"\nLine "+e+": "+r[e]+"\nCurrent state: "+a[u]+"\n")}r instanceof String&&r.split("\n");var e,t,o,i,u=0,a=["Initial state","NAME","ROWS","COLUMNS","RHS","BOUNDS","ENDATA"],s=r.length,c=0,l={},f=[],m=0,h={},p=0,d=[],g=[],v=[];for(e=0;e<s;++e){var y=(o=r[e]).match(/\S*/g),x=[];for(t=0;t<y.length;++t)""!==y[t]&&x.push(y[t]);if(0!==x.length){for(t=0;t<a.length&&o.substr(0,a[t].length)!==a[t];++t);if(t<a.length){if(u=t,1===t&&(i=x[1]),6===t)return{name:i,c:d,A:numeric.transpose(g),b:v,rows:l,vars:h}}else switch(u){case 0:case 1:n("Unexpected line");case 2:switch(x[0]){case"N":0===c?c=x[1]:n("Two or more N rows");break;case"L":l[x[1]]=m,f[m]=1,v[m]=0,++m;break;case"G":l[x[1]]=m,f[m]=-1,v[m]=0,++m;break;case"E":l[x[1]]=m,f[m]=0,v[m]=0,++m;break;default:n("Parse error "+numeric.prettyPrint(x))}break;case 3:h.hasOwnProperty(x[0])||(h[x[0]]=p,d[p]=0,g[p]=numeric.rep([m],0),++p);var w=h[x[0]];for(t=1;t<x.length;t+=2)if(x[t]!==c){var b=l[x[t]];g[w][b]=(f[b]<0?-1:1)*parseFloat(x[t+1])}else d[w]=parseFloat(x[t+1]);break;case 4:for(t=1;t<x.length;t+=2)v[l[x[t]]]=(f[l[x[t]]]<0?-1:1)*parseFloat(x[t+1]);break;case 5:break;case 6:n("Internal error")}}}n("Reached end of file without ENDATA")},numeric.seedrandom={pow:Math.pow,random:Math.random},function(r,n,e,t,o,i,u){function a(r){var n,t,o=this,i=r.length,u=0,a=o.i=o.j=o.m=0;for(o.S=[],o.c=[],i||(r=[i++]);u<e;)o.S[u]=u++;for(u=0;u<e;u++)a=l(a+(n=o.S[u])+r[u%i]),t=o.S[a],o.S[u]=t,o.S[a]=n;o.g=function(r){var n=o.S,t=l(o.i+1),i=n[t],u=l(o.j+i),a=n[u];n[t]=a,n[u]=i;for(var s=n[l(i+a)];--r;)t=l(t+1),a=n[u=l(u+(i=n[t]))],n[t]=a,n[u]=i,s=s*e+n[l(i+a)];return o.i=t,o.j=u,s},o.g(e)}function s(r,n,e,t,o){if(e=[],o=typeof r,n&&"object"==o)for(t in r)if(t.indexOf("S")<5)try{e.push(s(r[t],n-1))}catch(r){}return e.length?e:r+("string"!=o?"\0":"")}function c(r,n,e,t){for(r+="",e=0,t=0;t<r.length;t++)n[l(t)]=l((e^=19*n[l(t)])+r.charCodeAt(t));for(t in r="",n)r+=String.fromCharCode(n[t]);return r}function l(r){return r&e-1}n.seedrandom=function(t,l){var f,m=[];return t=c(s(l?[t,r]:arguments.length?t:[(new Date).getTime(),r,window],3),m),c((f=new a(m)).S,r),n.random=function(){for(var r=f.g(6),n=u,t=0;r<o;)r=(r+t)*e,n*=e,t=f.g(1);for(;r>=i;)r/=2,n/=2,t>>>=1;return(r+t)/n},t},u=n.pow(e,6),o=n.pow(2,o),i=2*o,c(n.random(),r)}([],numeric.seedrandom,256,0,52),function(r){function n(r){if("object"!=typeof r)return r;var e,t=[],o=r.length;for(e=0;e<o;e++)t[e+1]=n(r[e]);return t}function e(r){if("object"!=typeof r)return r;var n,t=[],o=r.length;for(n=1;n<o;n++)t[n-1]=e(r[n]);return t}r.solveQP=function(r,t,o,i,u,a){r=n(r),t=n(t),o=n(o);var s,c,l,f,m,h=[],p=[],d=[],g=[],v=[];if(u=u||0,a=a?n(a):[void 0,0],i=i?n(i):[],c=r.length-1,l=o[1].length-1,!i)for(s=1;s<=l;s+=1)i[s]=0;for(s=1;s<=l;s+=1)p[s]=0;for(f=Math.min(c,l),s=1;s<=c;s+=1)d[s]=0;for(h[1]=0,s=1;s<=2*c+f*(f+5)/2+2*l+1;s+=1)g[s]=0;for(s=1;s<=2;s+=1)v[s]=0;return function(r,n,e,t,o,i,u,a,s,c,l,f,m,h,p,d){function g(){for(h[1]=h[1]+1,_=P,b=1;b<=c;b+=1){for(_+=1,Y=-a[b],T=1;T<=t;T+=1)Y+=u[T][b]*o[T];if(Math.abs(Y)<G&&(Y=0),b>l)p[_]=Y;else if(p[_]=-Math.abs(Y),Y>0){for(T=1;T<=t;T+=1)u[T][b]=-u[T][b];a[b]=-a[b]}}for(b=1;b<=m;b+=1)p[P+f[b]]=0;for(j=0,E=0,b=1;b<=c;b+=1)p[P+b]<E*p[R+b]&&(j=b,E=p[P+b]/p[R+b]);return 0===j?999:0}function v(){for(b=1;b<=t;b+=1){for(Y=0,T=1;T<=t;T+=1)Y+=r[T][b]*u[T][j];p[b]=Y}for(M=S,b=1;b<=t;b+=1)p[M+b]=0;for(T=m+1;T<=t;T+=1)for(b=1;b<=t;b+=1)p[M+b]=p[M+b]+r[b][T]*p[T];for(B=!0,b=m;b>=1;b-=1){for(Y=p[b],M=(_=O+b*(b+3)/2)-b,T=b+1;T<=m;T+=1)Y-=p[_]*p[k+T],_+=T;if(Y/=p[M],p[k+b]=Y,f[b]<l)break;if(Y<0)break;B=!1,C=b}if(!B)for(V=p[N+C]/p[k+C],b=1;b<=m&&!(f[b]<l)&&!(p[k+b]<0);b+=1)(E=p[N+b]/p[k+b])<V&&(V=E,C=b);for(Y=0,b=S+1;b<=S+t;b+=1)Y+=p[b]*p[b];if(Math.abs(Y)<=G){if(B)return d[1]=1,999;for(b=1;b<=m;b+=1)p[N+b]=p[N+b]-V*p[k+b];return p[N+m+1]=p[N+m+1]+V,700}for(Y=0,b=1;b<=t;b+=1)Y+=p[S+b]*u[b][j];for(F=-p[P+j]/Y,D=!0,B||V<F&&(F=V,D=!1),b=1;b<=t;b+=1)o[b]=o[b]+F*p[S+b],Math.abs(o[b])<G&&(o[b]=0);for(i[1]=i[1]+F*Y*(F/2+p[N+m+1]),b=1;b<=m;b+=1)p[N+b]=p[N+b]-F*p[k+b];if(p[N+m+1]=p[N+m+1]+F,!D){for(Y=-a[j],T=1;T<=t;T+=1)Y+=o[T]*u[T][j];if(j>l)p[P+j]=Y;else if(p[P+j]=-Math.abs(Y),Y>0){for(T=1;T<=t;T+=1)u[T][j]=-u[T][j];a[j]=-a[j]}return 700}for(f[m+=1]=j,_=O+(m-1)*m/2+1,b=1;b<=m-1;b+=1)p[_]=p[b],_+=1;if(m===t)p[_]=p[t];else{for(b=t;b>=m+1&&0!==p[b]&&(L=Math.max(Math.abs(p[b-1]),Math.abs(p[b])),X=Math.min(Math.abs(p[b-1]),Math.abs(p[b])),E=p[b-1]>=0?Math.abs(L*Math.sqrt(1+X*X/(L*L))):-Math.abs(L*Math.sqrt(1+X*X/(L*L))),L=p[b-1]/E,X=p[b]/E,1!==L);b-=1)if(0===L)for(p[b-1]=X*E,T=1;T<=t;T+=1)E=r[T][b-1],r[T][b-1]=r[T][b],r[T][b]=E;else for(p[b-1]=E,I=X/(1+L),T=1;T<=t;T+=1)E=L*r[T][b-1]+X*r[T][b],r[T][b]=I*(r[T][b-1]+E)-r[T][b],r[T][b-1]=E;p[_]=p[m]}return 0}function y(){if(0===p[M=(_=O+C*(C+1)/2+1)+C])return 798;if(L=Math.max(Math.abs(p[M-1]),Math.abs(p[M])),X=Math.min(Math.abs(p[M-1]),Math.abs(p[M])),E=p[M-1]>=0?Math.abs(L*Math.sqrt(1+X*X/(L*L))):-Math.abs(L*Math.sqrt(1+X*X/(L*L))),L=p[M-1]/E,X=p[M]/E,1===L)return 798;if(0===L){for(b=C+1;b<=m;b+=1)E=p[M-1],p[M-1]=p[M],p[M]=E,M+=b;for(b=1;b<=t;b+=1)E=r[b][C],r[b][C]=r[b][C+1],r[b][C+1]=E}else{for(I=X/(1+L),b=C+1;b<=m;b+=1)E=L*p[M-1]+X*p[M],p[M]=I*(p[M-1]+E)-p[M],p[M-1]=E,M+=b;for(b=1;b<=t;b+=1)E=L*r[b][C]+X*r[b][C+1],r[b][C+1]=I*(r[b][C]+E)-r[b][C+1],r[b][C]=E}return 0}function x(){for(M=_-C,b=1;b<=C;b+=1)p[M]=p[_],_+=1,M+=1;return p[N+C]=p[N+C+1],f[C]=f[C+1],(C+=1)<m?797:0}function w(){return p[N+m]=p[N+m+1],p[N+m+1]=0,f[m]=0,m-=1,h[2]=h[2]+1,0}var b,T,_,M,A,C,S,k,O,P,N,j,q,R,E,Y,V,F,L,X,I,B,D,G,U,W,H;q=Math.min(t,c),_=2*t+q*(q+5)/2+2*c+1,G=1e-60;do{U=1+.1*(G+=G),W=1+.2*G}while(U<=1||W<=1);for(b=1;b<=t;b+=1)p[b]=n[b];for(b=t+1;b<=_;b+=1)p[b]=0;for(b=1;b<=c;b+=1)f[b]=0;if(A=[],0===d[1]){if(function(r,n,e,t){var o,i,u,a,s,c;for(i=1;i<=e;i+=1){if(t[1]=i,c=0,(u=i-1)<1){if((c=r[i][i]-c)<=0)break;r[i][i]=Math.sqrt(c)}else{for(a=1;a<=u;a+=1){for(s=r[a][i],o=1;o<a;o+=1)s-=r[o][i]*r[o][a];s/=r[a][a],r[a][i]=s,c+=s*s}if((c=r[i][i]-c)<=0)break;r[i][i]=Math.sqrt(c)}t[1]=0}}(r,0,t,A),0!==A[1])return void(d[1]=2);(function(r,n,e,t){var o,i,u,a;for(i=1;i<=e;i+=1){for(a=0,o=1;o<i;o+=1)a+=r[o][i]*t[o];t[i]=(t[i]-a)/r[i][i]}for(u=1;u<=e;u+=1)for(t[i=e+1-u]=t[i]/r[i][i],a=-t[i],o=1;o<i;o+=1)t[o]=t[o]+a*r[o][i]})(r,0,t,n),function(r,n,e){var t,o,i,u,a;for(i=1;i<=e;i+=1){for(r[i][i]=1/r[i][i],a=-r[i][i],t=1;t<i;t+=1)r[t][i]=a*r[t][i];if(e<(u=i+1))break;for(o=u;o<=e;o+=1)for(a=r[i][o],r[i][o]=0,t=1;t<=i;t+=1)r[t][o]=r[t][o]+a*r[t][i]}}(r,0,t)}else{for(T=1;T<=t;T+=1)for(o[T]=0,b=1;b<=T;b+=1)o[T]=o[T]+r[b][T]*n[b];for(T=1;T<=t;T+=1)for(n[T]=0,b=T;b<=t;b+=1)n[T]=n[T]+r[T][b]*o[b]}for(i[1]=0,T=1;T<=t;T+=1)for(o[T]=n[T],i[1]=i[1]+p[T]*o[T],p[T]=0,b=T+1;b<=t;b+=1)r[b][T]=0;for(i[1]=-i[1]/2,d[1]=0,R=(P=(O=(N=(k=(S=t)+t)+q)+q+1)+q*(q+1)/2)+c,b=1;b<=c;b+=1){for(Y=0,T=1;T<=t;T+=1)Y+=u[T][b]*u[T][b];p[R+b]=Math.sqrt(Y)}for(m=0,h[1]=0,h[2]=0,H=0;;){if(999===(H=g()))return;for(;0!==(H=v());){if(999===H)return;if(700===H)if(C===m)w();else{for(;y(),797===(H=x()););w()}}}}(r,t,0,c,d,h,o,i,0,l,u,p,0,v,g,a),m="",1===a[1]&&(m="constraints are inconsistent, no solution!"),2===a[1]&&(m="matrix D in quadratic function is not positive definite!"),{solution:e(d),value:e(h),unconstrained_solution:e(t),iterations:e(v),iact:e(p),message:m}}}(numeric),numeric.svd=function(r){function n(r,n){return(r=Math.abs(r))>(n=Math.abs(n))?r*Math.sqrt(1+n*n/r/r):0==n?r:n*Math.sqrt(1+r*r/n/n)}var e,t=numeric.epsilon,o=1e-64/t,i=0,u=0,a=0,s=0,c=0,l=numeric.clone(r),f=l.length,m=l[0].length;if(f<m)throw"Need more rows than columns";var h=new Array(m),p=new Array(m);for(u=0;u<m;u++)h[u]=p[u]=0;var d=numeric.rep([m,m],0),g=0,v=0,y=0,x=0,w=0,b=0,T=0;for(u=0;u<m;u++){for(h[u]=v,T=0,c=u+1,a=u;a<f;a++)T+=l[a][u]*l[a][u];if(T<=o)v=0;else for(g=l[u][u],v=Math.sqrt(T),g>=0&&(v=-v),y=g*v-T,l[u][u]=g-v,a=c;a<m;a++){for(T=0,s=u;s<f;s++)T+=l[s][u]*l[s][a];for(g=T/y,s=u;s<f;s++)l[s][a]+=g*l[s][u]}for(p[u]=v,T=0,a=c;a<m;a++)T+=l[u][a]*l[u][a];if(T<=o)v=0;else{for(g=l[u][u+1],v=Math.sqrt(T),g>=0&&(v=-v),y=g*v-T,l[u][u+1]=g-v,a=c;a<m;a++)h[a]=l[u][a]/y;for(a=c;a<f;a++){for(T=0,s=c;s<m;s++)T+=l[a][s]*l[u][s];for(s=c;s<m;s++)l[a][s]+=T*h[s]}}(w=Math.abs(p[u])+Math.abs(h[u]))>x&&(x=w)}for(u=m-1;-1!=u;u+=-1){if(0!=v){for(y=v*l[u][u+1],a=c;a<m;a++)d[a][u]=l[u][a]/y;for(a=c;a<m;a++){for(T=0,s=c;s<m;s++)T+=l[u][s]*d[s][a];for(s=c;s<m;s++)d[s][a]+=T*d[s][u]}}for(a=c;a<m;a++)d[u][a]=0,d[a][u]=0;d[u][u]=1,v=h[u],c=u}for(u=m-1;-1!=u;u+=-1){for(c=u+1,v=p[u],a=c;a<m;a++)l[u][a]=0;if(0!=v){for(y=l[u][u]*v,a=c;a<m;a++){for(T=0,s=c;s<f;s++)T+=l[s][u]*l[s][a];for(g=T/y,s=u;s<f;s++)l[s][a]+=g*l[s][u]}for(a=u;a<f;a++)l[a][u]=l[a][u]/v}else for(a=u;a<f;a++)l[a][u]=0;l[u][u]+=1}for(t*=x,s=m-1;-1!=s;s+=-1)for(var _=0;_<50;_++){var M=!1;for(c=s;-1!=c;c+=-1){if(Math.abs(h[c])<=t){M=!0;break}if(Math.abs(p[c-1])<=t)break}if(!M){i=0,T=1;var A=c-1;for(u=c;u<s+1&&(g=T*h[u],h[u]=i*h[u],!(Math.abs(g)<=t));u++)for(y=n(g,v=p[u]),p[u]=y,i=v/y,T=-g/y,a=0;a<f;a++)w=l[a][A],b=l[a][u],l[a][A]=w*i+b*T,l[a][u]=-w*T+b*i}if(b=p[s],c==s){if(b<0)for(p[s]=-b,a=0;a<m;a++)d[a][s]=-d[a][s];break}if(_>=49)throw"Error: no convergence.";for(x=p[c],v=n(g=(((w=p[s-1])-b)*(w+b)+((v=h[s-1])-(y=h[s]))*(v+y))/(2*y*w),1),g=g<0?((x-b)*(x+b)+y*(w/(g-v)-y))/x:((x-b)*(x+b)+y*(w/(g+v)-y))/x,i=1,T=1,u=c+1;u<s+1;u++){for(v=h[u],w=p[u],y=T*v,v*=i,b=n(g,y),h[u-1]=b,g=x*(i=g/b)+v*(T=y/b),v=-x*T+v*i,y=w*T,w*=i,a=0;a<m;a++)x=d[a][u-1],b=d[a][u],d[a][u-1]=x*i+b*T,d[a][u]=-x*T+b*i;for(b=n(g,y),p[u-1]=b,g=(i=g/b)*v+(T=y/b)*w,x=-T*v+i*w,a=0;a<f;a++)w=l[a][u-1],b=l[a][u],l[a][u-1]=w*i+b*T,l[a][u]=-w*T+b*i}h[c]=0,h[s]=g,p[s]=x}for(u=0;u<p.length;u++)p[u]<t&&(p[u]=0);for(u=0;u<m;u++)for(a=u-1;a>=0;a--)if(p[a]<p[u]){for(i=p[a],p[a]=p[u],p[u]=i,s=0;s<l.length;s++)e=l[s][u],l[s][u]=l[s][a],l[s][a]=e;for(s=0;s<d.length;s++)e=d[s][u],d[s][u]=d[s][a],d[s][a]=e;u=a}return{U:l,S:p,V:d}}},111:(r,n,e)=>{"use strict";function t(r){r.sort();const n=r[Math.trunc(r.length/4)],e=r.length%2==0?(r[Math.trunc(r.length/2)]+r[Math.trunc(r.length/2)-1])/2:r[Math.trunc(r.length/2)],t=r[Math.trunc(3*r.length/4)],i=1.5*(t-n);let u=o(r,t+i);u<0&&(u=~u);let a=r[Math.max(0,u-1)];a<t&&(a=t);let s=o(r,n-i);s<0&&(s=~s);let c=r[s];return c>n&&(c=n),{q1:n,q2:e,q3:t,lowerAdjacentValue:c,upperAdjacentValue:a}}function o(r,n,e=0,t){if(0===r.length)return-1;if(void 0===t&&(t=r.length-1),n<r[e])return-1;if(n>r[t])return-(t+1);for(;t-e>1;){const o=Math.trunc((t+e)/2);if(n===r[o])return o;n<r[o]?t=o:e=o}return r[e]===n?e:0===r[t]?t:n<r[e]?-(e+1):-(t+1)}e.d(n,{G:()=>t})},875:(r,n,e)=>{"use strict";e.d(n,{K0:()=>g,Kp:()=>c,Qc:()=>l,XD:()=>f,ZY:()=>_,aC:()=>S,cY:()=>h,d8:()=>s,hR:()=>A,iC:()=>M,j2:()=>a,js:()=>u,kW:()=>d,sw:()=>p,ue:()=>C,vK:()=>m,yB:()=>v});var t=e(976),o=e(78),i=e(162);const u={CONSTANT:"constant",PROPORTIONAL:"proportional"},a="fit",s="fit",c=".fit",l="rgba(255,191,63,0.4)",f="rgba(255,238,204,0.3)",m={TOP:"top",BOTTOM:"bottom"};class h{constructor(){this.chartOptions={},this.seriesOptions={},this.series=[]}}const p=[t.Property.js("rSquared",t.TYPE.FLOAT,{userEditable:!1}),t.Property.js("auc",t.TYPE.FLOAT,{userEditable:!1}),t.Property.js("interceptY",t.TYPE.FLOAT,{userEditable:!1}),t.Property.js("interceptX",t.TYPE.FLOAT,{userEditable:!1}),t.Property.js("slope",t.TYPE.FLOAT,{userEditable:!1}),t.Property.js("top",t.TYPE.FLOAT,{userEditable:!1}),t.Property.js("bottom",t.TYPE.FLOAT,{userEditable:!1})],d=[t.Property.js("minX",t.TYPE.FLOAT,{description:"Minimum value of the X axis",nullable:!0}),t.Property.js("minY",t.TYPE.FLOAT,{description:"Minimum value of the Y axis",nullable:!0}),t.Property.js("maxX",t.TYPE.FLOAT,{description:"Maximum value of the X axis",nullable:!0}),t.Property.js("maxY",t.TYPE.FLOAT,{description:"Maximum value of the Y axis",nullable:!0}),t.Property.js("title",t.TYPE.STRING,{nullable:!0}),t.Property.js("xAxisName",t.TYPE.STRING,{description:"Label to show on the X axis. If not specified, corresponding data column name is used",nullable:!0}),t.Property.js("yAxisName",t.TYPE.STRING,{description:"Label to show on the Y axis. If not specified, corresponding data column name is used",nullable:!0}),t.Property.js("logX",t.TYPE.BOOL,{description:"Whether the X axis should be logarithmic",defaultValue:!1}),t.Property.js("logY",t.TYPE.BOOL,{description:"Whether the Y axis should be logarithmic",defaultValue:!1}),t.Property.js("allowXZeroes",t.TYPE.BOOL,{description:"Whether x zeroes allowed for logarithmic data or not",defaultValue:!0}),t.Property.js("showStatistics",t.TYPE.STRING_LIST,{description:"Whether specific statistics should be rendered",choices:p.map((r=>r.name)),inputType:"MultiChoice"})],g=[t.Property.js("fitFunction",t.TYPE.STRING,{category:"Fitting",choices:["sigmoid","linear"],defaultValue:"sigmoid"}),t.Property.js("pointColor",t.TYPE.STRING,{category:"Rendering",nullable:!0,inputType:"Color"}),t.Property.js("fitLineColor",t.TYPE.STRING,{category:"Rendering",nullable:!0,inputType:"Color"}),t.Property.js("outlierColor",t.TYPE.STRING,{category:"Rendering",nullable:!0,inputType:"Color"}),t.Property.js("errorModel",t.TYPE.STRING,{category:"Fitting",defaultValue:"constant",choices:["constant","proportional"],nullable:!1}),t.Property.js("clickToToggle",t.TYPE.BOOL,{category:"Fitting",description:"Click on a point to mark it as outlier and refit",nullable:!0,defaultValue:!1}),t.Property.js("showFitLine",t.TYPE.BOOL,{category:"Fitting",defaultValue:!0}),t.Property.js("showPoints",t.TYPE.STRING,{category:"Fitting",description:"Whether points/candlesticks/none should be rendered",defaultValue:"points",choices:["points","candlesticks","both"]}),t.Property.js("showCurveConfidenceInterval",t.TYPE.BOOL,{category:"Fitting",description:"Whether confidence intervals should be rendered",defaultValue:!1,friendlyName:"Confidence interval"}),t.Property.js("markerType",t.TYPE.STRING,{category:"Rendering",defaultValue:"circle",choices:["asterisk","circle","cross border","diamond","square","star","triangle bottom","triangle left","triangle right","triangle top"],nullable:!1}),t.Property.js("lineStyle",t.TYPE.STRING,{category:"Rendering",defaultValue:"solid",choices:["solid","dotted","dashed","dashdotted"],nullable:!1}),t.Property.js("droplines",t.TYPE.STRING_LIST,{description:"Whether specific droplines should be rendered",choices:["IC50"],inputType:"MultiChoice"})],v="sigmoid";class y{}class x extends y{constructor(r,n,e,t){super(),this._name=r,this._parameterNames=t,this.y=n,this.getInitialParameters=e}get name(){return this._name}get parameterNames(){return this._parameterNames}y(r,n){throw new Error("Not implemented")}getInitialParameters(r,n){throw new Error("Not implemented")}}const w={linear:new class extends y{get name(){return"linear"}get parameterNames(){return["Slope","Intercept"]}y(r,n){return function(r,n){return r[0]*n+r[1]}(r,n)}getInitialParameters(r,n){let e=0,t=0;for(let n=1;n<r.length;n++)r[n]<r[e]&&(e=n),r[n]>r[t]&&(t=n);const o=r[t]-r[e],i=(n[t]-n[e])/o;return[i,n[t]-i*r[t]]}},sigmoid:new class extends y{get name(){return v}get parameterNames(){return["Top","Bottom","Slope","IC50"]}y(r,n){return function(r,n){const e=r[0],t=r[1],o=r[2],i=r[3];return i+(e-i)/(1+Math.pow(10,(n-o)*t))}(r,n)}getInitialParameters(r,n){const e=t.Rect.fromXYArrays(r,n),o=(e.bottom-e.top)/2+e.top;let i=e.bottom-e.top,u=0;for(let e=0;e<r.length;e++){const r=Math.abs(n[e]-o);r<i&&(i=r,u=e)}const a=r[u],s=n[0]>n[n.length-1]?1:-1;return[e.bottom,s,a,e.top]}}};function b(r){let n;switch(r){case u.CONSTANT:n=N;break;case u.PROPORTIONAL:n=j;break;default:n=N}return n}function T(r,n,e,t){return{getValue:t=>e(n,r,t).value,getGradient:(o,i)=>{for(let u=0;u<o.length;u++)i[u]=t.includes(u)?0:P(e,n,r,o,u);return i}}}function _(r){if("string"==typeof r)return w[r];if(!w[r.name]){const n=r.name,e=r.parameterNames,t=r.function.split("=>").map((r=>r.trim())),o=r.getInitialParameters.split("=>").map((r=>r.trim())),i=new Function(t[0].slice(1,t[0].length-1),`${t[1].includes(";")?"":"return "}${t[1]}`),u=new Function(o[0].slice(1,o[0].length-1),`return ${o[1]}`),a=new x(n,i,u,e);w[n]=a}return w[r.name]}function M(r,n,e,t){var i,u;const a=n.y,s=n.getInitialParameters(r.x,r.y),c=b(e),l=[];let f=!0;for(;f;){const n=T(r,a,c,l);if((0,o.U)(n,s),(0,o.U)(n,s),f=!1,!t)break;for(let r=0;r<t.length;r++){if(void 0!==(null===(i=t[r])||void 0===i?void 0:i.max)&&s[r]>t[r].max){f=!0,l.push(r),s[r]=t[r].max;break}if(void 0!==(null===(u=t[r])||void 0===u?void 0:u.min)&&s[r]<t[r].min){f=!0,l.push(r),s[r]=t[r].min;break}}}return{fittedCurve:A(a,s),parameters:s}}function A(r,n){return e=>r(n,e)}function C(r,n,e,t=.05,o){const a=b(o),s=o===u.PROPORTIONAL?a(e,r,n).mult:a(e,r,n).const,c=i.normal.inv(1-t/2,0,1);return{confidenceTop:r=>{const t=e(n,r);return o===u.CONSTANT?t+c*s:t+c*Math.abs(t)*s},confidenceBottom:r=>{const t=e(n,r);return o===u.CONSTANT?t-c*s:t-c*Math.abs(t)*s}}}function S(r,n,e,t=!0){const o=A(e,n);return{rSquared:t?O(o,r):void 0,auc:t?k(o,r):void 0,interceptX:n[2],interceptY:o(n[2]),slope:n[1],top:n[0],bottom:n[3]}}function k(r,n){let e=0;const t=Math.min(...n.x),o=Math.max(...n.x),i=(o-t)/1e3;for(let n=t;n<o;n+=i)e+=i*r(n);return e}function O(r,n){let e=0,t=0;const o=i.mean(n.y);for(let i=0;i<n.x.length;i++)e+=Math.pow(n.y[i]-r(n.x[i]),2),t+=Math.pow(n.y[i]-o,2);return 1-e/t}function P(r,n,e,t,o){const i=1e-4*t[o]==0?.001:1e-4*t[o],u=[],a=[];for(let r=0;r<t.length;r++)r===o?(u.push(t[r]+i),a.push(t[r]-i)):(u.push(t[r]),a.push(t[r]));return(r(n,e,u).value-r(n,e,a).value)/(2*i)}function N(r,n,e){const t=Math.PI;let o=0,i=0,u=0;const a=new Float32Array(n.x.length);for(let t=0;t<n.x.length;t++){const o=n.y[t],i=r(e,n.x[t]);a[t]=Math.pow(o-i,2)}for(let r=0;r<a.length;r++)i+=a[r];i/=a.length,o=Math.sqrt(i);for(let r=0;r<a.length;r++)u+=a[r]/i+Math.log(2*t*i);return{value:-u,const:o,mult:0}}function j(r,n,e){const t=Math.PI;let o=0,i=0,u=0;const a=new Float32Array(n.x.length);for(let t=0;t<n.x.length;t++){const o=n.y[t],i=r(e,n.x[t]);a[t]=Math.pow(o-i,2)}for(let r=0;r<a.length;r++)i+=a[r];i/=a.length,o=Math.sqrt(i);for(let r=0;r<a.length;r++)u+=a[r]/i+Math.log(2*t*i);return{value:-u,const:0,mult:o}}},416:(r,n,e)=>{"use strict";e.d(n,{LC:()=>d,PK:()=>p,TL:()=>u,Y6:()=>m,dU:()=>f,hq:()=>s,jG:()=>a,kG:()=>h,tq:()=>g});var t=e(976),o=e(875);function i(r){const n={};for(const e of r)null!==e.defaultValue&&(n[e.name]=e.defaultValue);return n}function u(){return{chartOptions:i(o.kW),seriesOptions:i(o.K0)}}function a(r){var n,e;return JSON.parse(null!==(n=(e=r.tags)[o.Kp])&&void 0!==n?n:e[o.Kp]=JSON.stringify(u()))}function s(r){var n,e;return JSON.parse(null!==(n=(e=r.tags)[o.Kp])&&void 0!==n?n:e[o.Kp]=JSON.stringify(u()))}function c(r){const n=[],e=[];for(let t=0;t<r.length;t++)n[t]=r[t].x,e[t]=r[t].y;return{xs:n,ys:e}}function l(r){const n=Math.floor(r.y.length/2),e=r.y.sort(((r,n)=>r-n));return e.length%2==0?(e[n-1]+e[n])/2:e[n]}function f(r){var n;const e=r.chartOptions;if((null===(n=r.series)||void 0===n?void 0:n.length)&&0!==r.series.length){const{xs:n,ys:o}=c(r.series[0].points);let i=t.Rect.fromXYArrays(n,o);for(let n=1;n<r.series.length;n++){const{xs:e,ys:o}=c(r.series[n].points);e.some((r=>void 0===r))||o.some((r=>void 0===r))||(i=i.union(t.Rect.fromXYArrays(e,o)))}return e?function(r,n){let e=r.x,o=r.y,i=r.width,u=r.height;return void 0!==n.minX&&null!==n.minX&&(!n.logX||n.logX&&n.minX>0)&&(i+=e-n.minX,e=n.minX),void 0!==n.maxX&&null!==n.maxX&&(!n.logX||n.logX&&n.maxX>0)&&(i+=n.maxX-(e+i)),void 0!==n.minY&&null!==n.minY&&(!n.logY||n.logY&&n.minY>0)&&(u+=o-n.minY,o=n.minY),void 0!==n.maxY&&null!==n.maxY&&(!n.logY||n.logY&&n.maxY>0)&&(u+=n.maxY-(o+u)),new t.Rect(e,o,i,u)}(i,e):i}return new t.Rect(0,0,1,1)}function m(r){return(0,o.ZY)(r.fitFunction)}function h(r,n){return(0,o.hR)(n.y,r.parameters)}function p(r,n,e){var t;const i={x:r.points.filter((r=>!r.outlier)).map((r=>(null==e?void 0:e.logX)?Math.log10(r.x):r.x)),y:r.points.filter((r=>!r.outlier)).map((r=>(null==e?void 0:e.logY)?Math.log10(r.y):r.y))};var u;return r.parameterBounds&&(null==e?void 0:e.logX)&&(r.parameterBounds[2]=((u=r.parameterBounds[2])&&(void 0!==u.max&&(u.max=Math.log10(u.max)),void 0!==u.min&&(u.min=0===u.min?-Number.MAX_VALUE:Math.log10(u.min))),u)),(0,o.iC)(function(r){const n={x:[],y:[]},e={x:[r.x[0]],y:[r.y[0]]};for(let t=1;t<r.x.length;t++){if(r.x[t]===e.x[0]){e.x[e.x.length]=r.x[t],e.y[e.y.length]=r.y[t];continue}const o=l(e);n.x[n.x.length]=e.x[0],n.y[n.y.length]=o,e.x=[r.x[t]],e.y=[r.y[t]]}const t=l(e);return n.x[n.x.length]=e.x[0],n.y[n.y.length]=t,n}(i),n,null!==(t=r.errorModel)&&void 0!==t?t:o.js.CONSTANT,r.parameterBounds)}function d(r,n,e,t){var i;const u=e?{x:r.points.map((r=>(null==t?void 0:t.logX)?Math.log10(r.x):r.x)),y:r.points.map((r=>(null==t?void 0:t.logY)?Math.log10(r.y):r.y))}:{x:r.points.filter((r=>!r.outlier)).map((r=>(null==t?void 0:t.logX)?Math.log10(r.x):r.x)),y:r.points.filter((r=>!r.outlier)).map((r=>(null==t?void 0:t.logY)?Math.log10(r.y):r.y))};return r.parameters||(r.parameters=p(r,n).parameters),(0,o.ue)(u,r.parameters,n.y,.05,null!==(i=r.errorModel)&&void 0!==i?i:o.js.CONSTANT)}function g(r,n,e){const t={x:r.points.filter((r=>!r.outlier)).map((r=>(null==e?void 0:e.logX)?Math.log10(r.x):r.x)),y:r.points.filter((r=>!r.outlier)).map((r=>(null==e?void 0:e.logY)?Math.log10(r.y):r.y))};return r.parameters||(r.parameters=p(r,n).parameters),(0,o.aC)(t,r.parameters,n.y,!0)}},766:(r,n,e)=>{"use strict";e.d(n,{l:()=>a});var t=e(976);const o=1e-30,i=new class{screenToWorld(r,n,e,t,o){return e+(o?1-r/n:r/n)*(t-e)}worldToScreen(r,n,e,t,o){return o?(1-(r-e)/(t-e))*n:(r-e)/(t-e)*n}},u=new class{screenToWorld(r,n,e,t,i){e=e<o?o:e;const u=Math.log(t),a=Math.log(e);return Math.exp(a+(u-a)*(i?n-r:r)/n)}worldToScreen(r,n,e,t,i){if(r<=0)return NaN;if(Math.abs(r-e)<o)return i?n:0;if(Math.abs(r-t)<o)return i?0:n;e=e<o?o:e,r=r<o?o:r;const u=n*Math.log(r/e)/Math.log(t/e);return i?n-u:u}};class a{get xt(){return this.logX?u:i}get yt(){return this.logY?u:i}constructor(r,n,e=!1,t=!1){this.logX=!1,this.logY=!1,this.inverseX=!1,this.inverseY=!1,this.world=r,this.screen=n,this.logX=e,this.logY=t}xToScreen(r){return this.screen.left+this.xt.worldToScreen(r,this.screen.width,this.world.minX,this.world.maxX,this.inverseX)}yToScreen(r){return this.screen.top+this.yt.worldToScreen(r,this.screen.height,this.world.minY,this.world.maxY,!this.inverseY)}xToWorld(r){return this.xt.screenToWorld(r-this.screen.left,this.screen.width,this.world.minX,this.world.maxX,this.inverseX)}yToWorld(r){return this.yt.screenToWorld(r-this.screen.top,this.screen.height,this.world.minY,this.world.maxY,!this.inverseY)}toScreen(r){return new t.Point(this.xToScreen(r.x),this.yToScreen(r.y))}toWorld(r){return new t.Point(this.xToWorld(r.x),this.yToWorld(r.y))}drawCoordinateGrid(r,n,e){n&&t.Paint.horzAxis(r,this.world.minX,this.world.maxX,n.x,n.y,n.width,n.height,this.logX,this.inverseX),e&&t.Paint.vertAxis(r,this.world.minY,this.world.maxY,e.x,e.y,e.width,e.height,this.logY,this.inverseY)}}},162:function(r){var n;r.exports=(n=function(r,n){var e=Array.prototype.concat,t=Array.prototype.slice,o=Object.prototype.toString;function i(n,e){var t=n>e?n:e;return r.pow(10,17-~~(r.log(t>0?t:-t)*r.LOG10E))}var u=Array.isArray||function(r){return"[object Array]"===o.call(r)};function a(r){return"[object Function]"===o.call(r)}function s(r){return"number"==typeof r&&r-r==0}function c(){return new c._init(arguments)}function l(){return 0}function f(){return 1}function m(r,n){return r===n?1:0}c.fn=c.prototype,c._init=function(r){if(u(r[0]))if(u(r[0][0])){a(r[1])&&(r[0]=c.map(r[0],r[1]));for(var n=0;n<r[0].length;n++)this[n]=r[0][n];this.length=r[0].length}else this[0]=a(r[1])?c.map(r[0],r[1]):r[0],this.length=1;else if(s(r[0]))this[0]=c.seq.apply(null,r),this.length=1;else{if(r[0]instanceof c)return c(r[0].toArray());this[0]=[],this.length=1}return this},c._init.prototype=c.prototype,c._init.constructor=c,c.utils={calcRdx:i,isArray:u,isFunction:a,isNumber:s,toVector:function(r){return e.apply([],r)}},c._random_fn=r.random,c.setRandom=function(r){if("function"!=typeof r)throw new TypeError("fn is not a function");c._random_fn=r},c.extend=function(r){var n,e;if(1===arguments.length){for(e in r)c[e]=r[e];return this}for(n=1;n<arguments.length;n++)for(e in arguments[n])r[e]=arguments[n][e];return r},c.rows=function(r){return r.length||1},c.cols=function(r){return r[0].length||1},c.dimensions=function(r){return{rows:c.rows(r),cols:c.cols(r)}},c.row=function(r,n){return u(n)?n.map((function(n){return c.row(r,n)})):r[n]},c.rowa=function(r,n){return c.row(r,n)},c.col=function(r,n){if(u(n)){var e=c.arange(r.length).map((function(){return new Array(n.length)}));return n.forEach((function(n,t){c.arange(r.length).forEach((function(o){e[o][t]=r[o][n]}))})),e}for(var t=new Array(r.length),o=0;o<r.length;o++)t[o]=[r[o][n]];return t},c.cola=function(r,n){return c.col(r,n).map((function(r){return r[0]}))},c.diag=function(r){for(var n=c.rows(r),e=new Array(n),t=0;t<n;t++)e[t]=[r[t][t]];return e},c.antidiag=function(r){for(var n=c.rows(r)-1,e=new Array(n),t=0;n>=0;n--,t++)e[t]=[r[t][n]];return e},c.transpose=function(r){var n,e,t,o,i,a=[];for(u(r[0])||(r=[r]),e=r.length,t=r[0].length,i=0;i<t;i++){for(n=new Array(e),o=0;o<e;o++)n[o]=r[o][i];a.push(n)}return 1===a.length?a[0]:a},c.map=function(r,n,e){var t,o,i,a,s;for(u(r[0])||(r=[r]),o=r.length,i=r[0].length,a=e?r:new Array(o),t=0;t<o;t++)for(a[t]||(a[t]=new Array(i)),s=0;s<i;s++)a[t][s]=n(r[t][s],t,s);return 1===a.length?a[0]:a},c.cumreduce=function(r,n,e){var t,o,i,a,s;for(u(r[0])||(r=[r]),o=r.length,i=r[0].length,a=e?r:new Array(o),t=0;t<o;t++)for(a[t]||(a[t]=new Array(i)),i>0&&(a[t][0]=r[t][0]),s=1;s<i;s++)a[t][s]=n(a[t][s-1],r[t][s]);return 1===a.length?a[0]:a},c.alter=function(r,n){return c.map(r,n,!0)},c.create=function(r,n,e){var t,o,i=new Array(r);for(a(n)&&(e=n,n=r),t=0;t<r;t++)for(i[t]=new Array(n),o=0;o<n;o++)i[t][o]=e(t,o);return i},c.zeros=function(r,n){return s(n)||(n=r),c.create(r,n,l)},c.ones=function(r,n){return s(n)||(n=r),c.create(r,n,f)},c.rand=function(r,n){return s(n)||(n=r),c.create(r,n,c._random_fn)},c.identity=function(r,n){return s(n)||(n=r),c.create(r,n,m)},c.symmetric=function(r){var n,e,t=r.length;if(r.length!==r[0].length)return!1;for(n=0;n<t;n++)for(e=0;e<t;e++)if(r[e][n]!==r[n][e])return!1;return!0},c.clear=function(r){return c.alter(r,l)},c.seq=function(r,n,e,t){a(t)||(t=!1);var o,u=[],s=i(r,n),c=(n*s-r*s)/((e-1)*s),l=r;for(o=0;l<=n&&o<e;l=(r*s+c*s*++o)/s)u.push(t?t(l,o):l);return u},c.arange=function(r,e,t){var o,i=[];if(t=t||1,e===n&&(e=r,r=0),r===e||0===t)return[];if(r<e&&t<0)return[];if(r>e&&t>0)return[];if(t>0)for(o=r;o<e;o+=t)i.push(o);else for(o=r;o>e;o+=t)i.push(o);return i},c.slice=function(){function r(r,e,t,o){var i,u=[],a=r.length;if(e===n&&t===n&&o===n)return c.copy(r);if(o=o||1,(e=(e=e||0)>=0?e:a+e)===(t=(t=t||r.length)>=0?t:a+t)||0===o)return[];if(e<t&&o<0)return[];if(e>t&&o>0)return[];if(o>0)for(i=e;i<t;i+=o)u.push(r[i]);else for(i=e;i>t;i+=o)u.push(r[i]);return u}return function(n,e){var t,o;return s((e=e||{}).row)?s(e.col)?n[e.row][e.col]:r(c.rowa(n,e.row),(t=e.col||{}).start,t.end,t.step):s(e.col)?r(c.cola(n,e.col),(o=e.row||{}).start,o.end,o.step):(o=e.row||{},t=e.col||{},r(n,o.start,o.end,o.step).map((function(n){return r(n,t.start,t.end,t.step)})))}}(),c.sliceAssign=function(e,t,o){var i,u;if(s(t.row)){if(s(t.col))return e[t.row][t.col]=o;t.col=t.col||{},t.col.start=t.col.start||0,t.col.end=t.col.end||e[0].length,t.col.step=t.col.step||1,i=c.arange(t.col.start,r.min(e.length,t.col.end),t.col.step);var a=t.row;return i.forEach((function(r,n){e[a][r]=o[n]})),e}if(s(t.col)){t.row=t.row||{},t.row.start=t.row.start||0,t.row.end=t.row.end||e.length,t.row.step=t.row.step||1,u=c.arange(t.row.start,r.min(e[0].length,t.row.end),t.row.step);var l=t.col;return u.forEach((function(r,n){e[r][l]=o[n]})),e}return o[0].length===n&&(o=[o]),t.row.start=t.row.start||0,t.row.end=t.row.end||e.length,t.row.step=t.row.step||1,t.col.start=t.col.start||0,t.col.end=t.col.end||e[0].length,t.col.step=t.col.step||1,u=c.arange(t.row.start,r.min(e.length,t.row.end),t.row.step),i=c.arange(t.col.start,r.min(e[0].length,t.col.end),t.col.step),u.forEach((function(r,n){i.forEach((function(t,i){e[r][t]=o[n][i]}))})),e},c.diagonal=function(r){var n=c.zeros(r.length,r.length);return r.forEach((function(r,e){n[e][e]=r})),n},c.copy=function(r){return r.map((function(r){return s(r)?r:r.map((function(r){return r}))}))};var h=c.prototype;return h.length=0,h.push=Array.prototype.push,h.sort=Array.prototype.sort,h.splice=Array.prototype.splice,h.slice=Array.prototype.slice,h.toArray=function(){return this.length>1?t.call(this):t.call(this)[0]},h.map=function(r,n){return c(c.map(this,r,n))},h.cumreduce=function(r,n){return c(c.cumreduce(this,r,n))},h.alter=function(r){return c.alter(this,r),this},function(r){for(var n=0;n<r.length;n++)!function(r){h[r]=function(n){var e,t=this;return n?(setTimeout((function(){n.call(t,h[r].call(t))})),this):(e=c[r](this),u(e)?c(e):e)}}(r[n])}("transpose clear symmetric rows cols dimensions diag antidiag".split(" ")),function(r){for(var n=0;n<r.length;n++)!function(r){h[r]=function(n,e){var t=this;return e?(setTimeout((function(){e.call(t,h[r].call(t,n))})),this):c(c[r](this,n))}}(r[n])}("row col".split(" ")),function(r){for(var n=0;n<r.length;n++)!function(r){h[r]=function(){return c(c[r].apply(null,arguments))}}(r[n])}("create zeros ones rand identity".split(" ")),c}(Math),function(r,n){var e=r.utils.isFunction;function t(r,n){return r-n}function o(r,e,t){return n.max(e,n.min(r,t))}r.sum=function(r){for(var n=0,e=r.length;--e>=0;)n+=r[e];return n},r.sumsqrd=function(r){for(var n=0,e=r.length;--e>=0;)n+=r[e]*r[e];return n},r.sumsqerr=function(n){for(var e,t=r.mean(n),o=0,i=n.length;--i>=0;)o+=(e=n[i]-t)*e;return o},r.sumrow=function(r){for(var n=0,e=r.length;--e>=0;)n+=r[e];return n},r.product=function(r){for(var n=1,e=r.length;--e>=0;)n*=r[e];return n},r.min=function(r){for(var n=r[0],e=0;++e<r.length;)r[e]<n&&(n=r[e]);return n},r.max=function(r){for(var n=r[0],e=0;++e<r.length;)r[e]>n&&(n=r[e]);return n},r.unique=function(r){for(var n={},e=[],t=0;t<r.length;t++)n[r[t]]||(n[r[t]]=!0,e.push(r[t]));return e},r.mean=function(n){return r.sum(n)/n.length},r.meansqerr=function(n){return r.sumsqerr(n)/n.length},r.geomean=function(e){var t=e.map(n.log),o=r.mean(t);return n.exp(o)},r.median=function(r){var n=r.length,e=r.slice().sort(t);return 1&n?e[n/2|0]:(e[n/2-1]+e[n/2])/2},r.cumsum=function(n){return r.cumreduce(n,(function(r,n){return r+n}))},r.cumprod=function(n){return r.cumreduce(n,(function(r,n){return r*n}))},r.diff=function(r){var n,e=[],t=r.length;for(n=1;n<t;n++)e.push(r[n]-r[n-1]);return e},r.rank=function(r){var n,e=[],o={};for(n=0;n<r.length;n++)o[s=r[n]]?o[s]++:(o[s]=1,e.push(s));var i=e.sort(t),u={},a=1;for(n=0;n<i.length;n++){var s,c=o[s=i[n]],l=(a+(a+c-1))/2;u[s]=l,a+=c}return r.map((function(r){return u[r]}))},r.mode=function(r){var n,e=r.length,o=r.slice().sort(t),i=1,u=0,a=0,s=[];for(n=0;n<e;n++)o[n]===o[n+1]?i++:(i>u?(s=[o[n]],u=i,a=0):i===u&&(s.push(o[n]),a++),i=1);return 0===a?s[0]:s},r.range=function(n){return r.max(n)-r.min(n)},r.variance=function(n,e){return r.sumsqerr(n)/(n.length-(e?1:0))},r.pooledvariance=function(n){return n.reduce((function(n,e){return n+r.sumsqerr(e)}),0)/(n.reduce((function(r,n){return r+n.length}),0)-n.length)},r.deviation=function(n){for(var e=r.mean(n),t=n.length,o=new Array(t),i=0;i<t;i++)o[i]=n[i]-e;return o},r.stdev=function(e,t){return n.sqrt(r.variance(e,t))},r.pooledstdev=function(e){return n.sqrt(r.pooledvariance(e))},r.meandev=function(e){for(var t=r.mean(e),o=[],i=e.length-1;i>=0;i--)o.push(n.abs(e[i]-t));return r.mean(o)},r.meddev=function(e){for(var t=r.median(e),o=[],i=e.length-1;i>=0;i--)o.push(n.abs(e[i]-t));return r.median(o)},r.coeffvar=function(n){return r.stdev(n)/r.mean(n)},r.quartiles=function(r){var e=r.length,o=r.slice().sort(t);return[o[n.round(e/4)-1],o[n.round(e/2)-1],o[n.round(3*e/4)-1]]},r.quantiles=function(r,e,i,u){var a,s,c,l,f,m=r.slice().sort(t),h=[e.length],p=r.length;for(void 0===i&&(i=3/8),void 0===u&&(u=3/8),a=0;a<e.length;a++)c=p*(s=e[a])+(i+s*(1-i-u)),l=n.floor(o(c,1,p-1)),f=o(c-l,0,1),h[a]=(1-f)*m[l-1]+f*m[l];return h},r.percentile=function(r,n,e){var o=r.slice().sort(t),i=n*(o.length+(e?1:-1))+(e?0:1),u=parseInt(i),a=i-u;return u+1<o.length?o[u-1]+a*(o[u]-o[u-1]):o[u-1]},r.percentileOfScore=function(r,n,e){var t,o,i=0,u=r.length,a=!1;for("strict"===e&&(a=!0),o=0;o<u;o++)t=r[o],(a&&t<n||!a&&t<=n)&&i++;return i/u},r.histogram=function(e,t){t=t||4;var o,i=r.min(e),u=(r.max(e)-i)/t,a=e.length,s=[];for(o=0;o<t;o++)s[o]=0;for(o=0;o<a;o++)s[n.min(n.floor((e[o]-i)/u),t-1)]+=1;return s},r.covariance=function(n,e){var t,o=r.mean(n),i=r.mean(e),u=n.length,a=new Array(u);for(t=0;t<u;t++)a[t]=(n[t]-o)*(e[t]-i);return r.sum(a)/(u-1)},r.corrcoeff=function(n,e){return r.covariance(n,e)/r.stdev(n,1)/r.stdev(e,1)},r.spearmancoeff=function(n,e){return n=r.rank(n),e=r.rank(e),r.corrcoeff(n,e)},r.stanMoment=function(e,t){for(var o=r.mean(e),i=r.stdev(e),u=e.length,a=0,s=0;s<u;s++)a+=n.pow((e[s]-o)/i,t);return a/e.length},r.skewness=function(n){return r.stanMoment(n,3)},r.kurtosis=function(n){return r.stanMoment(n,4)-3};var i=r.prototype;!function(n){for(var t=0;t<n.length;t++)!function(n){i[n]=function(t,o){var u=[],a=0,s=this;if(e(t)&&(o=t,t=!1),o)return setTimeout((function(){o.call(s,i[n].call(s,t))})),this;if(this.length>1){for(s=!0===t?this:this.transpose();a<s.length;a++)u[a]=r[n](s[a]);return u}return r[n](this[0],t)}}(n[t])}("cumsum cumprod".split(" ")),function(n){for(var t=0;t<n.length;t++)!function(n){i[n]=function(t,o){var u=[],a=0,s=this;if(e(t)&&(o=t,t=!1),o)return setTimeout((function(){o.call(s,i[n].call(s,t))})),this;if(this.length>1){for("sumrow"!==n&&(s=!0===t?this:this.transpose());a<s.length;a++)u[a]=r[n](s[a]);return!0===t?r[n](r.utils.toVector(u)):u}return r[n](this[0],t)}}(n[t])}("sum sumsqrd sumsqerr sumrow product min max unique mean meansqerr geomean median diff rank mode range variance deviation stdev meandev meddev coeffvar quartiles histogram skewness kurtosis".split(" ")),function(n){for(var t=0;t<n.length;t++)!function(n){i[n]=function(){var t,o=[],u=0,a=this,s=Array.prototype.slice.call(arguments);if(e(s[s.length-1])){t=s[s.length-1];var c=s.slice(0,s.length-1);return setTimeout((function(){t.call(a,i[n].apply(a,c))})),this}t=void 0;var l=function(e){return r[n].apply(a,[e].concat(s))};if(this.length>1){for(a=a.transpose();u<a.length;u++)o[u]=l(a[u]);return o}return l(this[0])}}(n[t])}("quantiles percentileOfScore".split(" "))}(n,Math),function(r,n){r.gammaln=function(r){var e,t,o,i=0,u=[76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18],a=1.000000000190015;for(o=(t=e=r)+5.5,o-=(e+.5)*n.log(o);i<6;i++)a+=u[i]/++t;return n.log(2.5066282746310007*a/e)-o},r.loggam=function(r){var e,t,o,i,u,a,s,c=[.08333333333333333,-.002777777777777778,.0007936507936507937,-.0005952380952380952,.0008417508417508418,-.001917526917526918,.00641025641025641,-.02955065359477124,.1796443723688307,-1.3924322169059];if(e=r,s=0,1==r||2==r)return 0;for(r<=7&&(e=r+(s=n.floor(7-r))),t=1/(e*e),o=2*n.PI,u=c[9],a=8;a>=0;a--)u*=t,u+=c[a];if(i=u/e+.5*n.log(o)+(e-.5)*n.log(e)-e,r<=7)for(a=1;a<=s;a++)i-=n.log(e-1),e-=1;return i},r.gammafn=function(r){var e,t,o,i,u=[-1.716185138865495,24.76565080557592,-379.80425647094563,629.3311553128184,866.9662027904133,-31451.272968848367,-36144.413418691176,66456.14382024054],a=[-30.8402300119739,315.35062697960416,-1015.1563674902192,-3107.771671572311,22538.11842098015,4755.846277527881,-134659.9598649693,-115132.2596755535],s=!1,c=0,l=0,f=0,m=r;if(r>171.6243769536076)return 1/0;if(m<=0){if(!(i=m%1+36e-17))return 1/0;s=(1&m?-1:1)*n.PI/n.sin(n.PI*i),m=1-m}for(o=m,t=m<1?m++:(m-=c=(0|m)-1)-1,e=0;e<8;++e)f=(f+u[e])*t,l=l*t+a[e];if(i=f/l+1,o<m)i/=o;else if(o>m)for(e=0;e<c;++e)i*=m,m++;return s&&(i=s/i),i},r.gammap=function(n,e){return r.lowRegGamma(n,e)*r.gammafn(n)},r.lowRegGamma=function(e,t){var o,i=r.gammaln(e),u=e,a=1/e,s=a,c=t+1-e,l=1/1e-30,f=1/c,m=f,h=1,p=-~(8.5*n.log(e>=1?e:1/e)+.4*e+17);if(t<0||e<=0)return NaN;if(t<e+1){for(;h<=p;h++)a+=s*=t/++u;return a*n.exp(-t+e*n.log(t)-i)}for(;h<=p;h++)m*=(f=1/(f=(o=-h*(h-e))*f+(c+=2)))*(l=c+o/l);return 1-m*n.exp(-t+e*n.log(t)-i)},r.factorialln=function(n){return n<0?NaN:r.gammaln(n+1)},r.factorial=function(n){return n<0?NaN:r.gammafn(n+1)},r.combination=function(e,t){return e>170||t>170?n.exp(r.combinationln(e,t)):r.factorial(e)/r.factorial(t)/r.factorial(e-t)},r.combinationln=function(n,e){return r.factorialln(n)-r.factorialln(e)-r.factorialln(n-e)},r.permutation=function(n,e){return r.factorial(n)/r.factorial(n-e)},r.betafn=function(e,t){if(!(e<=0||t<=0))return e+t>170?n.exp(r.betaln(e,t)):r.gammafn(e)*r.gammafn(t)/r.gammafn(e+t)},r.betaln=function(n,e){return r.gammaln(n)+r.gammaln(e)-r.gammaln(n+e)},r.betacf=function(r,e,t){var o,i,u,a,s=1e-30,c=1,l=e+t,f=e+1,m=e-1,h=1,p=1-l*r/f;for(n.abs(p)<s&&(p=s),a=p=1/p;c<=100&&(p=1+(i=c*(t-c)*r/((m+(o=2*c))*(e+o)))*p,n.abs(p)<s&&(p=s),h=1+i/h,n.abs(h)<s&&(h=s),a*=(p=1/p)*h,p=1+(i=-(e+c)*(l+c)*r/((e+o)*(f+o)))*p,n.abs(p)<s&&(p=s),h=1+i/h,n.abs(h)<s&&(h=s),a*=u=(p=1/p)*h,!(n.abs(u-1)<3e-7));c++);return a},r.gammapinv=function(e,t){var o,i,u,a,s,c,l=0,f=t-1,m=r.gammaln(t);if(e>=1)return n.max(100,t+100*n.sqrt(t));if(e<=0)return 0;for(t>1?(s=n.log(f),c=n.exp(f*(s-1)-m),a=e<.5?e:1-e,o=(2.30753+.27061*(i=n.sqrt(-2*n.log(a))))/(1+i*(.99229+.04481*i))-i,e<.5&&(o=-o),o=n.max(.001,t*n.pow(1-1/(9*t)-o/(3*n.sqrt(t)),3))):o=e<(i=1-t*(.253+.12*t))?n.pow(e/i,1/t):1-n.log(1-(e-i)/(1-i));l<12;l++){if(o<=0)return 0;if((o-=i=(u=(r.lowRegGamma(t,o)-e)/(i=t>1?c*n.exp(-(o-f)+f*(n.log(o)-s)):n.exp(-o+f*n.log(o)-m)))/(1-.5*n.min(1,u*((t-1)/o-1))))<=0&&(o=.5*(o+i)),n.abs(i)<1e-8*o)break}return o},r.erf=function(r){var e,t,o,i,u=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,1.5626441722e-8,-8.5238095915e-8,6.529054439e-9,5.059343495e-9,-9.91364156e-10,-2.27365122e-10,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18,-1523e-18,-94e-18,121e-18,-28e-18],a=u.length-1,s=!1,c=0,l=0;for(r<0&&(r=-r,s=!0),t=4*(e=2/(2+r))-2;a>0;a--)o=c,c=t*c-l+u[a],l=o;return i=e*n.exp(-r*r+.5*(u[0]+t*c)-l),s?i-1:1-i},r.erfc=function(n){return 1-r.erf(n)},r.erfcinv=function(e){var t,o,i,u,a=0;if(e>=2)return-100;if(e<=0)return 100;for(u=e<1?e:2-e,t=-.70711*((2.30753+.27061*(i=n.sqrt(-2*n.log(u/2))))/(1+i*(.99229+.04481*i))-i);a<2;a++)t+=(o=r.erfc(t)-u)/(1.1283791670955126*n.exp(-t*t)-t*o);return e<1?t:-t},r.ibetainv=function(e,t,o){var i,u,a,s,c,l,f,m,h,p,d=t-1,g=o-1,v=0;if(e<=0)return 0;if(e>=1)return 1;for(t>=1&&o>=1?(a=e<.5?e:1-e,l=(2.30753+.27061*(s=n.sqrt(-2*n.log(a))))/(1+s*(.99229+.04481*s))-s,e<.5&&(l=-l),f=(l*l-3)/6,m=2/(1/(2*t-1)+1/(2*o-1)),h=l*n.sqrt(f+m)/m-(1/(2*o-1)-1/(2*t-1))*(f+5/6-2/(3*m)),l=t/(t+o*n.exp(2*h))):(i=n.log(t/(t+o)),u=n.log(o/(t+o)),l=e<(s=n.exp(t*i)/t)/(h=s+(c=n.exp(o*u)/o))?n.pow(t*h*e,1/t):1-n.pow(o*h*(1-e),1/o)),p=-r.gammaln(t)-r.gammaln(o)+r.gammaln(t+o);v<10;v++){if(0===l||1===l)return l;if((l-=s=(c=(r.ibeta(l,t,o)-e)/(s=n.exp(d*n.log(l)+g*n.log(1-l)+p)))/(1-.5*n.min(1,c*(d/l-g/(1-l)))))<=0&&(l=.5*(l+s)),l>=1&&(l=.5*(l+s+1)),n.abs(s)<1e-8*l&&v>0)break}return l},r.ibeta=function(e,t,o){var i=0===e||1===e?0:n.exp(r.gammaln(t+o)-r.gammaln(t)-r.gammaln(o)+t*n.log(e)+o*n.log(1-e));return!(e<0||e>1)&&(e<(t+1)/(t+o+2)?i*r.betacf(e,t,o)/t:1-i*r.betacf(1-e,o,t)/o)},r.randn=function(e,t){var o,i,u,a,s;if(t||(t=e),e)return r.create(e,t,(function(){return r.randn()}));do{o=r._random_fn(),i=1.7156*(r._random_fn()-.5),s=(u=o-.449871)*u+(a=n.abs(i)+.386595)*(.196*a-.25472*u)}while(s>.27597&&(s>.27846||i*i>-4*n.log(o)*o*o));return i/o},r.randg=function(e,t,o){var i,u,a,s,c,l,f=e;if(o||(o=t),e||(e=1),t)return(l=r.zeros(t,o)).alter((function(){return r.randg(e)})),l;e<1&&(e+=1),i=e-1/3,u=1/n.sqrt(9*i);do{do{s=1+u*(c=r.randn())}while(s<=0);s*=s*s,a=r._random_fn()}while(a>1-.331*n.pow(c,4)&&n.log(a)>.5*c*c+i*(1-s+n.log(s)));if(e==f)return i*s;do{a=r._random_fn()}while(0===a);return n.pow(a,1/f)*i*s},function(n){for(var e=0;e<n.length;e++)!function(n){r.fn[n]=function(){return r(r.map(this,(function(e){return r[n](e)})))}}(n[e])}("gammaln gammafn factorial factorialln".split(" ")),function(n){for(var e=0;e<n.length;e++)!function(n){r.fn[n]=function(){return r(r[n].apply(null,arguments))}}(n[e])}("randn".split(" "))}(n,Math),function(r,n){function e(r,e,t,o){for(var i,u=0,a=1,s=1,c=1,l=0,f=0;n.abs((s-f)/s)>o;)f=s,a=c+(i=-(e+l)*(e+t+l)*r/(e+2*l)/(e+2*l+1))*a,s=(u=s+i*u)+(i=(l+=1)*(t-l)*r/(e+2*l-1)/(e+2*l))*s,u/=c=a+i*c,a/=c,s/=c,c=1;return s/e}function t(e,t,o){var i=[.9815606342467192,.9041172563704749,.7699026741943047,.5873179542866175,.3678314989981802,.1252334085114689],u=[.04717533638651183,.10693932599531843,.16007832854334622,.20316742672306592,.2334925365383548,.24914704581340277],a=.5*e;if(a>=8)return 1;var s,c=2*r.normal.cdf(a,0,1,1,0)-1;c=c>=n.exp(-50/o)?n.pow(c,o):0;for(var l=a,f=(8-a)/(s=e>3?2:3),m=l+f,h=0,p=o-1,d=1;d<=s;d++){for(var g=0,v=.5*(m+l),y=.5*(m-l),x=1;x<=12;x++){var w,b=v+y*(6<x?i[(w=12-x+1)-1]:-i[(w=x)-1]),T=b*b;if(T>60)break;var _=2*r.normal.cdf(b,0,1,1,0)*.5-2*r.normal.cdf(b,e,1,1,0)*.5;_>=n.exp(-30/p)&&(g+=_=u[w-1]*n.exp(-.5*T)*n.pow(_,p))}h+=g*=2*y*o/n.sqrt(2*n.PI),l=m,m+=f}return(c+=h)<=n.exp(-30/t)?0:(c=n.pow(c,t))>=1?1:c}!function(n){for(var e=0;e<n.length;e++)!function(n){r[n]=function r(n,e,t){return this instanceof r?(this._a=n,this._b=e,this._c=t,this):new r(n,e,t)},r.fn[n]=function(e,t,o){var i=r[n](e,t,o);return i.data=this,i},r[n].prototype.sample=function(e){var t=this._a,o=this._b,i=this._c;return e?r.alter(e,(function(){return r[n].sample(t,o,i)})):r[n].sample(t,o,i)},function(e){for(var t=0;t<e.length;t++)!function(e){r[n].prototype[e]=function(t){var o=this._a,i=this._b,u=this._c;return t||0===t||(t=this.data),"number"!=typeof t?r.fn.map.call(t,(function(t){return r[n][e](t,o,i,u)})):r[n][e](t,o,i,u)}}(e[t])}("pdf cdf inv".split(" ")),function(e){for(var t=0;t<e.length;t++)!function(e){r[n].prototype[e]=function(){return r[n][e](this._a,this._b,this._c)}}(e[t])}("mean median mode variance".split(" "))}(n[e])}("beta centralF cauchy chisquare exponential gamma invgamma kumaraswamy laplace lognormal noncentralt normal pareto studentt weibull uniform binomial negbin hypgeom poisson triangular tukey arcsine".split(" ")),r.extend(r.beta,{pdf:function(e,t,o){return e>1||e<0?0:1==t&&1==o?1:t<512&&o<512?n.pow(e,t-1)*n.pow(1-e,o-1)/r.betafn(t,o):n.exp((t-1)*n.log(e)+(o-1)*n.log(1-e)-r.betaln(t,o))},cdf:function(n,e,t){return n>1||n<0?1*(n>1):r.ibeta(n,e,t)},inv:function(n,e,t){return r.ibetainv(n,e,t)},mean:function(r,n){return r/(r+n)},median:function(n,e){return r.ibetainv(.5,n,e)},mode:function(r,n){return(r-1)/(r+n-2)},sample:function(n,e){var t=r.randg(n);return t/(t+r.randg(e))},variance:function(r,e){return r*e/(n.pow(r+e,2)*(r+e+1))}}),r.extend(r.centralF,{pdf:function(e,t,o){var i;return e<0?0:t<=2?0===e&&t<2?1/0:0===e&&2===t?1:1/r.betafn(t/2,o/2)*n.pow(t/o,t/2)*n.pow(e,t/2-1)*n.pow(1+t/o*e,-(t+o)/2):(i=t*e/(o+e*t),t*(o/(o+e*t))/2*r.binomial.pdf((t-2)/2,(t+o-2)/2,i))},cdf:function(n,e,t){return n<0?0:r.ibeta(e*n/(e*n+t),e/2,t/2)},inv:function(n,e,t){return t/(e*(1/r.ibetainv(n,e/2,t/2)-1))},mean:function(r,n){return n>2?n/(n-2):void 0},mode:function(r,n){return r>2?n*(r-2)/(r*(n+2)):void 0},sample:function(n,e){return 2*r.randg(n/2)/n/(2*r.randg(e/2)/e)},variance:function(r,n){if(!(n<=4))return 2*n*n*(r+n-2)/(r*(n-2)*(n-2)*(n-4))}}),r.extend(r.cauchy,{pdf:function(r,e,t){return t<0?0:t/(n.pow(r-e,2)+n.pow(t,2))/n.PI},cdf:function(r,e,t){return n.atan((r-e)/t)/n.PI+.5},inv:function(r,e,t){return e+t*n.tan(n.PI*(r-.5))},median:function(r){return r},mode:function(r){return r},sample:function(e,t){return r.randn()*n.sqrt(1/(2*r.randg(.5)))*t+e}}),r.extend(r.chisquare,{pdf:function(e,t){return e<0?0:0===e&&2===t?.5:n.exp((t/2-1)*n.log(e)-e/2-t/2*n.log(2)-r.gammaln(t/2))},cdf:function(n,e){return n<0?0:r.lowRegGamma(e/2,n/2)},inv:function(n,e){return 2*r.gammapinv(n,.5*e)},mean:function(r){return r},median:function(r){return r*n.pow(1-2/(9*r),3)},mode:function(r){return r-2>0?r-2:0},sample:function(n){return 2*r.randg(n/2)},variance:function(r){return 2*r}}),r.extend(r.exponential,{pdf:function(r,e){return r<0?0:e*n.exp(-e*r)},cdf:function(r,e){return r<0?0:1-n.exp(-e*r)},inv:function(r,e){return-n.log(1-r)/e},mean:function(r){return 1/r},median:function(r){return 1/r*n.log(2)},mode:function(){return 0},sample:function(e){return-1/e*n.log(r._random_fn())},variance:function(r){return n.pow(r,-2)}}),r.extend(r.gamma,{pdf:function(e,t,o){return e<0?0:0===e&&1===t?1/o:n.exp((t-1)*n.log(e)-e/o-r.gammaln(t)-t*n.log(o))},cdf:function(n,e,t){return n<0?0:r.lowRegGamma(e,n/t)},inv:function(n,e,t){return r.gammapinv(n,e)*t},mean:function(r,n){return r*n},mode:function(r,n){if(r>1)return(r-1)*n},sample:function(n,e){return r.randg(n)*e},variance:function(r,n){return r*n*n}}),r.extend(r.invgamma,{pdf:function(e,t,o){return e<=0?0:n.exp(-(t+1)*n.log(e)-o/e-r.gammaln(t)+t*n.log(o))},cdf:function(n,e,t){return n<=0?0:1-r.lowRegGamma(e,t/n)},inv:function(n,e,t){return t/r.gammapinv(1-n,e)},mean:function(r,n){return r>1?n/(r-1):void 0},mode:function(r,n){return n/(r+1)},sample:function(n,e){return e/r.randg(n)},variance:function(r,n){if(!(r<=2))return n*n/((r-1)*(r-1)*(r-2))}}),r.extend(r.kumaraswamy,{pdf:function(r,e,t){return 0===r&&1===e?t:1===r&&1===t?e:n.exp(n.log(e)+n.log(t)+(e-1)*n.log(r)+(t-1)*n.log(1-n.pow(r,e)))},cdf:function(r,e,t){return r<0?0:r>1?1:1-n.pow(1-n.pow(r,e),t)},inv:function(r,e,t){return n.pow(1-n.pow(1-r,1/t),1/e)},mean:function(n,e){return e*r.gammafn(1+1/n)*r.gammafn(e)/r.gammafn(1+1/n+e)},median:function(r,e){return n.pow(1-n.pow(2,-1/e),1/r)},mode:function(r,e){if(r>=1&&e>=1&&1!==r&&1!==e)return n.pow((r-1)/(r*e-1),1/r)},variance:function(){throw new Error("variance not yet implemented")}}),r.extend(r.lognormal,{pdf:function(r,e,t){return r<=0?0:n.exp(-n.log(r)-.5*n.log(2*n.PI)-n.log(t)-n.pow(n.log(r)-e,2)/(2*t*t))},cdf:function(e,t,o){return e<0?0:.5+.5*r.erf((n.log(e)-t)/n.sqrt(2*o*o))},inv:function(e,t,o){return n.exp(-1.4142135623730951*o*r.erfcinv(2*e)+t)},mean:function(r,e){return n.exp(r+e*e/2)},median:function(r){return n.exp(r)},mode:function(r,e){return n.exp(r-e*e)},sample:function(e,t){return n.exp(r.randn()*t+e)},variance:function(r,e){return(n.exp(e*e)-1)*n.exp(2*r+e*e)}}),r.extend(r.noncentralt,{pdf:function(e,t,o){return n.abs(o)<1e-14?r.studentt.pdf(e,t):n.abs(e)<1e-14?n.exp(r.gammaln((t+1)/2)-o*o/2-.5*n.log(n.PI*t)-r.gammaln(t/2)):t/e*(r.noncentralt.cdf(e*n.sqrt(1+2/t),t+2,o)-r.noncentralt.cdf(e,t,o))},cdf:function(e,t,o){var i=1e-14;if(n.abs(o)<i)return r.studentt.cdf(e,t);var u=!1;e<0&&(u=!0,o=-o);for(var a=r.normal.cdf(-o,0,1),s=i+1,c=s,l=e*e/(e*e+t),f=0,m=n.exp(-o*o/2),h=n.exp(-o*o/2-.5*n.log(2)-r.gammaln(1.5))*o;f<200||c>i||s>i;)c=s,f>0&&(m*=o*o/(2*f),h*=o*o/(2*(f+.5))),a+=.5*(s=m*r.beta.cdf(l,f+.5,t/2)+h*r.beta.cdf(l,f+1,t/2)),f++;return u?1-a:a}}),r.extend(r.normal,{pdf:function(r,e,t){return n.exp(-.5*n.log(2*n.PI)-n.log(t)-n.pow(r-e,2)/(2*t*t))},cdf:function(e,t,o){return.5*(1+r.erf((e-t)/n.sqrt(2*o*o)))},inv:function(n,e,t){return-1.4142135623730951*t*r.erfcinv(2*n)+e},mean:function(r){return r},median:function(r){return r},mode:function(r){return r},sample:function(n,e){return r.randn()*e+n},variance:function(r,n){return n*n}}),r.extend(r.pareto,{pdf:function(r,e,t){return r<e?0:t*n.pow(e,t)/n.pow(r,t+1)},cdf:function(r,e,t){return r<e?0:1-n.pow(e/r,t)},inv:function(r,e,t){return e/n.pow(1-r,1/t)},mean:function(r,e){if(!(e<=1))return e*n.pow(r,e)/(e-1)},median:function(r,e){return r*(e*n.SQRT2)},mode:function(r){return r},variance:function(r,e){if(!(e<=2))return r*r*e/(n.pow(e-1,2)*(e-2))}}),r.extend(r.studentt,{pdf:function(e,t){return t=t>1e100?1e100:t,1/(n.sqrt(t)*r.betafn(.5,t/2))*n.pow(1+e*e/t,-(t+1)/2)},cdf:function(e,t){var o=t/2;return r.ibeta((e+n.sqrt(e*e+t))/(2*n.sqrt(e*e+t)),o,o)},inv:function(e,t){var o=r.ibetainv(2*n.min(e,1-e),.5*t,.5);return o=n.sqrt(t*(1-o)/o),e>.5?o:-o},mean:function(r){return r>1?0:void 0},median:function(){return 0},mode:function(){return 0},sample:function(e){return r.randn()*n.sqrt(e/(2*r.randg(e/2)))},variance:function(r){return r>2?r/(r-2):r>1?1/0:void 0}}),r.extend(r.weibull,{pdf:function(r,e,t){return r<0||e<0||t<0?0:t/e*n.pow(r/e,t-1)*n.exp(-n.pow(r/e,t))},cdf:function(r,e,t){return r<0?0:1-n.exp(-n.pow(r/e,t))},inv:function(r,e,t){return e*n.pow(-n.log(1-r),1/t)},mean:function(n,e){return n*r.gammafn(1+1/e)},median:function(r,e){return r*n.pow(n.log(2),1/e)},mode:function(r,e){return e<=1?0:r*n.pow((e-1)/e,1/e)},sample:function(e,t){return e*n.pow(-n.log(r._random_fn()),1/t)},variance:function(e,t){return e*e*r.gammafn(1+2/t)-n.pow(r.weibull.mean(e,t),2)}}),r.extend(r.uniform,{pdf:function(r,n,e){return r<n||r>e?0:1/(e-n)},cdf:function(r,n,e){return r<n?0:r<e?(r-n)/(e-n):1},inv:function(r,n,e){return n+r*(e-n)},mean:function(r,n){return.5*(r+n)},median:function(n,e){return r.mean(n,e)},mode:function(){throw new Error("mode is not yet implemented")},sample:function(n,e){return n/2+e/2+(e/2-n/2)*(2*r._random_fn()-1)},variance:function(r,e){return n.pow(e-r,2)/12}}),r.extend(r.binomial,{pdf:function(e,t,o){return 0===o||1===o?t*o===e?1:0:r.combination(t,e)*n.pow(o,e)*n.pow(1-o,t-e)},cdf:function(t,o,i){var u,a=1e-10;if(t<0)return 0;if(t>=o)return 1;if(i<0||i>1||o<=0)return NaN;var s=i,c=(t=n.floor(t))+1,l=o-t,f=c+l,m=n.exp(r.gammaln(f)-r.gammaln(l)-r.gammaln(c)+c*n.log(s)+l*n.log(1-s));return u=s<(c+1)/(f+2)?m*e(s,c,l,a):1-m*e(1-s,l,c,a),n.round(1/a*(1-u))/(1/a)}}),r.extend(r.negbin,{pdf:function(e,t,o){return e===e>>>0&&(e<0?0:r.combination(e+t-1,t-1)*n.pow(1-o,e)*n.pow(o,t))},cdf:function(n,e,t){var o=0,i=0;if(n<0)return 0;for(;i<=n;i++)o+=r.negbin.pdf(i,e,t);return o}}),r.extend(r.hypgeom,{pdf:function(e,t,o,i){if(e!=e|0)return!1;if(e<0||e<o-(t-i))return 0;if(e>i||e>o)return 0;if(2*o>t)return 2*i>t?r.hypgeom.pdf(t-o-i+e,t,t-o,t-i):r.hypgeom.pdf(i-e,t,t-o,i);if(2*i>t)return r.hypgeom.pdf(o-e,t,o,t-i);if(o<i)return r.hypgeom.pdf(e,t,i,o);for(var u=1,a=0,s=0;s<e;s++){for(;u>1&&a<i;)u*=1-o/(t-a),a++;u*=(i-s)*(o-s)/((s+1)*(t-o-i+s+1))}for(;a<i;a++)u*=1-o/(t-a);return n.min(1,n.max(0,u))},cdf:function(e,t,o,i){if(e<0||e<o-(t-i))return 0;if(e>=i||e>=o)return 1;if(2*o>t)return 2*i>t?r.hypgeom.cdf(t-o-i+e,t,t-o,t-i):1-r.hypgeom.cdf(i-e-1,t,t-o,i);if(2*i>t)return 1-r.hypgeom.cdf(o-e-1,t,o,t-i);if(o<i)return r.hypgeom.cdf(e,t,i,o);for(var u=1,a=1,s=0,c=0;c<e;c++){for(;u>1&&s<i;){var l=1-o/(t-s);a*=l,u*=l,s++}u+=a*=(i-c)*(o-c)/((c+1)*(t-o-i+c+1))}for(;s<i;s++)u*=1-o/(t-s);return n.min(1,n.max(0,u))}}),r.extend(r.poisson,{pdf:function(e,t){return t<0||e%1!=0||e<0?0:n.pow(t,e)*n.exp(-t)/r.factorial(e)},cdf:function(n,e){var t=[],o=0;if(n<0)return 0;for(;o<=n;o++)t.push(r.poisson.pdf(o,e));return r.sum(t)},mean:function(r){return r},variance:function(r){return r},sampleSmall:function(e){var t=1,o=0,i=n.exp(-e);do{o++,t*=r._random_fn()}while(t>i);return o-1},sampleLarge:function(e){var t,o,i,u,a,s,c,l,f,m,h=e;for(u=n.sqrt(h),a=n.log(h),s=.02483*(c=.931+2.53*u)-.059,l=1.1239+1.1328/(c-3.4),f=.9277-3.6224/(c-2);;){if(o=n.random()-.5,i=n.random(),m=.5-n.abs(o),t=n.floor((2*s/m+c)*o+h+.43),m>=.07&&i<=f)return t;if(!(t<0||m<.013&&i>m)&&n.log(i)+n.log(l)-n.log(s/(m*m)+c)<=t*a-h-r.loggam(t+1))return t}},sample:function(r){return r<10?this.sampleSmall(r):this.sampleLarge(r)}}),r.extend(r.triangular,{pdf:function(r,n,e,t){return e<=n||t<n||t>e?NaN:r<n||r>e?0:r<t?2*(r-n)/((e-n)*(t-n)):r===t?2/(e-n):2*(e-r)/((e-n)*(e-t))},cdf:function(r,e,t,o){return t<=e||o<e||o>t?NaN:r<=e?0:r>=t?1:r<=o?n.pow(r-e,2)/((t-e)*(o-e)):1-n.pow(t-r,2)/((t-e)*(t-o))},inv:function(r,e,t,o){return t<=e||o<e||o>t?NaN:r<=(o-e)/(t-e)?e+(t-e)*n.sqrt(r*((o-e)/(t-e))):e+(t-e)*(1-n.sqrt((1-r)*(1-(o-e)/(t-e))))},mean:function(r,n,e){return(r+n+e)/3},median:function(r,e,t){return t<=(r+e)/2?e-n.sqrt((e-r)*(e-t))/n.sqrt(2):t>(r+e)/2?r+n.sqrt((e-r)*(t-r))/n.sqrt(2):void 0},mode:function(r,n,e){return e},sample:function(e,t,o){var i=r._random_fn();return i<(o-e)/(t-e)?e+n.sqrt(i*(t-e)*(o-e)):t-n.sqrt((1-i)*(t-e)*(t-o))},variance:function(r,n,e){return(r*r+n*n+e*e-r*n-r*e-n*e)/18}}),r.extend(r.arcsine,{pdf:function(r,e,t){return t<=e?NaN:r<=e||r>=t?0:2/n.PI*n.pow(n.pow(t-e,2)-n.pow(2*r-e-t,2),-.5)},cdf:function(r,e,t){return r<e?0:r<t?2/n.PI*n.asin(n.sqrt((r-e)/(t-e))):1},inv:function(r,e,t){return e+(.5-.5*n.cos(n.PI*r))*(t-e)},mean:function(r,n){return n<=r?NaN:(r+n)/2},median:function(r,n){return n<=r?NaN:(r+n)/2},mode:function(){throw new Error("mode is not yet implemented")},sample:function(e,t){return(e+t)/2+(t-e)/2*n.sin(2*n.PI*r.uniform.sample(0,1))},variance:function(r,e){return e<=r?NaN:n.pow(e-r,2)/8}}),r.extend(r.laplace,{pdf:function(r,e,t){return t<=0?0:n.exp(-n.abs(r-e)/t)/(2*t)},cdf:function(r,e,t){return t<=0?0:r<e?.5*n.exp((r-e)/t):1-.5*n.exp(-(r-e)/t)},mean:function(r){return r},median:function(r){return r},mode:function(r){return r},variance:function(r,n){return 2*n*n},sample:function(e,t){var o,i=r._random_fn()-.5;return e-t*((o=i)/n.abs(o))*n.log(1-2*n.abs(i))}}),r.extend(r.tukey,{cdf:function(e,o,i){var u=o,a=[.9894009349916499,.9445750230732326,.8656312023878318,.755404408355003,.6178762444026438,.45801677765722737,.2816035507792589,.09501250983763744],s=[.027152459411754096,.062253523938647894,.09515851168249279,.12462897125553388,.14959598881657674,.16915651939500254,.18260341504492358,.1894506104550685];if(e<=0)return 0;if(i<2||u<2)return NaN;if(!Number.isFinite(e))return 1;if(i>25e3)return t(e,1,u);var c,l=.5*i,f=l*n.log(i)-i*n.log(2)-r.gammaln(l),m=l-1,h=.25*i;c=i<=100?1:i<=800?.5:i<=5e3?.25:.125,f+=n.log(c);for(var p=0,d=1;d<=50;d++){for(var g=0,v=(2*d-1)*c,y=1;y<=16;y++){var x,w;8<y?(x=y-8-1,w=f+m*n.log(v+a[x]*c)-(a[x]*c+v)*h):(x=y-1,w=f+m*n.log(v-a[x]*c)+(a[x]*c-v)*h),w>=-30&&(g+=t(8<y?e*n.sqrt(.5*(a[x]*c+v)):e*n.sqrt(.5*(-a[x]*c+v)),1,u)*s[x]*n.exp(w))}if(d*c>=1&&g<=1e-14)break;p+=g}if(g>1e-14)throw new Error("tukey.cdf failed to converge");return p>1&&(p=1),p},inv:function(e,t,o){if(o<2||t<2)return NaN;if(e<0||e>1)return NaN;if(0===e)return 0;if(1===e)return 1/0;var i,u=function(r,e,t){var o=.5-.5*r,i=n.sqrt(n.log(1/(o*o))),u=i+((((-453642210148e-16*i-.204231210125)*i-.342242088547)*i-1)*i+.322232421088)/((((.0038560700634*i+.10353775285)*i+.531103462366)*i+.588581570495)*i+.099348462606);t<120&&(u+=(u*u*u+u)/t/4);var a=.8832-.2368*u;return t<120&&(a+=-1.214/t+1.208*u/t),u*(a*n.log(e-1)+1.4142)}(e,t,o),a=r.tukey.cdf(u,t,o)-e;i=a>0?n.max(0,u-1):u+1;for(var s,c=r.tukey.cdf(i,t,o)-e,l=1;l<50;l++)if(s=i-c*(i-u)/(c-a),a=c,u=i,s<0&&(s=0,c=-e),c=r.tukey.cdf(s,t,o)-e,i=s,n.abs(i-u)<1e-4)return s;throw new Error("tukey.inv failed to converge")}})}(n,Math),function(r,n){var e,t,o=Array.prototype.push,i=r.utils.isArray;function u(n){return i(n)||n instanceof r}r.extend({add:function(n,e){return u(e)?(u(e[0])||(e=[e]),r.map(n,(function(r,n,t){return r+e[n][t]}))):r.map(n,(function(r){return r+e}))},subtract:function(n,e){return u(e)?(u(e[0])||(e=[e]),r.map(n,(function(r,n,t){return r-e[n][t]||0}))):r.map(n,(function(r){return r-e}))},divide:function(n,e){return u(e)?(u(e[0])||(e=[e]),r.multiply(n,r.inv(e))):r.map(n,(function(r){return r/e}))},multiply:function(n,e){var t,o,i,a,s,c,l,f;if(void 0===n.length&&void 0===e.length)return n*e;if(s=n.length,c=n[0].length,l=r.zeros(s,i=u(e)?e[0].length:c),f=0,u(e)){for(;f<i;f++)for(t=0;t<s;t++){for(a=0,o=0;o<c;o++)a+=n[t][o]*e[o][f];l[t][f]=a}return 1===s&&1===f?l[0][0]:l}return r.map(n,(function(r){return r*e}))},outer:function(n,e){return r.multiply(n.map((function(r){return[r]})),[e])},dot:function(n,e){u(n[0])||(n=[n]),u(e[0])||(e=[e]);for(var t,o,i=1===n[0].length&&1!==n.length?r.transpose(n):n,a=1===e[0].length&&1!==e.length?r.transpose(e):e,s=[],c=0,l=i.length,f=i[0].length;c<l;c++){for(s[c]=[],t=0,o=0;o<f;o++)t+=i[c][o]*a[c][o];s[c]=t}return 1===s.length?s[0]:s},pow:function(e,t){return r.map(e,(function(r){return n.pow(r,t)}))},exp:function(e){return r.map(e,(function(r){return n.exp(r)}))},log:function(e){return r.map(e,(function(r){return n.log(r)}))},abs:function(e){return r.map(e,(function(r){return n.abs(r)}))},norm:function(r,e){var t=0,o=0;for(isNaN(e)&&(e=2),u(r[0])&&(r=r[0]);o<r.length;o++)t+=n.pow(n.abs(r[o]),e);return n.pow(t,1/e)},angle:function(e,t){return n.acos(r.dot(e,t)/(r.norm(e)*r.norm(t)))},aug:function(r,n){var e,t=[];for(e=0;e<r.length;e++)t.push(r[e].slice());for(e=0;e<t.length;e++)o.apply(t[e],n[e]);return t},inv:function(n){for(var e,t=n.length,o=n[0].length,i=r.identity(t,o),u=r.gauss_jordan(n,i),a=[],s=0;s<t;s++)for(a[s]=[],e=o;e<u[0].length;e++)a[s][e-o]=u[s][e];return a},det:function r(n){if(2===n.length)return n[0][0]*n[1][1]-n[0][1]*n[1][0];for(var e=0,t=0;t<n.length;t++){for(var o=[],i=1;i<n.length;i++){o[i-1]=[];for(var u=0;u<n.length;u++)u<t?o[i-1][u]=n[i][u]:u>t&&(o[i-1][u-1]=n[i][u])}var a=t%2?-1:1;e+=r(o)*n[0][t]*a}return e},gauss_elimination:function(e,t){var o,i,u,a,s=0,c=0,l=e.length,f=e[0].length,m=1,h=0,p=[];for(o=(e=r.aug(e,t))[0].length,s=0;s<l;s++){for(i=e[s][s],c=s,a=s+1;a<f;a++)i<n.abs(e[a][s])&&(i=e[a][s],c=a);if(c!=s)for(a=0;a<o;a++)u=e[s][a],e[s][a]=e[c][a],e[c][a]=u;for(c=s+1;c<l;c++)for(m=e[c][s]/e[s][s],a=s;a<o;a++)e[c][a]=e[c][a]-m*e[s][a]}for(s=l-1;s>=0;s--){for(h=0,c=s+1;c<=l-1;c++)h+=p[c]*e[s][c];p[s]=(e[s][o-1]-h)/e[s][s]}return p},gauss_jordan:function(e,t){var o,i,u,a=r.aug(e,t),s=a.length,c=a[0].length,l=0;for(i=0;i<s;i++){var f=i;for(u=i+1;u<s;u++)n.abs(a[u][i])>n.abs(a[f][i])&&(f=u);var m=a[i];for(a[i]=a[f],a[f]=m,u=i+1;u<s;u++)for(l=a[u][i]/a[i][i],o=i;o<c;o++)a[u][o]-=a[i][o]*l}for(i=s-1;i>=0;i--){for(l=a[i][i],u=0;u<i;u++)for(o=c-1;o>i-1;o--)a[u][o]-=a[i][o]*a[u][i]/l;for(a[i][i]/=l,o=s;o<c;o++)a[i][o]/=l}return a},triaUpSolve:function(n,e){var t,o=n[0].length,i=r.zeros(1,o)[0],u=!1;return null!=e[0].length&&(e=e.map((function(r){return r[0]})),u=!0),r.arange(o-1,-1,-1).forEach((function(u){t=r.arange(u+1,o).map((function(r){return i[r]*n[u][r]})),i[u]=(e[u]-r.sum(t))/n[u][u]})),u?i.map((function(r){return[r]})):i},triaLowSolve:function(n,e){var t,o=n[0].length,i=r.zeros(1,o)[0],u=!1;return null!=e[0].length&&(e=e.map((function(r){return r[0]})),u=!0),r.arange(o).forEach((function(o){t=r.arange(o).map((function(r){return n[o][r]*i[r]})),i[o]=(e[o]-r.sum(t))/n[o][o]})),u?i.map((function(r){return[r]})):i},lu:function(n){var e,t=n.length,o=r.identity(t),i=r.zeros(n.length,n[0].length);return r.arange(t).forEach((function(r){i[0][r]=n[0][r]})),r.arange(1,t).forEach((function(u){r.arange(u).forEach((function(t){e=r.arange(t).map((function(r){return o[u][r]*i[r][t]})),o[u][t]=(n[u][t]-r.sum(e))/i[t][t]})),r.arange(u,t).forEach((function(t){e=r.arange(u).map((function(r){return o[u][r]*i[r][t]})),i[u][t]=n[e.length][t]-r.sum(e)}))})),[o,i]},cholesky:function(e){var t,o=e.length,i=r.zeros(e.length,e[0].length);return r.arange(o).forEach((function(u){t=r.arange(u).map((function(r){return n.pow(i[u][r],2)})),i[u][u]=n.sqrt(e[u][u]-r.sum(t)),r.arange(u+1,o).forEach((function(n){t=r.arange(u).map((function(r){return i[u][r]*i[n][r]})),i[n][u]=(e[u][n]-r.sum(t))/i[u][u]}))})),i},gauss_jacobi:function(e,t,o,i){for(var u,a,s,c,l=0,f=0,m=e.length,h=[],p=[],d=[];l<m;l++)for(h[l]=[],p[l]=[],d[l]=[],f=0;f<m;f++)l>f?(h[l][f]=e[l][f],p[l][f]=d[l][f]=0):l<f?(p[l][f]=e[l][f],h[l][f]=d[l][f]=0):(d[l][f]=e[l][f],h[l][f]=p[l][f]=0);for(s=r.multiply(r.multiply(r.inv(d),r.add(h,p)),-1),a=r.multiply(r.inv(d),t),u=o,c=r.add(r.multiply(s,o),a),l=2;n.abs(r.norm(r.subtract(c,u)))>i;)u=c,c=r.add(r.multiply(s,u),a),l++;return c},gauss_seidel:function(e,t,o,i){for(var u,a,s,c,l,f=0,m=e.length,h=[],p=[],d=[];f<m;f++)for(h[f]=[],p[f]=[],d[f]=[],u=0;u<m;u++)f>u?(h[f][u]=e[f][u],p[f][u]=d[f][u]=0):f<u?(p[f][u]=e[f][u],h[f][u]=d[f][u]=0):(d[f][u]=e[f][u],h[f][u]=p[f][u]=0);for(c=r.multiply(r.multiply(r.inv(r.add(d,h)),p),-1),s=r.multiply(r.inv(r.add(d,h)),t),a=o,l=r.add(r.multiply(c,o),s),f=2;n.abs(r.norm(r.subtract(l,a)))>i;)a=l,l=r.add(r.multiply(c,a),s),f+=1;return l},SOR:function(e,t,o,i,u){for(var a,s,c,l,f,m=0,h=e.length,p=[],d=[],g=[];m<h;m++)for(p[m]=[],d[m]=[],g[m]=[],a=0;a<h;a++)m>a?(p[m][a]=e[m][a],d[m][a]=g[m][a]=0):m<a?(d[m][a]=e[m][a],p[m][a]=g[m][a]=0):(g[m][a]=e[m][a],p[m][a]=d[m][a]=0);for(l=r.multiply(r.inv(r.add(g,r.multiply(p,u))),r.subtract(r.multiply(g,1-u),r.multiply(d,u))),c=r.multiply(r.multiply(r.inv(r.add(g,r.multiply(p,u))),t),u),s=o,f=r.add(r.multiply(l,o),c),m=2;n.abs(r.norm(r.subtract(f,s)))>i;)s=f,f=r.add(r.multiply(l,s),c),m++;return f},householder:function(e){for(var t,o,i,u,a=e.length,s=e[0].length,c=0,l=[],f=[];c<a-1;c++){for(t=0,u=c+1;u<s;u++)t+=e[u][c]*e[u][c];for(t=(e[c+1][c]>0?-1:1)*n.sqrt(t),o=n.sqrt((t*t-e[c+1][c]*t)/2),(l=r.zeros(a,1))[c+1][0]=(e[c+1][c]-t)/(2*o),i=c+2;i<a;i++)l[i][0]=e[i][c]/(2*o);f=r.subtract(r.identity(a,s),r.multiply(r.multiply(l,r.transpose(l)),2)),e=r.multiply(f,r.multiply(e,f))}return e},QR:(e=r.sum,t=r.arange,function(o){var i,u,a,s=o.length,c=o[0].length,l=r.zeros(c,c);for(o=r.copy(o),u=0;u<c;u++){for(l[u][u]=n.sqrt(e(t(s).map((function(r){return o[r][u]*o[r][u]})))),i=0;i<s;i++)o[i][u]=o[i][u]/l[u][u];for(a=u+1;a<c;a++)for(l[u][a]=e(t(s).map((function(r){return o[r][u]*o[r][a]}))),i=0;i<s;i++)o[i][a]=o[i][a]-o[i][u]*l[u][a]}return[o,l]}),lstsq:function(n,e){var t=!1;void 0===e[0].length&&(e=e.map((function(r){return[r]})),t=!0);var o=r.QR(n),i=o[0],u=o[1],a=n[0].length,s=r.slice(i,{col:{end:a}}),c=function(n){var e=(n=r.copy(n)).length,t=r.identity(e);return r.arange(e-1,-1,-1).forEach((function(e){r.sliceAssign(t,{row:e},r.divide(r.slice(t,{row:e}),n[e][e])),r.sliceAssign(n,{row:e},r.divide(r.slice(n,{row:e}),n[e][e])),r.arange(e).forEach((function(o){var i=r.multiply(n[o][e],-1),u=r.slice(n,{row:o}),a=r.multiply(r.slice(n,{row:e}),i);r.sliceAssign(n,{row:o},r.add(u,a));var s=r.slice(t,{row:o}),c=r.multiply(r.slice(t,{row:e}),i);r.sliceAssign(t,{row:o},r.add(s,c))}))})),t}(r.slice(u,{row:{end:a}})),l=r.transpose(s);void 0===l[0].length&&(l=[l]);var f=r.multiply(r.multiply(c,l),e);return void 0===f.length&&(f=[[f]]),t?f.map((function(r){return r[0]})):f},jacobi:function(e){for(var t,o,i,u,a,s,c,l=1,f=e.length,m=r.identity(f,f),h=[];1===l;){for(a=e[0][1],i=0,u=1,t=0;t<f;t++)for(o=0;o<f;o++)t!=o&&a<n.abs(e[t][o])&&(a=n.abs(e[t][o]),i=t,u=o);for(s=e[i][i]===e[u][u]?e[i][u]>0?n.PI/4:-n.PI/4:n.atan(2*e[i][u]/(e[i][i]-e[u][u]))/2,(c=r.identity(f,f))[i][i]=n.cos(s),c[i][u]=-n.sin(s),c[u][i]=n.sin(s),c[u][u]=n.cos(s),m=r.multiply(m,c),e=r.multiply(r.multiply(r.inv(c),e),c),l=0,t=1;t<f;t++)for(o=1;o<f;o++)t!=o&&n.abs(e[t][o])>.001&&(l=1)}for(t=0;t<f;t++)h.push(e[t][t]);return[m,h]},rungekutta:function(r,n,e,t,o,i){var u,a,s;if(2===i)for(;t<=e;)o+=((u=n*r(t,o))+(a=n*r(t+n,o+u)))/2,t+=n;if(4===i)for(;t<=e;)o+=((u=n*r(t,o))+2*(a=n*r(t+n/2,o+u/2))+2*(s=n*r(t+n/2,o+a/2))+n*r(t+n,o+s))/6,t+=n;return o},romberg:function(r,e,t,o){for(var i,u,a,s,c,l=0,f=(t-e)/2,m=[],h=[],p=[];l<o/2;){for(c=r(e),a=e,s=0;a<=t;a+=f,s++)m[s]=a;for(i=m.length,a=1;a<i-1;a++)c+=(a%2!=0?4:2)*r(m[a]);c=f/3*(c+r(t)),p[l]=c,f/=2,l++}for(u=p.length,i=1;1!==u;){for(a=0;a<u-1;a++)h[a]=(n.pow(4,i)*p[a+1]-p[a])/(n.pow(4,i)-1);u=h.length,p=h,h=[],i++}return p},richardson:function(r,e,t,o){function i(r,n){for(var e,t=0,o=r.length;t<o;t++)r[t]===n&&(e=t);return e}for(var u,a,s,c,l,f=n.abs(t-r[i(r,t)+1]),m=0,h=[],p=[];o>=f;)u=i(r,t+o),a=i(r,t),h[m]=(e[u]-2*e[a]+e[2*a-u])/(o*o),o/=2,m++;for(c=h.length,s=1;1!=c;){for(l=0;l<c-1;l++)p[l]=(n.pow(4,s)*h[l+1]-h[l])/(n.pow(4,s)-1);c=p.length,h=p,p=[],s++}return h},simpson:function(r,n,e,t){for(var o,i=(e-n)/t,u=r(n),a=[],s=n,c=0,l=1;s<=e;s+=i,c++)a[c]=s;for(o=a.length;l<o-1;l++)u+=(l%2!=0?4:2)*r(a[l]);return i/3*(u+r(e))},hermite:function(r,n,e,t){for(var o,i=r.length,u=0,a=0,s=[],c=[],l=[],f=[];a<i;a++){for(s[a]=1,o=0;o<i;o++)a!=o&&(s[a]*=(t-r[o])/(r[a]-r[o]));for(c[a]=0,o=0;o<i;o++)a!=o&&(c[a]+=1/(r[a]-r[o]));l[a]=(1-2*(t-r[a])*c[a])*(s[a]*s[a]),f[a]=(t-r[a])*(s[a]*s[a]),u+=l[a]*n[a]+f[a]*e[a]}return u},lagrange:function(r,n,e){for(var t,o,i=0,u=0,a=r.length;u<a;u++){for(o=n[u],t=0;t<a;t++)u!=t&&(o*=(e-r[t])/(r[u]-r[t]));i+=o}return i},cubic_spline:function(n,e,t){for(var o,i,u=n.length,a=0,s=[],c=[],l=[],f=[],m=[],h=[];a<u-1;a++)f[a]=n[a+1]-n[a];for(l[0]=0,a=1;a<u-1;a++)l[a]=3/f[a]*(e[a+1]-e[a])-3/f[a-1]*(e[a]-e[a-1]);for(a=1;a<u-1;a++)s[a]=[],c[a]=[],s[a][a-1]=f[a-1],s[a][a]=2*(f[a-1]+f[a]),s[a][a+1]=f[a],c[a][0]=l[a];for(i=r.multiply(r.inv(s),c),o=0;o<u-1;o++)m[o]=(e[o+1]-e[o])/f[o]-f[o]*(i[o+1][0]+2*i[o][0])/3,h[o]=(i[o+1][0]-i[o][0])/(3*f[o]);for(o=0;o<u&&!(n[o]>t);o++);return e[o-=1]+(t-n[o])*m[o]+r.sq(t-n[o])*i[o]+(t-n[o])*r.sq(t-n[o])*h[o]},gauss_quadrature:function(){throw new Error("gauss_quadrature not yet implemented")},PCA:function(n){var e,t,o,i,u,a=n.length,s=n[0].length,c=0,l=[],f=[],m=[],h=[],p=[],d=[],g=[];for(c=0;c<a;c++)l[c]=r.sum(n[c])/s;for(c=0;c<s;c++)for(p[c]=[],e=0;e<a;e++)p[c][e]=n[e][c]-l[e];for(p=r.transpose(p),c=0;c<a;c++)for(d[c]=[],e=0;e<a;e++)d[c][e]=r.dot([p[c]],[p[e]])/(s-1);for(u=(o=r.jacobi(d))[0],f=o[1],g=r.transpose(u),c=0;c<f.length;c++)for(e=c;e<f.length;e++)f[c]<f[e]&&(t=f[c],f[c]=f[e],f[e]=t,m=g[c],g[c]=g[e],g[e]=m);for(i=r.transpose(p),c=0;c<a;c++)for(h[c]=[],e=0;e<i.length;e++)h[c][e]=r.dot([g[c]],[i[e]]);return[n,f,g,h]}}),function(n){for(var e=0;e<n.length;e++)!function(n){r.fn[n]=function(e,t){var o=this;return t?(setTimeout((function(){t.call(o,r.fn[n].call(o,e))}),15),this):"number"==typeof r[n](this,e)?r[n](this,e):r(r[n](this,e))}}(n[e])}("add divide multiply subtract dot pow exp log abs norm angle".split(" "))}(n,Math),function(r,n){var e=[].slice,t=r.utils.isNumber,o=r.utils.isArray;function i(r,e,t,o){if(r>1||t>1||r<=0||t<=0)throw new Error("Proportions should be greater than 0 and less than 1");var i=(r*e+t*o)/(e+o);return(r-t)/n.sqrt(i*(1-i)*(1/e+1/o))}r.extend({zscore:function(){var n=e.call(arguments);return t(n[1])?(n[0]-n[1])/n[2]:(n[0]-r.mean(n[1]))/r.stdev(n[1],n[2])},ztest:function(){var t,i=e.call(arguments);return o(i[1])?(t=r.zscore(i[0],i[1],i[3]),1===i[2]?r.normal.cdf(-n.abs(t),0,1):2*r.normal.cdf(-n.abs(t),0,1)):i.length>2?(t=r.zscore(i[0],i[1],i[2]),1===i[3]?r.normal.cdf(-n.abs(t),0,1):2*r.normal.cdf(-n.abs(t),0,1)):(t=i[0],1===i[1]?r.normal.cdf(-n.abs(t),0,1):2*r.normal.cdf(-n.abs(t),0,1))}}),r.extend(r.fn,{zscore:function(r,n){return(r-this.mean())/this.stdev(n)},ztest:function(e,t,o){var i=n.abs(this.zscore(e,o));return 1===t?r.normal.cdf(-i,0,1):2*r.normal.cdf(-i,0,1)}}),r.extend({tscore:function(){var t=e.call(arguments);return 4===t.length?(t[0]-t[1])/(t[2]/n.sqrt(t[3])):(t[0]-r.mean(t[1]))/(r.stdev(t[1],!0)/n.sqrt(t[1].length))},ttest:function(){var o,i=e.call(arguments);return 5===i.length?(o=n.abs(r.tscore(i[0],i[1],i[2],i[3])),1===i[4]?r.studentt.cdf(-o,i[3]-1):2*r.studentt.cdf(-o,i[3]-1)):t(i[1])?(o=n.abs(i[0]),1==i[2]?r.studentt.cdf(-o,i[1]-1):2*r.studentt.cdf(-o,i[1]-1)):(o=n.abs(r.tscore(i[0],i[1])),1==i[2]?r.studentt.cdf(-o,i[1].length-1):2*r.studentt.cdf(-o,i[1].length-1))}}),r.extend(r.fn,{tscore:function(r){return(r-this.mean())/(this.stdev(!0)/n.sqrt(this.cols()))},ttest:function(e,t){return 1===t?1-r.studentt.cdf(n.abs(this.tscore(e)),this.cols()-1):2*r.studentt.cdf(-n.abs(this.tscore(e)),this.cols()-1)}}),r.extend({anovafscore:function(){var t,o,i,u,a,s,c,l,f=e.call(arguments);if(1===f.length){for(a=new Array(f[0].length),c=0;c<f[0].length;c++)a[c]=f[0][c];f=a}for(o=new Array,c=0;c<f.length;c++)o=o.concat(f[c]);for(i=r.mean(o),t=0,c=0;c<f.length;c++)t+=f[c].length*n.pow(r.mean(f[c])-i,2);for(t/=f.length-1,s=0,c=0;c<f.length;c++)for(u=r.mean(f[c]),l=0;l<f[c].length;l++)s+=n.pow(f[c][l]-u,2);return t/(s/(o.length-f.length))},anovaftest:function(){var n,o,i,u,a=e.call(arguments);if(t(a[0]))return 1-r.centralF.cdf(a[0],a[1],a[2]);var s=r.anovafscore(a);for(n=a.length-1,i=0,u=0;u<a.length;u++)i+=a[u].length;return o=i-n-1,1-r.centralF.cdf(s,n,o)},ftest:function(n,e,t){return 1-r.centralF.cdf(n,e,t)}}),r.extend(r.fn,{anovafscore:function(){return r.anovafscore(this.toArray())},anovaftes:function(){var n,e=0;for(n=0;n<this.length;n++)e+=this[n].length;return r.ftest(this.anovafscore(),this.length-1,e-this.length)}}),r.extend({qscore:function(){var o,i,u,a,s,c=e.call(arguments);return t(c[0])?(o=c[0],i=c[1],u=c[2],a=c[3],s=c[4]):(o=r.mean(c[0]),i=r.mean(c[1]),u=c[0].length,a=c[1].length,s=c[2]),n.abs(o-i)/(s*n.sqrt((1/u+1/a)/2))},qtest:function(){var n,t=e.call(arguments);3===t.length?(n=t[0],t=t.slice(1)):7===t.length?(n=r.qscore(t[0],t[1],t[2],t[3],t[4]),t=t.slice(5)):(n=r.qscore(t[0],t[1],t[2]),t=t.slice(3));var o=t[0],i=t[1];return 1-r.tukey.cdf(n,i,o-i)},tukeyhsd:function(n){for(var e=r.pooledstdev(n),t=n.map((function(n){return r.mean(n)})),o=n.reduce((function(r,n){return r+n.length}),0),i=[],u=0;u<n.length;++u)for(var a=u+1;a<n.length;++a){var s=r.qtest(t[u],t[a],n[u].length,n[a].length,e,o,n.length);i.push([[u,a],s])}return i}}),r.extend({normalci:function(){var t,o=e.call(arguments),i=new Array(2);return t=4===o.length?n.abs(r.normal.inv(o[1]/2,0,1)*o[2]/n.sqrt(o[3])):n.abs(r.normal.inv(o[1]/2,0,1)*r.stdev(o[2])/n.sqrt(o[2].length)),i[0]=o[0]-t,i[1]=o[0]+t,i},tci:function(){var t,o=e.call(arguments),i=new Array(2);return t=4===o.length?n.abs(r.studentt.inv(o[1]/2,o[3]-1)*o[2]/n.sqrt(o[3])):n.abs(r.studentt.inv(o[1]/2,o[2].length-1)*r.stdev(o[2],!0)/n.sqrt(o[2].length)),i[0]=o[0]-t,i[1]=o[0]+t,i},significant:function(r,n){return r<n}}),r.extend(r.fn,{normalci:function(n,e){return r.normalci(n,e,this.toArray())},tci:function(n,e){return r.tci(n,e,this.toArray())}}),r.extend(r.fn,{oneSidedDifferenceOfProportions:function(n,e,t,o){var u=i(n,e,t,o);return r.ztest(u,1)},twoSidedDifferenceOfProportions:function(n,e,t,o){var u=i(n,e,t,o);return r.ztest(u,2)}})}(n,Math),n.models=function(){function r(r,e){var t=r.length,o=e[0].length-1,i=t-o-1,u=n.lstsq(e,r),a=n.multiply(e,u.map((function(r){return[r]}))).map((function(r){return r[0]})),s=n.subtract(r,a),c=n.mean(r),l=n.sum(a.map((function(r){return Math.pow(r-c,2)}))),f=n.sum(r.map((function(r,n){return Math.pow(r-a[n],2)}))),m=l+f;return{exog:e,endog:r,nobs:t,df_model:o,df_resid:i,coef:u,predict:a,resid:s,ybar:c,SST:m,SSE:l,SSR:f,R2:l/m}}function e(e){var t,o,i=(t=e.exog,o=t[0].length,n.arange(o).map((function(e){var i=n.arange(o).filter((function(r){return r!==e}));return r(n.col(t,e).map((function(r){return r[0]})),n.col(t,i))}))),u=Math.sqrt(e.SSR/e.df_resid),a=i.map((function(r){var n=r.SST,e=r.R2;return u/Math.sqrt(n*(1-e))})),s=e.coef.map((function(r,n){return(r-0)/a[n]})),c=s.map((function(r){var t=n.studentt.cdf(r,e.df_resid);return 2*(t>.5?1-t:t)})),l=n.studentt.inv(.975,e.df_resid),f=e.coef.map((function(r,n){var e=l*a[n];return[r-e,r+e]}));return{se:a,t:s,p:c,sigmaHat:u,interval95:f}}return{ols:function(t,o){var i=r(t,o),u=e(i),a=function(r){var e,t,o,i=r.R2/r.df_model/((1-r.R2)/r.df_resid);return{F_statistic:i,pvalue:1-(e=i,t=r.df_model,o=r.df_resid,n.beta.cdf(e/(o/t+e),t/2,o/2))}}(i),s=1-(1-i.R2)*((i.nobs-1)/i.df_resid);return i.t=u,i.f=a,i.adjust_R2=s,i}}}(),n.extend({buildxmatrix:function(){for(var r=new Array(arguments.length),e=0;e<arguments.length;e++)r[e]=[1].concat(arguments[e]);return n(r)},builddxmatrix:function(){for(var r=new Array(arguments[0].length),e=0;e<arguments[0].length;e++)r[e]=[1].concat(arguments[0][e]);return n(r)},buildjxmatrix:function(r){for(var e=new Array(r.length),t=0;t<r.length;t++)e[t]=r[t];return n.builddxmatrix(e)},buildymatrix:function(r){return n(r).transpose()},buildjymatrix:function(r){return r.transpose()},matrixmult:function(r,e){var t,o,i,u,a;if(r.cols()==e.rows()){if(e.rows()>1){for(u=[],t=0;t<r.rows();t++)for(u[t]=[],o=0;o<e.cols();o++){for(a=0,i=0;i<r.cols();i++)a+=r.toArray()[t][i]*e.toArray()[i][o];u[t][o]=a}return n(u)}for(u=[],t=0;t<r.rows();t++)for(u[t]=[],o=0;o<e.cols();o++){for(a=0,i=0;i<r.cols();i++)a+=r.toArray()[t][i]*e.toArray()[o];u[t][o]=a}return n(u)}},regress:function(r,e){var t=n.xtranspxinv(r),o=r.transpose(),i=n.matrixmult(n(t),o);return n.matrixmult(i,e)},regresst:function(r,e,t){var o=n.regress(r,e),i={anova:{}},u=n.jMatYBar(r,o);i.yBar=u;var a=e.mean();i.anova.residuals=n.residuals(e,u),i.anova.ssr=n.ssr(u,a),i.anova.msr=i.anova.ssr/(r[0].length-1),i.anova.sse=n.sse(e,u),i.anova.mse=i.anova.sse/(e.length-(r[0].length-1)-1),i.anova.sst=n.sst(e,a),i.anova.mst=i.anova.sst/(e.length-1),i.anova.r2=1-i.anova.sse/i.anova.sst,i.anova.r2<0&&(i.anova.r2=0),i.anova.fratio=i.anova.msr/i.anova.mse,i.anova.pvalue=n.anovaftest(i.anova.fratio,r[0].length-1,e.length-(r[0].length-1)-1),i.anova.rmse=Math.sqrt(i.anova.mse),i.anova.r2adj=1-i.anova.mse/i.anova.mst,i.anova.r2adj<0&&(i.anova.r2adj=0),i.stats=new Array(r[0].length);for(var s,c,l,f=n.xtranspxinv(r),m=0;m<o.length;m++)s=Math.sqrt(i.anova.mse*Math.abs(f[m][m])),c=Math.abs(o[m]/s),l=n.ttest(c,e.length-r[0].length-1,t),i.stats[m]=[o[m],s,c,l];return i.regress=o,i},xtranspx:function(r){return n.matrixmult(r.transpose(),r)},xtranspxinv:function(r){var e=n.matrixmult(r.transpose(),r);return n.inv(e)},jMatYBar:function(r,e){var t=n.matrixmult(r,e);return new n(t)},residuals:function(r,e){return n.matrixsubtract(r,e)},ssr:function(r,n){for(var e=0,t=0;t<r.length;t++)e+=Math.pow(r[t]-n,2);return e},sse:function(r,n){for(var e=0,t=0;t<r.length;t++)e+=Math.pow(r[t]-n[t],2);return e},sst:function(r,n){for(var e=0,t=0;t<r.length;t++)e+=Math.pow(r[t]-n,2);return e},matrixsubtract:function(r,e){for(var t=new Array(r.length),o=0;o<r.length;o++){t[o]=new Array(r[o].length);for(var i=0;i<r[o].length;i++)t[o][i]=r[o][i]-e[o][i]}return n(t)}}),n.jStat=n,n)},184:(r,n,e)=>{"use strict";e.d(n,{$:()=>u});var t=e(976),o=e(870),i=e(559);class u extends t.JsViewer{constructor(r){super(),this.canvas=o.canvas(),this.gridCellStyle=t.GridCellStyle.create(),this.renderer=r,this.root.append(this.canvas),this.canvas.style.width="100%",this.canvas.style.height="100%",o.tools.handleResize(this.canvas,((r,n)=>{this.canvas.width=r,this.canvas.height=n,this.render()}));const n=r=>n=>{this.gridCell&&r(this.gridCell,n)};this.canvas.onmousemove=n(this.renderer.onMouseMove),this.canvas.onmouseenter=n(this.renderer.onMouseEnter),this.canvas.onmouseleave=n(this.renderer.onMouseLeave)}static fromGridCell(r){const n=new u(new i.cv);return n.gridCell=r,n.render(),n}render(){if(!this.gridCell)return;const r=this.canvas.getContext("2d");r.clearRect(0,0,this.canvas.width,this.canvas.height),this.renderer.renderInternal(r,0,0,this.canvas.width,this.canvas.height,this.gridCell.dart,this.gridCellStyle)}}},840:(r,n,e)=>{"use strict";e.d(n,{DI:()=>u}),e(976);var t=e(469),o=e(363),i=(e(875),e(414),function(r,n,e,t){return new(e||(e=Promise))((function(o,i){function u(r){try{s(t.next(r))}catch(r){i(r)}}function a(r){try{s(t.throw(r))}catch(r){i(r)}}function s(r){var n;r.done?o(r.value):(n=r.value,n instanceof e?n:new e((function(r){r(n)}))).then(u,a)}s((t=t.apply(r,n||[])).next())}))});function u(){return i(this,void 0,void 0,(function*(){t.shell.windows.showContextPanel=!0;const r=yield t.data.loadTable(`${o._package.webRoot}files/curves-demo.csv`);t.shell.addTableView(r)}))}},188:(r,n,e)=>{"use strict";e.d(n,{No:()=>g,Z:()=>x,hS:()=>d});var t=e(976),o=e(870),i=e(416),u=e(875),a=e(559),s=e(184),c=e(711),l=function(r,n,e,t){return new(e||(e=Promise))((function(o,i){function u(r){try{s(t.next(r))}catch(r){i(r)}}function a(r){try{s(t.throw(r))}catch(r){i(r)}}function s(r){var n;r.done?o(r.value):(n=r.value,n instanceof e?n:new e((function(r){r(n)}))).then(u,a)}s((t=t.apply(r,n||[])).next())}))};const f="chartOptions",m="seriesOptions";var h;!function(r){r.DATAFRAME="Dataframe",r.COLUMN="Column",r.CELL="Cell"}(h||(h={}));const p={count:"totalCount",nulls:"missingValueCount",unique:"uniqueCount",values:"valueCount",min:"min",max:"max",sum:"sum",avg:"avg",stdev:"stdev",variance:"variance",skew:"skew",kurt:"kurt",med:"med",q1:"q1",q2:"q2",q3:"q3"};function d(r,n){const e=(0,i.Y6)(r);return r.parameters?n.logX&&r.parameters[2]>0&&(r.parameters[2]=Math.log10(r.parameters[2])):r.parameters=(0,i.PK)(r,e,n).parameters,(0,i.tq)(r,e,n)}function g(r,n){var e,o,i;const u={logX:null===(e=r.chartOptions)||void 0===e?void 0:e.logX,logY:null===(o=r.chartOptions)||void 0===o?void 0:o.logY},a=[],s=[],c=[],l=[],f=[],m=[],h=[];for(let n=0,e=0;n<(null===(i=r.series)||void 0===i?void 0:i.length);n++){if(r.series[n].points.every((r=>r.outlier)))continue;const t=d(r.series[n],u);a[e]=t.rSquared,s[e]=t.auc,c[e]=t.interceptX,l[e]=t.interceptY,f[e]=t.slope,m[e]=t.top,h[e]=t.bottom,e++}return{rSquared:t.Stats.fromValues(a)[p[n]],auc:t.Stats.fromValues(s)[p[n]],interceptX:t.Stats.fromValues(c)[p[n]],interceptY:t.Stats.fromValues(l)[p[n]],slope:t.Stats.fromValues(f)[p[n]],top:t.Stats.fromValues(m)[p[n]],bottom:t.Stats.fromValues(h)[p[n]]}}function v(r){for(let n=0;n<r.length;n++){const e=r.get(n);if(""===e)continue;const t=(0,c.f)(e);r.set(n,JSON.stringify(t))}r.setTag(a.Rj,"")}function y(r,n,e,t){var o;void 0===r.cell.column.temp[`${f}-custom-title`]&&function(r){var n,e;const t=r.columns.bySemTypeAll(u.j2);for(let r=0;r<t.length;r++){u.kW.map((n=>{t[r].temp[`${f}-custom-${n.name}`]=!1})),u.K0.map((n=>{t[r].temp[`${m}-custom-${n.name}`]=!1})),t[r].getTag(a.Rj)===a.NH&&v(t[r]);for(let o=0;o<t[r].length;o++){if(""===t[r].get(o))continue;const i=null!==(e=JSON.parse(null!==(n=t[r].get(o))&&void 0!==n?n:"{}"))&&void 0!==e?e:{};u.kW.map((n=>{i.chartOptions&&void 0!==i.chartOptions[n.name]&&(t[r].temp[`${f}-custom-${n.name}`]=!0)})),u.K0.map((n=>{if(i.series)for(const e of i.series)void 0!==e[n.name]&&(t[r].temp[`${m}-custom-${n.name}`]=!0)}))}}}(r.cell.dataFrame);const s=n.property.name,c=t===h.DATAFRAME?(0,i.jG)(r.cell.dataFrame):(0,i.hq)(r.cell.column);if(e===f?c.chartOptions[s]=n.value:e===m&&(c.seriesOptions[s]=n.value),t===h.CELL){const t=r.cell.value;if(""===t)return;const i=null!==(o=JSON.parse(null!=t?t:"{}"))&&void 0!==o?o:{};!function(r,n,e){const t=n.property.name;if(e===f){if(void 0===r.chartOptions)return;r.chartOptions[t]=n.value}else if(e===m){if(void 0===r.series)return;for(let e=0;e<r.series.length;e++)r.series[e][t]=n.value}}(i,n,e),r.cell.value=JSON.stringify(i)}else{let n;t===h.DATAFRAME?(r.cell.dataFrame.tags[u.Kp]=JSON.stringify(c),n=r.cell.dataFrame.columns.bySemTypeAll(u.j2)):(r.cell.column.tags[u.Kp]=JSON.stringify(c),n=[r.cell.column]);for(let r=0;r<n.length;r++){if(t===h.DATAFRAME){const t=(0,i.hq)(n[r]);e===f?delete t.chartOptions[s]:delete t.seriesOptions[s],n[r].tags[u.Kp]=JSON.stringify(t)}!1!==n[r].temp[`${e}-custom-${s}`]&&(n[r].init((t=>{var o,i;const u=n[r].get(t);if(""===u)return u;const a=null!==(i=JSON.parse(null!==(o=n[r].get(t))&&void 0!==o?o:"{}"))&&void 0!==i?i:{};if(e===f){if(void 0===a.chartOptions)return u;if(void 0===a.chartOptions[s])return u;delete a.chartOptions[s]}else{if(void 0===a.series)return u;let r=!1;for(const n of a.series)void 0!==n[s]&&(delete n[s],r=!0);if(a.seriesOptions&&delete a.seriesOptions[s],!r)return u}return JSON.stringify(a)})),n[r].temp[`${e}-custom-${s}`]=!1)}}r.grid.invalidate()}class x extends t.ObjectHandler{get type(){return"GridCell"}isApplicable(r){return r instanceof t.GridCell&&r.cellType===u.d8}renderProperties(r,n=null){var e,c,h,p,v,x,w,b,T,_,M;const A=o.accordion("Curves property panel"),C=t.Property.js("level",t.TYPE.STRING,{description:"Controls the level at which properties will be switched",defaultValue:"Column",choices:["Dataframe","Column","Cell"],nullable:!1}),S=o.input.forProperty(C);o.tooltip.bind(S.captionLabel,"Controls the level at which properties will be switched");const k=(0,a.W$)(r),O=(0,i.hq)(r.cell.column),P=(0,i.jG)(r.cell.dataFrame),N={onValueChanged:n=>y(r,n,m,S.value)},j={onValueChanged:n=>y(r,n,f,S.value)};(0,a.fi)(null===(e=P.seriesOptions)||void 0===e?void 0:e.pointColor)||(0,a.fi)(null===(c=O.seriesOptions)||void 0===c?void 0:c.pointColor)||(k.seriesOptions?(0,a.fi)(k.seriesOptions.pointColor)||(k.seriesOptions.pointColor=t.Color.toHtml(t.Color.getCategoricalColor(0))):(0,a.fi)(k.series?k.series[0].pointColor:"")||(k.series[0].pointColor=t.Color.toHtml(t.Color.getCategoricalColor(0)))),(0,a.fi)(null===(h=P.seriesOptions)||void 0===h?void 0:h.fitLineColor)||(0,a.fi)(null===(p=O.seriesOptions)||void 0===p?void 0:p.fitLineColor)||(k.seriesOptions?(0,a.fi)(k.seriesOptions.fitLineColor)||(k.seriesOptions.fitLineColor=t.Color.toHtml(t.Color.getCategoricalColor(0))):(0,a.fi)(k.series?k.series[0].fitLineColor:"")||(k.series[0].fitLineColor=t.Color.toHtml(t.Color.getCategoricalColor(0)))),(0,a.fi)(null===(v=P.seriesOptions)||void 0===v?void 0:v.outlierColor)||(0,a.fi)(null===(x=O.seriesOptions)||void 0===x?void 0:x.outlierColor)||(k.seriesOptions?(0,a.fi)(k.seriesOptions.outlierColor)||(k.seriesOptions.outlierColor=t.Color.toHtml(t.Color.red)):(0,a.fi)(k.series?k.series[0].outlierColor:"")||(k.series[0].outlierColor=t.Color.toHtml(t.Color.red))),(0,a.BI)(u.K0,O.seriesOptions,k.seriesOptions?k.seriesOptions:k.series&&null!==(w=k.series[0])&&void 0!==w?w:{}),(0,a.BI)(u.K0,P.seriesOptions,k.seriesOptions?k.seriesOptions:k.series&&null!==(b=k.series[0])&&void 0!==b?b:{}),(0,a.BI)(u.kW,O.chartOptions,k.chartOptions?k.chartOptions:{}),(0,a.BI)(u.kW,P.chartOptions,k.chartOptions?k.chartOptions:{}),(null===(T=k.chartOptions)||void 0===T?void 0:T.allowXZeroes)&&(null===(_=k.chartOptions)||void 0===_?void 0:_.logX)&&(null===(M=k.series)||void 0===M?void 0:M.some((r=>r.points.some((r=>0===r.x)))))&&(0,a.kb)(k);const q=o.form([S]),R=u.K0.map((r=>o.input.forProperty(r,k.seriesOptions?k.seriesOptions:k.series[0],N)));o.forms.addGroup(q,"Series options",R),o.forms.addGroup(q,"Chart options",u.kW.map((r=>o.input.forProperty(r,k.chartOptions,j)))),A.addPane("Options",(()=>q));const E=t.Property.js("series",t.TYPE.STRING,{description:"Controls whether to show series statistics or aggregated statistics",defaultValue:"All",choices:["all","aggregated"],nullable:!1}),Y=o.input.forProperty(E,null,{onValueChanged(r){A.getPane("Fit").root.lastElementChild.replaceChildren(L())}}),V=t.Property.js("aggregation type",t.TYPE.STRING,{description:"Controls which aggregation to use on the series statistics",defaultValue:"med",choices:Object.values(t.STATS),nullable:!1}),F=o.input.forProperty(V,null,{onValueChanged(r){A.getPane("Fit").root.lastElementChild.replaceChildren(L())}});function L(){var n,e,a;const s=o.divV("aggregated"===Y.stringValue?[Y.root,F.root]:[Y.root]),c=(0,i.dU)(k);if(c.x<=0&&k.chartOptions&&(k.chartOptions.logX=!1),c.y<=0&&k.chartOptions&&(k.chartOptions.logY=!1),"all"===Y.stringValue){const i={logX:null===(n=k.chartOptions)||void 0===n?void 0:n.logX,logY:null===(e=k.chartOptions)||void 0===e?void 0:e.logY};for(let n=0;n<k.series.length;n++){const e=k.series[n],c=d(e,i),f=e.fitLineColor&&t.Color.fromHtml(e.fitLineColor)?e.fitLineColor:t.Color.toHtml(t.Color.getCategoricalColor(n));s.appendChild(o.panel([o.h1(null!==(a=e.name)&&void 0!==a?a:"series "+n,{style:{color:f}}),o.input.form(c,u.sw,{onCreated:i=>i.root.appendChild(o.iconFA("plus",(()=>l(this,void 0,void 0,(function*(){const o={df:r.cell.dataFrame,colName:r.gridColumn.name,propName:i.property.name,seriesName:e.name,seriesNumber:n};yield t.Func.find({name:"addStatisticsColumn"})[0].prepare(o).call(void 0,void 0,{processed:!1})}))),`Calculate ${i.property.name} for the whole column`))})]))}}else{const n=g(k,F.stringValue);s.appendChild(o.panel([o.h1(`series ${F.stringValue}`),o.input.form(n,u.sw,{onCreated:n=>n.root.appendChild(o.iconFA("plus",(()=>l(this,void 0,void 0,(function*(){const e={df:r.cell.dataFrame,colName:r.gridColumn.name,propName:n.property.name,aggrType:F.stringValue};yield t.Func.find({name:"addAggrStatisticsColumn"})[0].prepare(e).call(void 0,void 0,{processed:!1})}))),`Calculate ${n.property.name} ${F.stringValue} for the whole column`))})]))}return s}return A.addPane("Fit",(()=>L())),A.addPane("Chart",(()=>s.$.fromGridCell(r).root)),A.root}}},711:(r,n,e)=>{"use strict";e.d(n,{f:()=>c});var t=e(976),o=e(875);const i={x:"xAxis",y:"yAxis"},u={min:"min",max:"max"};function a(r){var n,e,i;const u=null===(e=null===(n=r.getElementsByTagName("params")[0])||void 0===n?void 0:n.childNodes[0].nodeValue)||void 0===e?void 0:e.split(",").map(Number);let a=null===(i=r.getElementsByTagName("function")[0])||void 0===i?void 0:i.getAttribute("type");a=a&&"sigif"!==a?a:o.yB;const s=r.getElementsByTagName("settings")[0].getAttribute("markerColor"),c=r.getElementsByTagName("settings")[0].getAttribute("color"),l=!!r.getElementsByTagName("settings")[0].getAttribute("drawLine"),f={name:r.getAttribute("name"),fitFunction:a,markerType:t.MARKER_TYPE.CIRCLE,pointColor:s,fitLineColor:c,showFitLine:l,showPoints:"points",showCurveConfidenceInterval:!1,clickToToggle:!1};return u&&(f.parameters=[u[2],u[1],u[0],u[3]]),f}function s(r){const n=function(r){var n,e,t;const o=null===(n=r.getElementsByTagName("x")[0].childNodes[0].nodeValue)||void 0===n?void 0:n.split(","),i=null===(e=r.getElementsByTagName("y")[0].childNodes[0].nodeValue)||void 0===e?void 0:e.split(","),u=null===(t=r.getElementsByTagName("mask")[0].childNodes[0].nodeValue)||void 0===t?void 0:t.split(""),a=[];for(let r=0;r<o.length;r++)a[r]={x:+o[r],y:+i[r],outlier:!Boolean(u[r])};return a}(r),e=a(r),t={points:n};return Object.assign(t,e),t}function c(r){const n=(new DOMParser).parseFromString(r,"text/xml"),e=n.getElementsByTagName("grid")[0],t=(c=n.getElementsByTagName("settings")[0],{minX:+(o=e).getElementsByTagName(i.x)[0].getAttribute(u.min),minY:+o.getElementsByTagName(i.y)[0].getAttribute(u.min),maxX:+o.getElementsByTagName(i.x)[0].getAttribute(u.max),maxY:+o.getElementsByTagName(i.y)[0].getAttribute(u.max),xAxisName:c.getAttribute("xLabel"),yAxisName:c.getAttribute("yLabel"),logX:!!c.getAttribute("logX")});var o,c;const l=n.getElementsByTagName("seriesCollection")[0],f=a(l.getElementsByTagName("series")[0]),m=function(r){const n=[],e=r.getElementsByTagName("series").length;for(let t=0;t<e;t++){const e=r.getElementsByTagName("series")[t];n[t]=s(e)}return n}(l);return{chartOptions:t,seriesOptions:f,series:m}}},559:(r,n,e)=>{"use strict";e.d(n,{cv:()=>E,Rj:()=>g,NH:()=>v,W$:()=>M,fi:()=>C,BI:()=>_,kb:()=>R});var t=e(976),o=e(469),i=e(870),u=e(875),a=e(111),s=e(766);const c=window,l=new Intl.NumberFormat("en-US",{minimumFractionDigits:2,maximumFractionDigits:2});class f{static getUniqueName(r,n,e){return c.grok_Utils_GetUniqueName(r,n,null==e?void 0:e.auto,null==e?void 0:e.idx,null==e?void 0:e.render,null==e?void 0:e.choices)}static isEmpty(r){return null==r||""==r}static formatNumber(r){return l.format(r)}}var m=e(416),h=e(711),p=e(184),d=e(188);const g=".fitChartFormat",v="3dx",y=100,x=18,w=4,b=3.5,T={solid:[],dotted:[1,1],dashed:[5,5],dashdotted:[5,5,2,5]};function _(r,n,e){if(n&&e)for(const t of r)!(t.name in e)&&t.name in n&&(e[t.name]=n[t.name])}function M(r){var n,e,o,i,a;let s=r.cell.value;s.includes("|")&&(s=s.replaceAll("|",""));const c=(null===(e=null===(n=r.cell)||void 0===n?void 0:n.column)||void 0===e?void 0:e.type)===t.TYPE.STRING?r.cell.column.getTag(g)===v?(0,h.f)(s):null!==(o=JSON.parse(null!=s?s:"{}"))&&void 0!==o?o:{}:(0,m.TL)(),l=r.cell.column?(0,m.hq)(r.cell.column):{},f=r.cell.column?(0,m.jG)(r.cell.dataFrame):{};null!==(i=c.series)&&void 0!==i||(c.series=[]),null!==(a=c.chartOptions)&&void 0!==a||(c.chartOptions=l.chartOptions),_(u.kW,l.chartOptions,c.chartOptions),_(u.kW,f.chartOptions,c.chartOptions);for(const r of c.series)_(u.K0,l.seriesOptions,r),_(u.K0,f.seriesOptions,r);return c}function A(r,n,e){if(r.width<y||r.height<55)return[r,void 0,void 0];const t=n?45:38,o=n?30:15,i=e?25:5;return[r.cutLeft(t).cutBottom(o).cutTop(i).cutRight(x),r.getBottom(o).getTop(i).cutLeft(t).cutRight(x),r.getLeft(t).getRight(x).cutBottom(o).cutTop(i)]}function C(r){return null!=r&&""!==r&&void 0!==t.Color.fromHtml(r)}function S(r,n,e,t){r.moveTo(t.xToScreen(n)-w/2,t.yToScreen(e)),r.lineTo(t.xToScreen(n)+w/2,t.yToScreen(e))}function k(r,n,e,o,i,u){S(r,n,e.lowerAdjacentValue,o),r.moveTo(o.xToScreen(n),o.yToScreen(e.lowerAdjacentValue)),r.lineTo(o.xToScreen(n),o.yToScreen(e.upperAdjacentValue)),S(r,n,e.upperAdjacentValue,o),t.Paint.marker(r,t.MARKER_TYPE.CIRCLE,o.xToScreen(n),o.yToScreen(e.q2),u,b*i)}function O(r,n,e,o,i,u,a){for(let i=0;i<n.points.length;i++){const s=n.points[i],c=s.outlier?s.outlierColor&&t.Color.fromHtml(s.outlierColor)?t.Color.fromHtml(s.outlierColor):a:s.color&&t.Color.fromHtml(s.color)?t.Color.fromHtml(s.color):u,l=s.marker?s.marker:n.markerType,f=s.outlier?12*o:s.size?s.size:4*o;t.Paint.marker(r,s.outlier?t.MARKER_TYPE.OUTLIER:l,e.xToScreen(s.x),e.yToScreen(s.y),c,f),s.stdev&&!s.outlier&&(r.strokeStyle=t.Color.toHtml(c),r.beginPath(),r.moveTo(e.xToScreen(s.x),e.yToScreen(s.y+s.stdev)),r.lineTo(e.xToScreen(s.x),e.yToScreen(s.y-s.stdev)),r.stroke())}}function P(r,n,e,o,i){for(let u=0,s=null;u<n.points.length;u++){const c=n.points[u];if(c.outlier)continue;const l=u+1<n.points.length&&n.points[u+1].x===c.x;if(!s&&l)s=u;else if(null!==s&&!l){const l=[];for(let r=s,e=0;r<=u;r++,e++)l[e]=n.points[r].y;const f=(0,a.G)(l);if(r.beginPath(),k(r,c.x,f,e,o,i),r.stroke(),"both"===n.showPoints)for(let i=0;i<l.length;i++)(l[i]<f.lowerAdjacentValue||l[i]>f.upperAdjacentValue)&&t.Paint.marker(r,t.MARKER_TYPE.OUTLIER,e.xToScreen(c.x),e.yToScreen(l[i]),n.pointColor?t.Color.fromHtml(n.pointColor):t.Color.scatterPlotMarker,6*o);s=null}}}function N(r,n,e,t,o,i,a,s){r.beginPath();const c=i?a?45:38:0,l=i?x:0,f=o===u.vK.TOP?n.confidenceTop:n.confidenceBottom;for(let n=c;n<=e.width-l;n++){const o=e.x+n,i=s.logX?Math.log10(t.xToWorld(o)):t.xToWorld(o),u=s.logY?t.yToScreen(Math.pow(10,f(i))):t.yToScreen(f(i));n===c?r.moveTo(o,u):r.lineTo(o,u)}r.stroke()}function j(r,n,e,t,o,i,u){r.beginPath();const a=o?i?45:38:0,s=o?x:0;for(let o=a;o<=e.width-s;o++){const i=e.x+o,s=u.logX?Math.log10(t.xToWorld(i)):t.xToWorld(i),c=u.logY?t.yToScreen(Math.pow(10,n.confidenceTop(s))):t.yToScreen(n.confidenceTop(s));o===a?r.moveTo(i,c):r.lineTo(i,c)}for(let o=e.width-s;o>=a;o--){const i=e.x+o,a=u.logX?Math.log10(t.xToWorld(i)):t.xToWorld(i),s=u.logY?t.yToScreen(Math.pow(10,n.confidenceBottom(a))):t.yToScreen(n.confidenceBottom(a));r.lineTo(i,s)}r.closePath(),r.fill()}function q(r,n,e,t,o,i){i.logX&&(e=Math.pow(10,e));const u=i.logX?Math.log10(e):e,a=i.logY?Math.pow(10,o(u)):o(u);r.moveTo(n.xToScreen(t.minX),n.yToScreen(a)),r.lineTo(n.xToScreen(e),n.yToScreen(a)),r.lineTo(n.xToScreen(e),n.yToScreen(t.minY))}function R(r){var n;for(let e=0;e<(null===(n=r.series)||void 0===n?void 0:n.length);e++){const n=r.series[e];if(n.points.every((r=>0!==r.x)))continue;let t=Number.MAX_VALUE,o=0,i=0;const u=[];for(let r=0;r<n.points.length;r++)n.points[r].x<t&&0!==n.points[r].x&&(t=n.points[r].x),n.points[r].x>o&&0!==n.points[r].x&&(o=n.points[r].x),u.includes(n.points[r].x)||(u[u.length]=n.points[r].x,i++);const a=Math.pow(10,Math.log10(t)-(Math.log10(o)-Math.log10(t)/(i-1)));for(let r=0;r<n.points.length;r++)0===n.points[r].x&&(n.points[r].x=a)}}class E extends t.GridCellRenderer{get name(){return u.d8}get cellType(){return u.d8}getDefaultSize(r){return{width:220,height:150}}onClick(r,n){var e,t,i,u,a,c,l,f;if(!r.cell.value)return;const p=r.cell.column.getTag(g)===v?(0,h.f)(r.cell.value):M(r);if(null===(e=p.series)||void 0===e?void 0:e.some((r=>0===r.points.length)))return;o.shell.o=r;const x=r.bounds.inflate(-6,-6),w=A(x,r.bounds.width>=180&&r.bounds.height>=140,r.bounds.width>=275&&r.bounds.height>=225)[0],b=(0,m.dU)(p),T=new s.l(b,w,null!==(i=null===(t=p.chartOptions)||void 0===t?void 0:t.logX)&&void 0!==i&&i,null!==(a=null===(u=p.chartOptions)||void 0===u?void 0:u.logY)&&void 0!==a&&a);for(let e=0;e<(null===(c=p.series)||void 0===c?void 0:c.length);e++)if(!(!p.series[e].clickToToggle||"points"!==p.series[e].showPoints||x.width<y||x.height<55))for(let t=0;t<p.series[e].points.length;t++){const o=p.series[e].points[t],i=T.xToScreen(o.x),u=T.yToScreen(o.y),a=(o.outlier?12:4)/2+2;if(n.offsetX>=i-a&&n.offsetX<=i+a&&n.offsetY>=u-a&&n.offsetY<=u+a){o.outlier=!o.outlier;const n=r.grid.dataFrame.columns.byTags({".sourceColumn":r.cell.column.name});if(n)for(const t of n){const n={logX:null===(l=p.chartOptions)||void 0===l?void 0:l.logX,logY:null===(f=p.chartOptions)||void 0===f?void 0:f.logY},o=null!==t.tags[".seriesAggregation"]?(0,d.No)(p,t.tags[".seriesAggregation"]):t.tags[".seriesNumber"]===e?(0,d.hS)(p.series[e],n):null;null!==o&&t.set(r.cell.rowIndex,o[t.tags[".statistics"]])}if(r.cell.column.getTag(g)!==v){const n=JSON.parse(r.cell.value);n.series[e].points[t].outlier=o.outlier,r.cell.value=JSON.stringify(n)}return}}}onDoubleClick(r,n){if(!r.cell.value)return;const e=p.$.fromGridCell(r),t=i.dialog({title:"Edit chart"}).add(e.root).show({resizable:!0}).root.getElementsByClassName("d4-dialog-contents dlg-edit-chart")[0].firstChild;e.canvas.width=t.clientWidth,e.canvas.height=t.clientHeight,e.render(),t.style.width="100%",t.style.height="100%",i.tools.handleResize(t,((r,n)=>{e.canvas.width=r,e.canvas.height=n,e.render()}))}renderCurves(r,n,e,o,i,a){var c,l,h,p,d,g,v,w,b,_,M,C,S,k,E,Y,V,F,L,X,I,B,D,G,U;r.save(),r.beginPath(),r.rect(n,e,o,i),r.clip(),(null===(c=a.chartOptions)||void 0===c?void 0:c.allowXZeroes)&&(null===(l=a.chartOptions)||void 0===l?void 0:l.logX)&&(null===(h=a.series)||void 0===h?void 0:h.some((r=>r.points.some((r=>0===r.x)))))&&R(a);const W=new t.Rect(n,e,o,i).inflate(-6,-6),H=W.width>=y&&W.height>=55,$=o>=180&&i>=140&&!!(null===(p=a.chartOptions)||void 0===p?void 0:p.xAxisName)&&!!a.chartOptions.yAxisName,z=o>=275&&i>=225&&!!(null===(d=a.chartOptions)||void 0===d?void 0:d.title),K=o>=120&&i>=110,[Q,Z,J]=A(W,$,z),rr=(0,m.dU)(a);(rr.x<0&&a.chartOptions||0===rr.x&&a.chartOptions&&!a.chartOptions.allowXZeroes)&&(a.chartOptions.logX=!1),rr.y<=0&&a.chartOptions&&(a.chartOptions.logY=!1);const nr=new s.l(rr,Q,null!==(v=null===(g=a.chartOptions)||void 0===g?void 0:g.logX)&&void 0!==v&&v,null!==(b=null===(w=a.chartOptions)||void 0===w?void 0:w.logY)&&void 0!==b&&b),er=Math.min(Q.width,Q.height),tr=er>100?1:.2+er/100*.8,or={logX:null===(_=a.chartOptions)||void 0===_?void 0:_.logX,logY:null===(M=a.chartOptions)||void 0===M?void 0:M.logY};r.save(),r.font='11px Roboto, "Roboto Local"',nr.drawCoordinateGrid(r,Z,J),r.restore();for(let n=0;n<(null===(C=a.series)||void 0===C?void 0:C.length);n++){const e=a.series[n];if(e.points.some((r=>void 0===r.x||void 0===r.y)))continue;(o<70||i<45)&&(e.showPoints="",a.chartOptions&&(a.chartOptions.showStatistics=[])),e.points.sort(((r,n)=>r.x-n.x));let s=!0;const c=(0,m.Y6)(e);let l;if(e.parameters)(null===(S=a.chartOptions)||void 0===S?void 0:S.logX)&&e.parameters[2]>0&&(e.parameters[2]=Math.log10(e.parameters[2])),l=(0,m.kG)(e,c);else{const r=(0,m.PK)(e,c,or);l=r.fittedCurve,e.parameters=r.parameters,s=!1}if(null===(k=e.showPoints)||void 0===k||k){const o=e.pointColor&&t.Color.fromHtml(e.pointColor)?e.pointColor:t.Color.toHtml(t.Color.getCategoricalColor(n)),i=e.outlierColor&&t.Color.fromHtml(e.outlierColor)?t.Color.fromHtml(e.outlierColor):t.Color.red;r.strokeStyle=o,"points"===e.showPoints?O(r,e,nr,tr,0,t.Color.fromHtml(o),i):["candlesticks","both"].includes(e.showPoints)&&P(r,e,nr,tr,t.Color.fromHtml(o))}if(null===(E=e.showFitLine)||void 0===E||E){const o=e.fitLineColor&&t.Color.fromHtml(e.fitLineColor)?e.fitLineColor:t.Color.toHtml(t.Color.getCategoricalColor(n));r.save(),r.strokeStyle=o,r.lineWidth=2*tr,r.beginPath(),e.lineStyle&&r.setLineDash(T[e.lineStyle]);const i=H?$?45:38:0,u=H?x:0;for(let n=i;n<=W.width-u;n++){const e=W.x+n,t=(null===(Y=a.chartOptions)||void 0===Y?void 0:Y.logX)?Math.log10(nr.xToWorld(e)):nr.xToWorld(e),o=(null===(V=a.chartOptions)||void 0===V?void 0:V.logY)?nr.yToScreen(Math.pow(10,l(t))):nr.yToScreen(l(t));n===i?r.moveTo(e,o):r.lineTo(e,o)}r.stroke(),r.restore()}if((null===(F=e.showFitLine)||void 0===F||F)&&null!==(L=e.showCurveConfidenceInterval)&&void 0!==L&&L){r.strokeStyle=null!==(X=e.confidenceIntervalColor)&&void 0!==X?X:u.Qc,r.fillStyle=null!==(I=e.confidenceIntervalColor)&&void 0!==I?I:u.XD;const n=(0,m.LC)(e,c,s,or);N(r,n,W,nr,u.vK.TOP,H,$,or),N(r,n,W,nr,u.vK.BOTTOM,H,$,or),j(r,n,W,nr,H,$,or)}if(e.droplines&&K){r.save(),r.strokeStyle="blue",r.lineWidth=tr,r.beginPath(),r.setLineDash([5,5]);for(let n=0;n<e.droplines.length;n++)"IC50"===e.droplines[n]&&q(r,nr,e.parameters[2],rr,l,or);r.stroke(),r.restore()}if(null===(B=a.chartOptions)||void 0===B?void 0:B.showStatistics){const o=(0,m.tq)(e,c,or);for(let i=0;i<a.chartOptions.showStatistics.length;i++){const s=a.chartOptions.showStatistics[i],c=u.sw.find((r=>r.name===s));if(c){const u=f.formatNumber(c.get(o)),a=e.fitLineColor&&t.Color.fromHtml(e.fitLineColor)?e.fitLineColor:t.Color.toHtml(t.Color.getCategoricalColor(n));r.fillStyle=a,r.textAlign="left",r.fillText(c.name+": "+u,Q.x+5,Q.y+20+20*i)}}}}if(z&&(r.font='12px Roboto, "Roboto Local"',r.textAlign="center",r.fillStyle="black",r.fillText(null===(D=a.chartOptions)||void 0===D?void 0:D.title,Q.midX-5,e+15)),$){r.font='11px Roboto, "Roboto Local"',r.textAlign="center",r.fillStyle="black",r.fillText(null===(G=a.chartOptions)||void 0===G?void 0:G.xAxisName,Q.midX-5,e+i-10),r.translate(n,e),r.rotate(-Math.PI/2);const t=z?25:5;r.fillText(null===(U=a.chartOptions)||void 0===U?void 0:U.yAxisName,-(Q.height/2+t+15),15),r.restore()}r.restore()}render(r,n,e,t,o,i,u){var a,s;if(t<20||o<10)return;if(!i.cell.value)return;const c=(null===(a=i.cell.column)||void 0===a?void 0:a.getTag(g))===v?(0,h.f)(i.cell.value):M(i);(null===(s=c.series)||void 0===s?void 0:s.some((r=>0===r.points.length)))||this.renderCurves(r,n,e,t,o,c)}onMouseMove(r,n){var e,t,o,u,a;if(!r.cell.value)return;if(r.bounds.width<70||r.bounds.height<45){const e=i.canvas(300,200);this.render(e.getContext("2d"),0,0,300,200,r,null);const t=i.divV([e]);i.tooltip.show(t,n.x,n.y)}const c=r.cell.column.getTag(g)===v?(0,h.f)(r.cell.value):M(r),l=r.bounds.inflate(-6,-6),f=A(l,r.bounds.width>=180&&r.bounds.height>=140,r.bounds.width>=275&&r.bounds.height>=225)[0],p=(0,m.dU)(c),d=new s.l(p,f,null!==(t=null===(e=c.chartOptions)||void 0===e?void 0:e.logX)&&void 0!==t&&t,null!==(u=null===(o=c.chartOptions)||void 0===o?void 0:o.logY)&&void 0!==u&&u);for(let r=0;r<(null===(a=c.series)||void 0===a?void 0:a.length);r++)if(!(!c.series[r].clickToToggle||"points"!==c.series[r].showPoints||l.width<y||l.height<55))for(let e=0;e<c.series[r].points.length;e++){const t=c.series[r].points[e],o=d.xToScreen(t.x),i=d.yToScreen(t.y),u=(t.outlier?12:4)/2+2;if(n.offsetX>=o-u&&n.offsetX<=o+u&&n.offsetY>=i-u&&n.offsetY<=i+u)return void(document.body.style.cursor="pointer")}document.body.style.cursor="default"}}},363:(r,n,e)=>{"use strict";e.r(n),e.d(n,{_FitViewer:()=>b,_initCurves:()=>_,_package:()=>d,addAggrStatisticsColumn:()=>A,addStatisticsColumn:()=>M,curveFitDemo:()=>T,fitCellRenderer:()=>w});var t=e(976),o=e(188),i=e(559),u=e(870),a=e(184),s=e(875);const c=rxjs.operators,l=rxjs;class f extends a.${constructor(){super(new i.cv),this.showSelectedRowsCurves=!1,this.showCurrentRowCurve=!0,this.showMouseOverRowCurve=!0,this.rows=[],this.data=new s.cY,this.curvesColumnName=this.column("curves"),this.showSelectedRowsCurves=this.bool("showSelectedRowsCurves",!1,{description:"Adds curves from the selected rows"}),this.showCurrentRowCurve=this.bool("showCurrentRowCurve",!0),this.showMouseOverRowCurve=this.bool("showMouseOverRowCurve",!0);for(const r of s.kW)this.addProperty(r.name,r.propertyType,r.defaultValue,r.options)}static fromChartData(r){let n=new f;return n.data=r,n.render(),n}applyViewerProperties(){(0,i.BI)(s.kW,this,this.data.chartOptions)}createChartData(){var r,n;if(!this.curvesColumnName)return;this.rows.length=0,this.showCurrentRowCurve&&-1!==this.dataFrame.currentRowIdx&&this.rows.push(this.dataFrame.currentRowIdx),this.showMouseOverRowCurve&&-1!==this.dataFrame.mouseOverRowIdx&&this.rows.push(this.dataFrame.mouseOverRowIdx),this.showSelectedRowsCurves&&-1!==this.dataFrame.mouseOverRowIdx&&this.rows.push(...this.dataFrame.selection.getSelectedIndexes()),this.data=new s.cY;const e=null===(r=this.tableView)||void 0===r?void 0:r.grid;for(let r of this.rows){const t=(0,i.W$)(e.cell(this.curvesColumnName,e.tableRowToGrid(r)));null===(n=this.data.series)||void 0===n||n.push(...t.series)}}onPropertyChanged(r){this.applyViewerProperties(),this.render()}onTableAttached(){var r,n,e;const t=null===(r=this.tableView)||void 0===r?void 0:r.grid;null!==(n=this.curvesColumnName)&&void 0!==n||(this.curvesColumnName=null===(e=this.dataFrame.columns.bySemType(s.j2))||void 0===e?void 0:e.name),(0,l.merge)(this.dataFrame.onCurrentCellChanged,t.onCellMouseEnter,this.dataFrame.onSelectionChanged).pipe((0,c.debounce)((r=>(0,l.interval)(50)))).subscribe((r=>{this.createChartData(),this.render()}))}_showErrorMessage(r){this.root.appendChild(u.divText(r,"d4-viewer-error"))}render(){if(!this.curvesColumnName)return void this._showErrorMessage("The MultiCurveViewer viewer requires a minimum of 1 curves column.");const r=this.canvas.getContext("2d");r.clearRect(0,0,this.canvas.width,this.canvas.height),this.renderer.renderCurves(r,0,0,this.canvas.width,this.canvas.height,this.data)}}var m=e(840),h=e(711),p=function(r,n,e,t){return new(e||(e=Promise))((function(o,i){function u(r){try{s(t.next(r))}catch(r){i(r)}}function a(r){try{s(t.throw(r))}catch(r){i(r)}}function s(r){var n;r.done?o(r.value):(n=r.value,n instanceof e?n:new e((function(r){r(n)}))).then(u,a)}s((t=t.apply(r,n||[])).next())}))};const d=new t.Package,g=".sourceColumn",v=".seriesNumber",y=".seriesAggregation",x=".statistics";function w(){return new i.cv}function b(){return new f}function T(){return p(this,void 0,void 0,(function*(){yield(0,m.DI)()}))}function _(){t.ObjectHandler.register(new o.Z)}function M(r,n,e,u,a){var s;const c=t.Viewer.grid(r),l=c.col(n),f=t.Column.float(`${n}_${u}_${e}`,null===(s=l.column)||void 0===s?void 0:s.length);f.tags[g]=n,f.tags[v]=a,f.tags[x]=e,f.init((r=>{var u,s,l,f,m;const p=t.GridCell.fromColumnRow(c,n,c.tableRowToGrid(r));if(""===p.cell.value)return null;const d=p.cell.column.getTag(i.Rj)===i.NH?(0,h.f)(p.cell.value):(0,i.W$)(p);if(void 0===d.series[a]||d.series[a].points.every((r=>r.outlier)))return null;(null===(u=d.chartOptions)||void 0===u?void 0:u.allowXZeroes)&&(null===(s=d.chartOptions)||void 0===s?void 0:s.logX)&&(null===(l=d.series)||void 0===l?void 0:l.some((r=>r.points.some((r=>0===r.x)))))&&(0,i.kb)(d);const g={logX:null===(f=d.chartOptions)||void 0===f?void 0:f.logX,logY:null===(m=d.chartOptions)||void 0===m?void 0:m.logY};return(0,o.hS)(d.series[a],g)[e]})),r.columns.insert(f,l.idx)}function A(r,n,e,u){var a;const s=t.Viewer.grid(r),c=s.col(n),l=t.Column.float(`${n}_${u}_${e}`,null===(a=c.column)||void 0===a?void 0:a.length);l.tags[g]=n,l.tags[y]=u,l.tags[x]=e,l.init((r=>{var a,c,l,f;const m=t.GridCell.fromColumnRow(s,n,s.tableRowToGrid(r));if(""===m.cell.value)return null;const p=m.cell.column.getTag(i.Rj)===i.NH?(0,h.f)(m.cell.value):(0,i.W$)(m);return(null===(a=p.series)||void 0===a?void 0:a.every((r=>r.points.every((r=>r.outlier)))))?null:((null===(c=p.chartOptions)||void 0===c?void 0:c.allowXZeroes)&&(null===(l=p.chartOptions)||void 0===l?void 0:l.logX)&&(null===(f=p.series)||void 0===f?void 0:f.some((r=>r.points.some((r=>0===r.x)))))&&(0,i.kb)(p),(0,o.No)(p,u)[e])})),r.columns.insert(l,c.idx)}},976:r=>{"use strict";r.exports=DG},469:r=>{"use strict";r.exports=grok},870:r=>{"use strict";r.exports=ui},414:r=>{"use strict";r.exports=wu}},__webpack_module_cache__={};function __webpack_require__(r){var n=__webpack_module_cache__[r];if(void 0!==n)return n.exports;var e=__webpack_module_cache__[r]={exports:{}};return __webpack_modules__[r].call(e.exports,e,e.exports,__webpack_require__),e.exports}__webpack_require__.n=r=>{var n=r&&r.__esModule?()=>r.default:()=>r;return __webpack_require__.d(n,{a:n}),n},__webpack_require__.d=(r,n)=>{for(var e in n)__webpack_require__.o(n,e)&&!__webpack_require__.o(r,e)&&Object.defineProperty(r,e,{enumerable:!0,get:n[e]})},__webpack_require__.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(r){if("object"==typeof window)return window}}(),__webpack_require__.o=(r,n)=>Object.prototype.hasOwnProperty.call(r,n),__webpack_require__.r=r=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})};var __webpack_exports__=__webpack_require__(363);curves=__webpack_exports__})();
1
+ var curves;(()=>{var __webpack_modules__={78:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{"use strict";function copyInto(r,e){for(var n=0;n<e.length;n++)r[n]=e[n]}function limitedMemoryBFGS(r,e){var n=+new Date,t=e.length,o=numeric.rep([t],0);r.getGradient(e,o);var i=numeric.clone(o),u=numeric.clone(e),a=numeric.clone(o);numeric.diveq(a,numeric.norm2(a));var s=[],c=[],l=[],f=(backtrackingLineSearch(r,a,o,e),r.getValue(e));o=r.getGradient(e,o);for(var m=f,h=0;h<100;h++){var d;if(new Date,s.length<4)s.unshift(numeric.sub(e,u)),c.unshift(numeric.sub(o,i));else{for(var p=s.pop(),g=c.pop(),v=0;v<t;v++)p[v]=e[v]-u[v],g[v]=o[v]-i[v];s.unshift(p),c.unshift(g)}copyInto(u,e),copyInto(i,o);var y=0,x=0;for(v=0;v<t;v++)y+=s[0][v]*c[0][v],x+=c[0][v]*c[0][v];var w=y/x;l.unshift(1/y),copyInto(a,o);for(var b=[],T=0;T<s.length;T++){var C=0;for(v=0;v<t;v++)C+=s[T][v]*a[v];for(C*=l[T],b.push(C),v=0;v<t;v++)a[v]+=c[T][v]*-C}for(v=0;v<t;v++)a[v]*=w;for(T=s.length-1;T>=0;T--){var M=0;for(v=0;v<t;v++)M+=c[T][v]*a[v];for(M*=l[T],C=b[T],v=0;v<t;v++)a[v]+=s[T][v]*(C-M)}for(v=0;v<t;v++)a[v]=-a[v];if(backtrackingLineSearch(r,a,o,e),f=r.getValue(e),o=r.getGradient(e,o),2*(f-m)<=1e-4*(Math.abs(f)+Math.abs(m)+1e-5))return d=+new Date,!0;var _=numeric.norm2(o);if(_<.001)return d=+new Date,!0;if(0==_)return d=+new Date,!0;m=f}return d=+new Date,console.log("Finished iterations "+(d-n)),!0}function backtrackingLineSearch(r,e,n,t){var o=t.length,i=0,u=1,a=0,s=r.getValue(t),c=s,l=numeric.norm2(e);l>100&&numeric.muleq(e,100/l);for(var f=0,m=0;m<o;m++)f+=n[m]*e[m];var h=0;for(m=0;m<o;m++){var d=Math.abs(e[m]/Math.max(Math.abs(t[m]),1));d>h&&(h=d)}for(var p=1e-4/h,g=0;g<25;g++){for(m=0;m<o;m++)t[m]+=(u-i)*e[m];if(u<p)return 0;var v=r.getValue(t);if(v>=s+1e-4*u*f)return u;if(isFinite(v))if(1==u)a=-f/(2*(v-s-f));else{var y=v-s-u*f,x=c-s-i*f,w=1/(u*u),b=1/(i*i),T=1/(u-i),C=T*(y*w-x*b),M=T*(-y*i*w+x*u*b);if(0==C)a=-f/(2*M);else{var _=M*M-3*C*f;a=_<0?.5*u:M<=0?(-M+Math.sqrt(_))/(3*C):-f/(M+Math.sqrt(_))}a>.5*u&&(a=.5*u)}else a=.2*u;c=v,i=u,u=Math.max(a,.1*u)}}__webpack_require__.d(__webpack_exports__,{U:()=>limitedMemoryBFGS});var quadratic={getValue:function(r){var e=r[0],n=r[1];return-3*e*e-4*n*n+2*e-4*n+18},getGradient:function(r,e){return e[0]=-6*r[0]+2,e[1]=-8*r[1]-4,e}};function doubleExp(r){for(var e=Array(r),n=0;n<r;n++)e[n]=Math.log(Math.random())*(Math.random()>.5?1:-1);return e}var ridgeRegression={covariates:[],responses:[],originalParameters:doubleExp(100),sample:function(r,e){for(var n=0;n<r;n++){var t=doubleExp(100);this.responses.push(numeric.dot(t,this.originalParameters)+e()),this.covariates.push(t)}},getValue:function(r){for(var e=0,n=0;n<this.covariates.length;n++){var t=this.responses[n]-numeric.dot(this.covariates[n],r);e+=-.5*t*t}return e},getGradient:function(r,e){for(var n=0;n<this.covariates.length;n++){var t=this.responses[n]-numeric.dot(this.covariates[n],r);numeric.addeq(e,numeric.mul(this.covariates[n],t))}return e}},numeric="undefined"==typeof exports?function(){}:exports;void 0!==__webpack_require__.g&&(__webpack_require__.g.numeric=numeric),numeric.version="1.2.6",numeric.bench=function(r,e){var n,t,o;for(void 0===e&&(e=15),t=.5,n=new Date;;){for(o=t*=2;o>3;o-=4)r(),r(),r(),r();for(;o>0;)r(),o--;if(new Date-n>e)break}for(o=t;o>3;o-=4)r(),r(),r(),r();for(;o>0;)r(),o--;return 1e3*(3*t-1)/(new Date-n)},numeric._myIndexOf=function(r){var e,n=this.length;for(e=0;e<n;++e)if(this[e]===r)return e;return-1},numeric.myIndexOf=Array.prototype.indexOf?Array.prototype.indexOf:numeric._myIndexOf,numeric.Function=Function,numeric.precision=4,numeric.largeArray=50,numeric.prettyPrint=function(r){function e(r){if(0===r)return"0";if(isNaN(r))return"NaN";if(r<0)return"-"+e(-r);if(isFinite(r)){var n=Math.floor(Math.log(r)/Math.log(10)),t=r/Math.pow(10,n),o=t.toPrecision(numeric.precision);return 10===parseFloat(o)&&(n++,o=(t=1).toPrecision(numeric.precision)),parseFloat(o).toString()+"e"+n.toString()}return"Infinity"}var n=[];return function r(t){var o;if(void 0===t)return n.push(Array(numeric.precision+8).join(" ")),!1;if("string"==typeof t)return n.push('"'+t+'"'),!1;if("boolean"==typeof t)return n.push(t.toString()),!1;if("number"==typeof t){var i=e(t),u=t.toPrecision(numeric.precision),a=parseFloat(t.toString()).toString(),s=[i,u,a,parseFloat(u).toString(),parseFloat(a).toString()];for(o=1;o<s.length;o++)s[o].length<i.length&&(i=s[o]);return n.push(Array(numeric.precision+8-i.length).join(" ")+i),!1}if(null===t)return n.push("null"),!1;if("function"==typeof t){n.push(t.toString());var c=!1;for(o in t)t.hasOwnProperty(o)&&(c?n.push(",\n"):n.push("\n{"),c=!0,n.push(o),n.push(": \n"),r(t[o]));return c&&n.push("}\n"),!0}if(t instanceof Array){if(t.length>numeric.largeArray)return n.push("...Large Array..."),!0;for(c=!1,n.push("["),o=0;o<t.length;o++)o>0&&(n.push(","),c&&n.push("\n ")),c=r(t[o]);return n.push("]"),!0}for(o in n.push("{"),c=!1,t)t.hasOwnProperty(o)&&(c&&n.push(",\n"),c=!0,n.push(o),n.push(": \n"),r(t[o]));return n.push("}"),!0}(r),n.join("")},numeric.parseDate=function(r){return function r(e){if("string"==typeof e)return Date.parse(e.replace(/-/g,"/"));if(e instanceof Array){var n,t=[];for(n=0;n<e.length;n++)t[n]=r(e[n]);return t}throw new Error("parseDate: parameter must be arrays of strings")}(r)},numeric.parseFloat=function(r){return function r(e){if("string"==typeof e)return parseFloat(e);if(e instanceof Array){var n,t=[];for(n=0;n<e.length;n++)t[n]=r(e[n]);return t}throw new Error("parseFloat: parameter must be arrays of strings")}(r)},numeric.parseCSV=function(r){var e,n,t,o=r.split("\n"),i=[],u=/(([^'",]*)|('[^']*')|("[^"]*")),/g,a=/^\s*(([+-]?[0-9]+(\.[0-9]*)?(e[+-]?[0-9]+)?)|([+-]?[0-9]*(\.[0-9]+)?(e[+-]?[0-9]+)?))\s*$/,s=0;for(n=0;n<o.length;n++){var c,l=(o[n]+",").match(u);if(l.length>0){for(i[s]=[],e=0;e<l.length;e++)c=(t=l[e]).substr(0,t.length-1),a.test(c)?i[s][e]=parseFloat(c):i[s][e]=c;s++}}return i},numeric.toCSV=function(r){var e,n,t,o,i,u=numeric.dim(r);for(t=u[0],u[1],i=[],e=0;e<t;e++){for(o=[],n=0;n<t;n++)o[n]=r[e][n].toString();i[e]=o.join(", ")}return i.join("\n")+"\n"},numeric.getURL=function(r){var e=new XMLHttpRequest;return e.open("GET",r,!1),e.send(),e},numeric.imageURL=function(r){function e(r,e,n){void 0===e&&(e=0),void 0===n&&(n=r.length);var t,o=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117],i=-1;for(r.length,t=e;t<n;t++)i=i>>>8^o[255&(i^r[t])];return-1^i}var n,t,o,i,u,a,s,c,l,f,m=r[0].length,h=r[0][0].length,d=[137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,h>>24&255,h>>16&255,h>>8&255,255&h,m>>24&255,m>>16&255,m>>8&255,255&m,8,2,0,0,0,-1,-2,-3,-4,-5,-6,-7,-8,73,68,65,84,8,29];for(f=e(d,12,29),d[29]=f>>24&255,d[30]=f>>16&255,d[31]=f>>8&255,d[32]=255&f,n=1,t=0,s=0;s<m;s++){for(s<m-1?d.push(0):d.push(1),u=3*h+1+(0===s)&255,a=3*h+1+(0===s)>>8&255,d.push(u),d.push(a),d.push(255&~u),d.push(255&~a),0===s&&d.push(0),c=0;c<h;c++)for(o=0;o<3;o++)t=(t+(n=(n+(u=(u=r[o][s][c])>255?255:u<0?0:Math.round(u)))%65521))%65521,d.push(u);d.push(0)}return l=(t<<16)+n,d.push(l>>24&255),d.push(l>>16&255),d.push(l>>8&255),d.push(255&l),i=d.length-41,d[33]=i>>24&255,d[34]=i>>16&255,d[35]=i>>8&255,d[36]=255&i,f=e(d,37),d.push(f>>24&255),d.push(f>>16&255),d.push(f>>8&255),d.push(255&f),d.push(0),d.push(0),d.push(0),d.push(0),d.push(73),d.push(69),d.push(78),d.push(68),d.push(174),d.push(66),d.push(96),d.push(130),"data:image/png;base64,"+function(r){var e,n,t,o,i,u,a,s=r.length,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l="";for(e=0;e<s;e+=3)i=((3&(n=r[e]))<<4)+((t=r[e+1])>>4),u=((15&t)<<2)+((o=r[e+2])>>6),a=63&o,e+1>=s?u=a=64:e+2>=s&&(a=64),l+=c.charAt(n>>2)+c.charAt(i)+c.charAt(u)+c.charAt(a);return l}(d)},numeric._dim=function(r){for(var e=[];"object"==typeof r;)e.push(r.length),r=r[0];return e},numeric.dim=function(r){var e;return"object"==typeof r?"object"==typeof(e=r[0])?"object"==typeof e[0]?numeric._dim(r):[r.length,e.length]:[r.length]:[]},numeric.mapreduce=function(r,e){return Function("x","accum","_s","_k",'if(typeof accum === "undefined") accum = '+e+';\nif(typeof x === "number") { var xi = x; '+r+'; return accum; }\nif(typeof _s === "undefined") _s = numeric.dim(x);\nif(typeof _k === "undefined") _k = 0;\nvar _n = _s[_k];\nvar i,xi;\nif(_k < _s.length-1) {\n for(i=_n-1;i>=0;i--) {\n accum = arguments.callee(x[i],accum,_s,_k+1);\n } return accum;\n}\nfor(i=_n-1;i>=1;i-=2) { \n xi = x[i];\n '+r+";\n xi = x[i-1];\n "+r+";\n}\nif(i === 0) {\n xi = x[i];\n "+r+"\n}\nreturn accum;")},numeric.mapreduce2=function(r,e){return Function("x","var n = x.length;\nvar i,xi;\n"+e+";\nfor(i=n-1;i!==-1;--i) { \n xi = x[i];\n "+r+";\n}\nreturn accum;")},numeric.same=function r(e,n){var t,o;if(e instanceof Array&&n instanceof Array){if((o=e.length)!==n.length)return!1;for(t=0;t<o;t++)if(e[t]!==n[t]){if("object"!=typeof e[t])return!1;if(!r(e[t],n[t]))return!1}return!0}return!1},numeric.rep=function(r,e,n){void 0===n&&(n=0);var t,o=r[n],i=Array(o);if(n===r.length-1){for(t=o-2;t>=0;t-=2)i[t+1]=e,i[t]=e;return-1===t&&(i[0]=e),i}for(t=o-1;t>=0;t--)i[t]=numeric.rep(r,e,n+1);return i},numeric.dotMMsmall=function(r,e){var n,t,o,i,u,a,s,c,l,f,m;for(i=r.length,u=e.length,a=e[0].length,s=Array(i),n=i-1;n>=0;n--){for(c=Array(a),l=r[n],o=a-1;o>=0;o--){for(f=l[u-1]*e[u-1][o],t=u-2;t>=1;t-=2)m=t-1,f+=l[t]*e[t][o]+l[m]*e[m][o];0===t&&(f+=l[0]*e[0][o]),c[o]=f}s[n]=c}return s},numeric._getCol=function(r,e,n){var t;for(t=r.length-1;t>0;--t)n[t]=r[t][e],n[--t]=r[t][e];0===t&&(n[0]=r[0][e])},numeric.dotMMbig=function(r,e){var n,t,o,i=numeric._getCol,u=e.length,a=Array(u),s=r.length,c=e[0].length,l=new Array(s),f=numeric.dotVV;for(--u,t=--s;-1!==t;--t)l[t]=Array(c);for(t=--c;-1!==t;--t)for(i(e,t,a),o=s;-1!==o;--o)n=r[o],l[o][t]=f(n,a);return l},numeric.dotMV=function(r,e){var n,t=r.length,o=(e.length,Array(t)),i=numeric.dotVV;for(n=t-1;n>=0;n--)o[n]=i(r[n],e);return o},numeric.dotVM=function(r,e){var n,t,o,i,u,a,s;for(o=r.length,i=e[0].length,u=Array(i),t=i-1;t>=0;t--){for(a=r[o-1]*e[o-1][t],n=o-2;n>=1;n-=2)s=n-1,a+=r[n]*e[n][t]+r[s]*e[s][t];0===n&&(a+=r[0]*e[0][t]),u[t]=a}return u},numeric.dotVV=function(r,e){var n,t,o=r.length,i=r[o-1]*e[o-1];for(n=o-2;n>=1;n-=2)t=n-1,i+=r[n]*e[n]+r[t]*e[t];return 0===n&&(i+=r[0]*e[0]),i},numeric.dot=function(r,e){var n=numeric.dim;switch(1e3*n(r).length+n(e).length){case 2002:return e.length<10?numeric.dotMMsmall(r,e):numeric.dotMMbig(r,e);case 2001:return numeric.dotMV(r,e);case 1002:return numeric.dotVM(r,e);case 1001:return numeric.dotVV(r,e);case 1e3:return numeric.mulVS(r,e);case 1:return numeric.mulSV(r,e);case 0:return r*e;default:throw new Error("numeric.dot only works on vectors and matrices")}},numeric.diag=function(r){var e,n,t,o,i=r.length,u=Array(i);for(e=i-1;e>=0;e--){for(o=Array(i),n=e+2,t=i-1;t>=n;t-=2)o[t]=0,o[t-1]=0;for(t>e&&(o[t]=0),o[e]=r[e],t=e-1;t>=1;t-=2)o[t]=0,o[t-1]=0;0===t&&(o[0]=0),u[e]=o}return u},numeric.getDiag=function(r){var e,n=Math.min(r.length,r[0].length),t=Array(n);for(e=n-1;e>=1;--e)t[e]=r[e][e],t[--e]=r[e][e];return 0===e&&(t[0]=r[0][0]),t},numeric.identity=function(r){return numeric.diag(numeric.rep([r],1))},numeric.pointwise=function(r,e,n){void 0===n&&(n="");var t,o,i=[],u=/\[i\]$/,a="",s=!1;for(t=0;t<r.length;t++)u.test(r[t])?a=o=r[t].substring(0,r[t].length-3):o=r[t],"ret"===o&&(s=!0),i.push(o);return i[r.length]="_s",i[r.length+1]="_k",i[r.length+2]='if(typeof _s === "undefined") _s = numeric.dim('+a+');\nif(typeof _k === "undefined") _k = 0;\nvar _n = _s[_k];\nvar i'+(s?"":", ret = Array(_n)")+";\nif(_k < _s.length-1) {\n for(i=_n-1;i>=0;i--) ret[i] = arguments.callee("+r.join(",")+",_s,_k+1);\n return ret;\n}\n"+n+"\nfor(i=_n-1;i!==-1;--i) {\n "+e+"\n}\nreturn ret;",Function.apply(null,i)},numeric.pointwise2=function(r,e,n){void 0===n&&(n="");var t,o,i=[],u=/\[i\]$/,a="",s=!1;for(t=0;t<r.length;t++)u.test(r[t])?a=o=r[t].substring(0,r[t].length-3):o=r[t],"ret"===o&&(s=!0),i.push(o);return i[r.length]="var _n = "+a+".length;\nvar i"+(s?"":", ret = Array(_n)")+";\n"+n+"\nfor(i=_n-1;i!==-1;--i) {\n"+e+"\n}\nreturn ret;",Function.apply(null,i)},numeric._biforeach=function r(e,n,t,o,i){var u;if(o!==t.length-1)for(u=t[o]-1;u>=0;u--)r("object"==typeof e?e[u]:e,"object"==typeof n?n[u]:n,t,o+1,i);else i(e,n)},numeric._biforeach2=function r(e,n,t,o,i){if(o===t.length-1)return i(e,n);var u,a=t[o],s=Array(a);for(u=a-1;u>=0;--u)s[u]=r("object"==typeof e?e[u]:e,"object"==typeof n?n[u]:n,t,o+1,i);return s},numeric._foreach=function r(e,n,t,o){var i;if(t!==n.length-1)for(i=n[t]-1;i>=0;i--)r(e[i],n,t+1,o);else o(e)},numeric._foreach2=function r(e,n,t,o){if(t===n.length-1)return o(e);var i,u=n[t],a=Array(u);for(i=u-1;i>=0;i--)a[i]=r(e[i],n,t+1,o);return a},numeric.ops2={add:"+",sub:"-",mul:"*",div:"/",mod:"%",and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">=",band:"&",bor:"|",bxor:"^",lshift:"<<",rshift:">>",rrshift:">>>"},numeric.opseq={addeq:"+=",subeq:"-=",muleq:"*=",diveq:"/=",modeq:"%=",lshifteq:"<<=",rshifteq:">>=",rrshifteq:">>>=",bandeq:"&=",boreq:"|=",bxoreq:"^="},numeric.mathfuns=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan","isNaN","isFinite"],numeric.mathfuns2=["atan2","pow","max","min"],numeric.ops1={neg:"-",not:"!",bnot:"~",clone:""},numeric.mapreducers={any:["if(xi) return true;","var accum = false;"],all:["if(!xi) return false;","var accum = true;"],sum:["accum += xi;","var accum = 0;"],prod:["accum *= xi;","var accum = 1;"],norm2Squared:["accum += xi*xi;","var accum = 0;"],norminf:["accum = max(accum,abs(xi));","var accum = 0, max = Math.max, abs = Math.abs;"],norm1:["accum += abs(xi)","var accum = 0, abs = Math.abs;"],sup:["accum = max(accum,xi);","var accum = -Infinity, max = Math.max;"],inf:["accum = min(accum,xi);","var accum = Infinity, min = Math.min;"]},function(){var r,e;for(r=0;r<numeric.mathfuns2.length;++r)e=numeric.mathfuns2[r],numeric.ops2[e]=e;for(r in numeric.ops2)if(numeric.ops2.hasOwnProperty(r)){e=numeric.ops2[r];var n,t,o="";-1!==numeric.myIndexOf.call(numeric.mathfuns2,r)?(o="var "+e+" = Math."+e+";\n",n=function(r,n,t){return r+" = "+e+"("+n+","+t+")"},t=function(r,n){return r+" = "+e+"("+r+","+n+")"}):(n=function(r,n,t){return r+" = "+n+" "+e+" "+t},t=numeric.opseq.hasOwnProperty(r+"eq")?function(r,n){return r+" "+e+"= "+n}:function(r,n){return r+" = "+r+" "+e+" "+n}),numeric[r+"VV"]=numeric.pointwise2(["x[i]","y[i]"],n("ret[i]","x[i]","y[i]"),o),numeric[r+"SV"]=numeric.pointwise2(["x","y[i]"],n("ret[i]","x","y[i]"),o),numeric[r+"VS"]=numeric.pointwise2(["x[i]","y"],n("ret[i]","x[i]","y"),o),numeric[r]=Function("var n = arguments.length, i, x = arguments[0], y;\nvar VV = numeric."+r+"VV, VS = numeric."+r+"VS, SV = numeric."+r+'SV;\nvar dim = numeric.dim;\nfor(i=1;i!==n;++i) { \n y = arguments[i];\n if(typeof x === "object") {\n if(typeof y === "object") x = numeric._biforeach2(x,y,dim(x),0,VV);\n else x = numeric._biforeach2(x,y,dim(x),0,VS);\n } else if(typeof y === "object") x = numeric._biforeach2(x,y,dim(y),0,SV);\n else '+t("x","y")+"\n}\nreturn x;\n"),numeric[e]=numeric[r],numeric[r+"eqV"]=numeric.pointwise2(["ret[i]","x[i]"],t("ret[i]","x[i]"),o),numeric[r+"eqS"]=numeric.pointwise2(["ret[i]","x"],t("ret[i]","x"),o),numeric[r+"eq"]=Function("var n = arguments.length, i, x = arguments[0], y;\nvar V = numeric."+r+"eqV, S = numeric."+r+'eqS\nvar s = numeric.dim(x);\nfor(i=1;i!==n;++i) { \n y = arguments[i];\n if(typeof y === "object") numeric._biforeach(x,y,s,0,V);\n else numeric._biforeach(x,y,s,0,S);\n}\nreturn x;\n')}for(r=0;r<numeric.mathfuns2.length;++r)e=numeric.mathfuns2[r],delete numeric.ops2[e];for(r=0;r<numeric.mathfuns.length;++r)e=numeric.mathfuns[r],numeric.ops1[e]=e;for(r in numeric.ops1)numeric.ops1.hasOwnProperty(r)&&(o="",e=numeric.ops1[r],-1!==numeric.myIndexOf.call(numeric.mathfuns,r)&&Math.hasOwnProperty(e)&&(o="var "+e+" = Math."+e+";\n"),numeric[r+"eqV"]=numeric.pointwise2(["ret[i]"],"ret[i] = "+e+"(ret[i]);",o),numeric[r+"eq"]=Function("x",'if(typeof x !== "object") return '+e+"x\nvar i;\nvar V = numeric."+r+"eqV;\nvar s = numeric.dim(x);\nnumeric._foreach(x,s,0,V);\nreturn x;\n"),numeric[r+"V"]=numeric.pointwise2(["x[i]"],"ret[i] = "+e+"(x[i]);",o),numeric[r]=Function("x",'if(typeof x !== "object") return '+e+"(x)\nvar i;\nvar V = numeric."+r+"V;\nvar s = numeric.dim(x);\nreturn numeric._foreach2(x,s,0,V);\n"));for(r=0;r<numeric.mathfuns.length;++r)e=numeric.mathfuns[r],delete numeric.ops1[e];for(r in numeric.mapreducers)numeric.mapreducers.hasOwnProperty(r)&&(e=numeric.mapreducers[r],numeric[r+"V"]=numeric.mapreduce2(e[0],e[1]),numeric[r]=Function("x","s","k",e[1]+'if(typeof x !== "object") { xi = x;\n'+e[0]+';\n return accum;\n}if(typeof s === "undefined") s = numeric.dim(x);\nif(typeof k === "undefined") k = 0;\nif(k === s.length-1) return numeric.'+r+"V(x);\nvar xi;\nvar n = x.length, i;\nfor(i=n-1;i!==-1;--i) {\n xi = arguments.callee(x[i]);\n"+e[0]+";\n}\nreturn accum;\n"))}(),numeric.truncVV=numeric.pointwise(["x[i]","y[i]"],"ret[i] = round(x[i]/y[i])*y[i];","var round = Math.round;"),numeric.truncVS=numeric.pointwise(["x[i]","y"],"ret[i] = round(x[i]/y)*y;","var round = Math.round;"),numeric.truncSV=numeric.pointwise(["x","y[i]"],"ret[i] = round(x/y[i])*y[i];","var round = Math.round;"),numeric.trunc=function(r,e){return"object"==typeof r?"object"==typeof e?numeric.truncVV(r,e):numeric.truncVS(r,e):"object"==typeof e?numeric.truncSV(r,e):Math.round(r/e)*e},numeric.inv=function(r){var e,n,t,o,i,u,a,s=numeric.dim(r),c=Math.abs,l=s[0],f=s[1],m=numeric.clone(r),h=numeric.identity(l);for(u=0;u<f;++u){var d=-1,p=-1;for(i=u;i!==l;++i)(a=c(m[i][u]))>p&&(d=i,p=a);for(n=m[d],m[d]=m[u],m[u]=n,o=h[d],h[d]=h[u],h[u]=o,r=n[u],a=u;a!==f;++a)n[a]/=r;for(a=f-1;-1!==a;--a)o[a]/=r;for(i=l-1;-1!==i;--i)if(i!==u){for(e=m[i],t=h[i],r=e[u],a=u+1;a!==f;++a)e[a]-=n[a]*r;for(a=f-1;a>0;--a)t[a]-=o[a]*r,t[--a]-=o[a]*r;0===a&&(t[0]-=o[0]*r)}}return h},numeric.det=function(r){var e=numeric.dim(r);if(2!==e.length||e[0]!==e[1])throw new Error("numeric: det() only works on square matrices");var n,t,o,i,u,a,s,c,l=e[0],f=1,m=numeric.clone(r);for(t=0;t<l-1;t++){for(o=t,n=t+1;n<l;n++)Math.abs(m[n][t])>Math.abs(m[o][t])&&(o=n);for(o!==t&&(s=m[o],m[o]=m[t],m[t]=s,f*=-1),i=m[t],n=t+1;n<l;n++){for(a=(u=m[n])[t]/i[t],o=t+1;o<l-1;o+=2)c=o+1,u[o]-=i[o]*a,u[c]-=i[c]*a;o!==l&&(u[o]-=i[o]*a)}if(0===i[t])return 0;f*=i[t]}return f*m[t][t]},numeric.transpose=function(r){var e,n,t,o,i,u=r.length,a=r[0].length,s=Array(a);for(n=0;n<a;n++)s[n]=Array(u);for(e=u-1;e>=1;e-=2){for(o=r[e],t=r[e-1],n=a-1;n>=1;--n)(i=s[n])[e]=o[n],i[e-1]=t[n],(i=s[--n])[e]=o[n],i[e-1]=t[n];0===n&&((i=s[0])[e]=o[0],i[e-1]=t[0])}if(0===e){for(t=r[0],n=a-1;n>=1;--n)s[n][0]=t[n],s[--n][0]=t[n];0===n&&(s[0][0]=t[0])}return s},numeric.negtranspose=function(r){var e,n,t,o,i,u=r.length,a=r[0].length,s=Array(a);for(n=0;n<a;n++)s[n]=Array(u);for(e=u-1;e>=1;e-=2){for(o=r[e],t=r[e-1],n=a-1;n>=1;--n)(i=s[n])[e]=-o[n],i[e-1]=-t[n],(i=s[--n])[e]=-o[n],i[e-1]=-t[n];0===n&&((i=s[0])[e]=-o[0],i[e-1]=-t[0])}if(0===e){for(t=r[0],n=a-1;n>=1;--n)s[n][0]=-t[n],s[--n][0]=-t[n];0===n&&(s[0][0]=-t[0])}return s},numeric._random=function r(e,n){var t,o,i=e[n],u=Array(i);if(n===e.length-1){for(o=Math.random,t=i-1;t>=1;t-=2)u[t]=o(),u[t-1]=o();return 0===t&&(u[0]=o()),u}for(t=i-1;t>=0;t--)u[t]=r(e,n+1);return u},numeric.random=function(r){return numeric._random(r,0)},numeric.norm2=function(r){return Math.sqrt(numeric.norm2Squared(r))},numeric.linspace=function(r,e,n){if(void 0===n&&(n=Math.max(Math.round(e-r)+1,1)),n<2)return 1===n?[r]:[];var t,o=Array(n);for(t=--n;t>=0;t--)o[t]=(t*e+(n-t)*r)/n;return o},numeric.getBlock=function(r,e,n){var t=numeric.dim(r);return function r(o,i){var u,a=e[i],s=n[i]-a,c=Array(s);if(i===t.length-1){for(u=s;u>=0;u--)c[u]=o[u+a];return c}for(u=s;u>=0;u--)c[u]=r(o[u+a],i+1);return c}(r,0)},numeric.setBlock=function(r,e,n,t){var o=numeric.dim(r);return function r(t,i,u){var a,s=e[u],c=n[u]-s;if(u===o.length-1)for(a=c;a>=0;a--)t[a+s]=i[a];for(a=c;a>=0;a--)r(t[a+s],i[a],u+1)}(r,t,0),r},numeric.getRange=function(r,e,n){var t,o,i,u,a=e.length,s=n.length,c=Array(a);for(t=a-1;-1!==t;--t)for(c[t]=Array(s),i=c[t],u=r[e[t]],o=s-1;-1!==o;--o)i[o]=u[n[o]];return c},numeric.blockMatrix=function(r){var e=numeric.dim(r);if(e.length<4)return numeric.blockMatrix([r]);var n,t,o,i,u,a=e[0],s=e[1];for(n=0,t=0,o=0;o<a;++o)n+=r[o][0].length;for(i=0;i<s;++i)t+=r[0][i][0].length;var c=Array(n);for(o=0;o<n;++o)c[o]=Array(t);var l,f,m,h,d,p=0;for(o=0;o<a;++o){for(l=t,i=s-1;-1!==i;--i)for(l-=(u=r[o][i])[0].length,m=u.length-1;-1!==m;--m)for(d=u[m],f=c[p+m],h=d.length-1;-1!==h;--h)f[l+h]=d[h];p+=r[o][0].length}return c},numeric.tensor=function(r,e){if("number"==typeof r||"number"==typeof e)return numeric.mul(r,e);var n=numeric.dim(r),t=numeric.dim(e);if(1!==n.length||1!==t.length)throw new Error("numeric: tensor product is only defined for vectors");var o,i,u,a,s=n[0],c=t[0],l=Array(s);for(i=s-1;i>=0;i--){for(o=Array(c),a=r[i],u=c-1;u>=3;--u)o[u]=a*e[u],o[--u]=a*e[u],o[--u]=a*e[u],o[--u]=a*e[u];for(;u>=0;)o[u]=a*e[u],--u;l[i]=o}return l},numeric.T=function(r,e){this.x=r,this.y=e},numeric.t=function(r,e){return new numeric.T(r,e)},numeric.Tbinop=function(r,e,n,t,o){var i;if(numeric.indexOf,"string"!=typeof o)for(i in o="",numeric)numeric.hasOwnProperty(i)&&(r.indexOf(i)>=0||e.indexOf(i)>=0||n.indexOf(i)>=0||t.indexOf(i)>=0)&&i.length>1&&(o+="var "+i+" = numeric."+i+";\n");return Function(["y"],"var x = this;\nif(!(y instanceof numeric.T)) { y = new numeric.T(y); }\n"+o+"\nif(x.y) { if(y.y) { return new numeric.T("+t+");\n }\n return new numeric.T("+n+");\n}\nif(y.y) {\n return new numeric.T("+e+");\n}\nreturn new numeric.T("+r+");\n")},numeric.T.prototype.add=numeric.Tbinop("add(x.x,y.x)","add(x.x,y.x),y.y","add(x.x,y.x),x.y","add(x.x,y.x),add(x.y,y.y)"),numeric.T.prototype.sub=numeric.Tbinop("sub(x.x,y.x)","sub(x.x,y.x),neg(y.y)","sub(x.x,y.x),x.y","sub(x.x,y.x),sub(x.y,y.y)"),numeric.T.prototype.mul=numeric.Tbinop("mul(x.x,y.x)","mul(x.x,y.x),mul(x.x,y.y)","mul(x.x,y.x),mul(x.y,y.x)","sub(mul(x.x,y.x),mul(x.y,y.y)),add(mul(x.x,y.y),mul(x.y,y.x))"),numeric.T.prototype.reciprocal=function(){var r=numeric.mul,e=numeric.div;if(this.y){var n=numeric.add(r(this.x,this.x),r(this.y,this.y));return new numeric.T(e(this.x,n),e(numeric.neg(this.y),n))}return new T(e(1,this.x))},numeric.T.prototype.div=function(r){if(r instanceof numeric.T||(r=new numeric.T(r)),r.y)return this.mul(r.reciprocal());var e=numeric.div;return this.y?new numeric.T(e(this.x,r.x),e(this.y,r.x)):new numeric.T(e(this.x,r.x))},numeric.T.prototype.dot=numeric.Tbinop("dot(x.x,y.x)","dot(x.x,y.x),dot(x.x,y.y)","dot(x.x,y.x),dot(x.y,y.x)","sub(dot(x.x,y.x),dot(x.y,y.y)),add(dot(x.x,y.y),dot(x.y,y.x))"),numeric.T.prototype.transpose=function(){var r=numeric.transpose,e=this.x,n=this.y;return n?new numeric.T(r(e),r(n)):new numeric.T(r(e))},numeric.T.prototype.transjugate=function(){var r=numeric.transpose,e=this.x,n=this.y;return n?new numeric.T(r(e),numeric.negtranspose(n)):new numeric.T(r(e))},numeric.Tunop=function(r,e,n){return"string"!=typeof n&&(n=""),Function("var x = this;\n"+n+"\nif(x.y) { "+e+";\n}\n"+r+";\n")},numeric.T.prototype.exp=numeric.Tunop("return new numeric.T(ex)","return new numeric.T(mul(cos(x.y),ex),mul(sin(x.y),ex))","var ex = numeric.exp(x.x), cos = numeric.cos, sin = numeric.sin, mul = numeric.mul;"),numeric.T.prototype.conj=numeric.Tunop("return new numeric.T(x.x);","return new numeric.T(x.x,numeric.neg(x.y));"),numeric.T.prototype.neg=numeric.Tunop("return new numeric.T(neg(x.x));","return new numeric.T(neg(x.x),neg(x.y));","var neg = numeric.neg;"),numeric.T.prototype.sin=numeric.Tunop("return new numeric.T(numeric.sin(x.x))","return x.exp().sub(x.neg().exp()).div(new numeric.T(0,2));"),numeric.T.prototype.cos=numeric.Tunop("return new numeric.T(numeric.cos(x.x))","return x.exp().add(x.neg().exp()).div(2);"),numeric.T.prototype.abs=numeric.Tunop("return new numeric.T(numeric.abs(x.x));","return new numeric.T(numeric.sqrt(numeric.add(mul(x.x,x.x),mul(x.y,x.y))));","var mul = numeric.mul;"),numeric.T.prototype.log=numeric.Tunop("return new numeric.T(numeric.log(x.x));","var theta = new numeric.T(numeric.atan2(x.y,x.x)), r = x.abs();\nreturn new numeric.T(numeric.log(r.x),theta.x);"),numeric.T.prototype.norm2=numeric.Tunop("return numeric.norm2(x.x);","var f = numeric.norm2Squared;\nreturn Math.sqrt(f(x.x)+f(x.y));"),numeric.T.prototype.inv=function(){var r=this;if(void 0===r.y)return new numeric.T(numeric.inv(r.x));var e,n,t,o,i,u,a,s,c,l,f,m,h,d,p,g,v,y,x=r.x.length,w=numeric.identity(x),b=numeric.rep([x,x],0),T=numeric.clone(r.x),C=numeric.clone(r.y);for(c=0;c<x;c++){for(m=(d=T[c][c])*d+(p=C[c][c])*p,f=c,l=c+1;l<x;l++)(h=(d=T[l][c])*d+(p=C[l][c])*p)>m&&(f=l,m=h);for(f!==c&&(y=T[c],T[c]=T[f],T[f]=y,y=C[c],C[c]=C[f],C[f]=y,y=w[c],w[c]=w[f],w[f]=y,y=b[c],b[c]=b[f],b[f]=y),e=T[c],n=C[c],i=w[c],u=b[c],d=e[c],p=n[c],l=c+1;l<x;l++)g=e[l],v=n[l],e[l]=(g*d+v*p)/m,n[l]=(v*d-g*p)/m;for(l=0;l<x;l++)g=i[l],v=u[l],i[l]=(g*d+v*p)/m,u[l]=(v*d-g*p)/m;for(l=c+1;l<x;l++){for(t=T[l],o=C[l],a=w[l],s=b[l],d=t[c],p=o[c],f=c+1;f<x;f++)g=e[f],v=n[f],t[f]-=g*d-v*p,o[f]-=v*d+g*p;for(f=0;f<x;f++)g=i[f],v=u[f],a[f]-=g*d-v*p,s[f]-=v*d+g*p}}for(c=x-1;c>0;c--)for(i=w[c],u=b[c],l=c-1;l>=0;l--)for(a=w[l],s=b[l],d=T[l][c],p=C[l][c],f=x-1;f>=0;f--)g=i[f],v=u[f],a[f]-=d*g-p*v,s[f]-=d*v+p*g;return new numeric.T(w,b)},numeric.T.prototype.get=function(r){var e,n=this.x,t=this.y,o=0,i=r.length;if(t){for(;o<i;)n=n[e=r[o]],t=t[e],o++;return new numeric.T(n,t)}for(;o<i;)n=n[e=r[o]],o++;return new numeric.T(n)},numeric.T.prototype.set=function(r,e){var n,t=this.x,o=this.y,i=0,u=r.length,a=e.x,s=e.y;if(0===u)return s?this.y=s:o&&(this.y=void 0),this.x=t,this;if(s){for(o||(o=numeric.rep(numeric.dim(t),0),this.y=o);i<u-1;)t=t[n=r[i]],o=o[n],i++;return t[n=r[i]]=a,o[n]=s,this}if(o){for(;i<u-1;)t=t[n=r[i]],o=o[n],i++;return t[n=r[i]]=a,o[n]=a instanceof Array?numeric.rep(numeric.dim(a),0):0,this}for(;i<u-1;)t=t[n=r[i]],i++;return t[n=r[i]]=a,this},numeric.T.prototype.getRows=function(r,e){var n,t,o=e-r+1,i=Array(o),u=this.x,a=this.y;for(n=r;n<=e;n++)i[n-r]=u[n];if(a){for(t=Array(o),n=r;n<=e;n++)t[n-r]=a[n];return new numeric.T(i,t)}return new numeric.T(i)},numeric.T.prototype.setRows=function(r,e,n){var t,o=this.x,i=this.y,u=n.x,a=n.y;for(t=r;t<=e;t++)o[t]=u[t-r];if(a)for(i||(i=numeric.rep(numeric.dim(o),0),this.y=i),t=r;t<=e;t++)i[t]=a[t-r];else if(i)for(t=r;t<=e;t++)i[t]=numeric.rep([u[t-r].length],0);return this},numeric.T.prototype.getRow=function(r){var e=this.x,n=this.y;return n?new numeric.T(e[r],n[r]):new numeric.T(e[r])},numeric.T.prototype.setRow=function(r,e){var n=this.x,t=this.y,o=e.x,i=e.y;return n[r]=o,i?(t||(t=numeric.rep(numeric.dim(n),0),this.y=t),t[r]=i):t&&(t=numeric.rep([o.length],0)),this},numeric.T.prototype.getBlock=function(r,e){var n=this.x,t=this.y,o=numeric.getBlock;return t?new numeric.T(o(n,r,e),o(t,r,e)):new numeric.T(o(n,r,e))},numeric.T.prototype.setBlock=function(r,e,n){n instanceof numeric.T||(n=new numeric.T(n));var t=this.x,o=this.y,i=numeric.setBlock,u=n.x,a=n.y;if(a)return o||(this.y=numeric.rep(numeric.dim(this),0),o=this.y),i(t,r,e,u),i(o,r,e,a),this;i(t,r,e,u),o&&i(o,r,e,numeric.rep(numeric.dim(u),0))},numeric.T.rep=function(r,e){var n=numeric.T;e instanceof n||(e=new n(e));var t=e.x,o=e.y,i=numeric.rep;return o?new n(i(r,t),i(r,o)):new n(i(r,t))},numeric.T.diag=function(r){r instanceof numeric.T||(r=new numeric.T(r));var e=r.x,n=r.y,t=numeric.diag;return n?new numeric.T(t(e),t(n)):new numeric.T(t(e))},numeric.T.eig=function(){if(this.y)throw new Error("eig: not implemented for complex matrices.");return numeric.eig(this.x)},numeric.T.identity=function(r){return new numeric.T(numeric.identity(r))},numeric.T.prototype.getDiag=function(){var r=numeric,e=this.x,n=this.y;return n?new r.T(r.getDiag(e),r.getDiag(n)):new r.T(r.getDiag(e))},numeric.house=function(r){var e=numeric.clone(r),n=(r[0]>=0?1:-1)*numeric.norm2(r);e[0]+=n;var t=numeric.norm2(e);if(0===t)throw new Error("eig: internal error");return numeric.div(e,t)},numeric.toUpperHessenberg=function(r){var e=numeric.dim(r);if(2!==e.length||e[0]!==e[1])throw new Error("numeric: toUpperHessenberg() only works on square matrices");var n,t,o,i,u,a,s,c,l,f,m=e[0],h=numeric.clone(r),d=numeric.identity(m);for(t=0;t<m-2;t++){for(i=Array(m-t-1),n=t+1;n<m;n++)i[n-t-1]=h[n][t];if(numeric.norm2(i)>0){for(u=numeric.house(i),a=numeric.getBlock(h,[t+1,t],[m-1,m-1]),s=numeric.tensor(u,numeric.dot(u,a)),n=t+1;n<m;n++)for(c=h[n],l=s[n-t-1],o=t;o<m;o++)c[o]-=2*l[o-t];for(a=numeric.getBlock(h,[0,t+1],[m-1,m-1]),s=numeric.tensor(numeric.dot(a,u),u),n=0;n<m;n++)for(c=h[n],l=s[n],o=t+1;o<m;o++)c[o]-=2*l[o-t-1];for(a=Array(m-t-1),n=t+1;n<m;n++)a[n-t-1]=d[n];for(s=numeric.tensor(u,numeric.dot(u,a)),n=t+1;n<m;n++)for(f=d[n],l=s[n-t-1],o=0;o<m;o++)f[o]-=2*l[o]}}return{H:h,Q:d}},numeric.epsilon=2220446049250313e-31,numeric.QRFrancis=function(r,e){void 0===e&&(e=1e4),r=numeric.clone(r),numeric.clone(r);var n,t,o,i,u,a,s,c,l,f,m,h,d,p,g,v,y,x,w=numeric.dim(r)[0],b=numeric.identity(w);if(w<3)return{Q:b,B:[[0,w-1]]};var T=numeric.epsilon;for(x=0;x<e;x++){for(v=0;v<w-1;v++)if(Math.abs(r[v+1][v])<T*(Math.abs(r[v][v])+Math.abs(r[v+1][v+1]))){var C=numeric.QRFrancis(numeric.getBlock(r,[0,0],[v,v]),e),M=numeric.QRFrancis(numeric.getBlock(r,[v+1,v+1],[w-1,w-1]),e);for(h=Array(v+1),g=0;g<=v;g++)h[g]=b[g];for(d=numeric.dot(C.Q,h),g=0;g<=v;g++)b[g]=d[g];for(h=Array(w-v-1),g=v+1;g<w;g++)h[g-v-1]=b[g];for(d=numeric.dot(M.Q,h),g=v+1;g<w;g++)b[g]=d[g-v-1];return{Q:b,B:C.B.concat(numeric.add(M.B,v+1))}}var _,S,A;for(o=r[w-2][w-2],i=r[w-2][w-1],u=r[w-1][w-2],c=o+(a=r[w-1][w-1]),s=o*a-i*u,l=numeric.getBlock(r,[0,0],[2,2]),c*c>=4*s?(_=.5*(c+Math.sqrt(c*c-4*s)),S=.5*(c-Math.sqrt(c*c-4*s)),l=numeric.add(numeric.sub(numeric.dot(l,l),numeric.mul(l,_+S)),numeric.diag(numeric.rep([3],_*S)))):l=numeric.add(numeric.sub(numeric.dot(l,l),numeric.mul(l,c)),numeric.diag(numeric.rep([3],s))),n=[l[0][0],l[1][0],l[2][0]],t=numeric.house(n),h=[r[0],r[1],r[2]],d=numeric.tensor(t,numeric.dot(t,h)),g=0;g<3;g++)for(m=r[g],p=d[g],y=0;y<w;y++)m[y]-=2*p[y];for(h=numeric.getBlock(r,[0,0],[w-1,2]),d=numeric.tensor(numeric.dot(h,t),t),g=0;g<w;g++)for(m=r[g],p=d[g],y=0;y<3;y++)m[y]-=2*p[y];for(h=[b[0],b[1],b[2]],d=numeric.tensor(t,numeric.dot(t,h)),g=0;g<3;g++)for(f=b[g],p=d[g],y=0;y<w;y++)f[y]-=2*p[y];for(v=0;v<w-2;v++){for(y=v;y<=v+1;y++)if(Math.abs(r[y+1][y])<T*(Math.abs(r[y][y])+Math.abs(r[y+1][y+1]))){for(C=numeric.QRFrancis(numeric.getBlock(r,[0,0],[y,y]),e),M=numeric.QRFrancis(numeric.getBlock(r,[y+1,y+1],[w-1,w-1]),e),h=Array(y+1),g=0;g<=y;g++)h[g]=b[g];for(d=numeric.dot(C.Q,h),g=0;g<=y;g++)b[g]=d[g];for(h=Array(w-y-1),g=y+1;g<w;g++)h[g-y-1]=b[g];for(d=numeric.dot(M.Q,h),g=y+1;g<w;g++)b[g]=d[g-y-1];return{Q:b,B:C.B.concat(numeric.add(M.B,y+1))}}for(A=Math.min(w-1,v+3),n=Array(A-v),g=v+1;g<=A;g++)n[g-v-1]=r[g][v];for(t=numeric.house(n),h=numeric.getBlock(r,[v+1,v],[A,w-1]),d=numeric.tensor(t,numeric.dot(t,h)),g=v+1;g<=A;g++)for(m=r[g],p=d[g-v-1],y=v;y<w;y++)m[y]-=2*p[y-v];for(h=numeric.getBlock(r,[0,v+1],[w-1,A]),d=numeric.tensor(numeric.dot(h,t),t),g=0;g<w;g++)for(m=r[g],p=d[g],y=v+1;y<=A;y++)m[y]-=2*p[y-v-1];for(h=Array(A-v),g=v+1;g<=A;g++)h[g-v-1]=b[g];for(d=numeric.tensor(t,numeric.dot(t,h)),g=v+1;g<=A;g++)for(f=b[g],p=d[g-v-1],y=0;y<w;y++)f[y]-=2*p[y]}}throw new Error("numeric: eigenvalue iteration does not converge -- increase maxiter?")},numeric.eig=function(r,e){var n,t,o,i,u,a,s,c,l,f,m,h,d,p,g,v,y=numeric.toUpperHessenberg(r),x=numeric.QRFrancis(y.H,e),w=numeric.T,b=r.length,T=x.B,C=numeric.dot(x.Q,numeric.dot(y.H,numeric.transpose(x.Q))),M=new w(numeric.dot(x.Q,y.Q)),_=T.length,S=Math.sqrt;for(t=0;t<_;t++)if((n=T[t][0])!==T[t][1]){if(i=n+1,u=C[n][n],a=C[n][i],s=C[i][n],c=C[i][i],0===a&&0===s)continue;(f=(l=-u-c)*l-4*(u*c-a*s))>=0?((g=(u-(m=l<0?-.5*(l-S(f)):-.5*(l+S(f))))*(u-m)+a*a)>(v=s*s+(c-m)*(c-m))?(d=(u-m)/(g=S(g)),p=a/g):(d=s/(v=S(v)),p=(c-m)/v),o=new w([[p,-d],[d,p]]),M.setRows(n,i,o.dot(M.getRows(n,i)))):(m=-.5*l,h=.5*S(-f),(g=(u-m)*(u-m)+a*a)>(v=s*s+(c-m)*(c-m))?(d=(u-m)/(g=S(g+h*h)),p=a/g,m=0,h/=g):(d=s/(v=S(v+h*h)),p=(c-m)/v,m=h/v,h=0),o=new w([[p,-d],[d,p]],[[m,h],[h,-m]]),M.setRows(n,i,o.dot(M.getRows(n,i))))}var A=M.dot(r).dot(M.transjugate()),k=(b=r.length,numeric.T.identity(b));for(i=0;i<b;i++)if(i>0)for(t=i-1;t>=0;t--){var O=A.get([t,t]),P=A.get([i,i]);numeric.neq(O.x,P.x)||numeric.neq(O.y,P.y)?(m=A.getRow(t).getBlock([t],[i-1]),h=k.getRow(i).getBlock([t],[i-1]),k.set([i,t],A.get([t,i]).neg().sub(m.dot(h)).div(O.sub(P)))):k.setRow(i,k.getRow(t))}for(i=0;i<b;i++)m=k.getRow(i),k.setRow(i,m.div(m.norm2()));return k=k.transpose(),k=M.transjugate().dot(k),{lambda:A.getDiag(),E:k}},numeric.ccsSparse=function(r){var e,n,t,o=r.length,i=[];for(n=o-1;-1!==n;--n)for(t in e=r[n]){for(t=parseInt(t);t>=i.length;)i[i.length]=0;0!==e[t]&&i[t]++}var u=i.length,a=Array(u+1);for(a[0]=0,n=0;n<u;++n)a[n+1]=a[n]+i[n];var s=Array(a[u]),c=Array(a[u]);for(n=o-1;-1!==n;--n)for(t in e=r[n])0!==e[t]&&(i[t]--,s[a[t]+i[t]]=n,c[a[t]+i[t]]=e[t]);return[a,s,c]},numeric.ccsFull=function(r){var e,n,t,o,i=r[0],u=r[1],a=r[2],s=numeric.ccsDim(r),c=s[0],l=s[1],f=numeric.rep([c,l],0);for(e=0;e<l;e++)for(t=i[e],o=i[e+1],n=t;n<o;++n)f[u[n]][e]=a[n];return f},numeric.ccsTSolve=function(r,e,n,t,o){function i(r){var e;if(0===n[r]){for(n[r]=1,e=h[r];e<h[r+1];++e)i(d[e]);o[y]=r,++y}}var u,a,s,c,l,f,m,h=r[0],d=r[1],p=r[2],g=h.length-1,v=Math.max,y=0;for(void 0===t&&(n=numeric.rep([g],0)),void 0===t&&(t=numeric.linspace(0,n.length-1)),void 0===o&&(o=[]),u=t.length-1;-1!==u;--u)i(t[u]);for(o.length=y,u=o.length-1;-1!==u;--u)n[o[u]]=0;for(u=t.length-1;-1!==u;--u)a=t[u],n[a]=e[a];for(u=o.length-1;-1!==u;--u){for(a=o[u],s=h[a],c=v(h[a+1],s),l=s;l!==c;++l)if(d[l]===a){n[a]/=p[l];break}for(m=n[a],l=s;l!==c;++l)(f=d[l])!==a&&(n[f]-=m*p[l])}return n},numeric.ccsDFS=function(r){this.k=Array(r),this.k1=Array(r),this.j=Array(r)},numeric.ccsDFS.prototype.dfs=function(r,e,n,t,o,i){var u,a,s,c=0,l=o.length,f=this.k,m=this.k1,h=this.j;if(0===t[r])for(t[r]=1,h[0]=r,f[0]=a=e[r],m[0]=s=e[r+1];;)if(a>=s){if(o[l]=h[c],0===c)return;++l,a=f[--c],s=m[c]}else 0===t[u=i[n[a]]]?(t[u]=1,f[c]=a,h[++c]=u,a=e[u],m[c]=s=e[u+1]):++a},numeric.ccsLPSolve=function(r,e,n,t,o,i,u){var a,s,c,l,f,m,h,d,p,g=r[0],v=r[1],y=r[2],x=(g.length,e[0]),w=e[1],b=e[2];for(s=x[o],c=x[o+1],t.length=0,a=s;a<c;++a)u.dfs(i[w[a]],g,v,n,t,i);for(a=t.length-1;-1!==a;--a)n[t[a]]=0;for(a=s;a!==c;++a)n[l=i[w[a]]]=b[a];for(a=t.length-1;-1!==a;--a){for(f=g[l=t[a]],m=g[l+1],h=f;h<m;++h)if(i[v[h]]===l){n[l]/=y[h];break}for(p=n[l],h=f;h<m;++h)(d=i[v[h]])!==l&&(n[d]-=p*y[h])}return n},numeric.ccsLUP1=function(r,e){var n,t,o,i,u,a,s,c=r[0].length-1,l=[numeric.rep([c+1],0),[],[]],f=[numeric.rep([c+1],0),[],[]],m=l[0],h=l[1],d=l[2],p=f[0],g=f[1],v=f[2],y=numeric.rep([c],0),x=numeric.rep([c],0),w=numeric.ccsLPSolve,b=(Math.max,Math.abs),T=numeric.linspace(0,c-1),C=numeric.linspace(0,c-1),M=new numeric.ccsDFS(c);for(void 0===e&&(e=1),n=0;n<c;++n){for(w(l,r,y,x,n,C,M),i=-1,u=-1,t=x.length-1;-1!==t;--t)(o=x[t])<=n||(a=b(y[o]))>i&&(u=o,i=a);for(b(y[n])<e*i&&(t=T[n],i=T[u],T[n]=i,C[i]=n,T[u]=t,C[t]=u,i=y[n],y[n]=y[u],y[u]=i),i=m[n],u=p[n],s=y[n],h[i]=T[n],d[i]=1,++i,t=x.length-1;-1!==t;--t)a=y[o=x[t]],x[t]=0,y[o]=0,o<=n?(g[u]=o,v[u]=a,++u):(h[i]=T[o],d[i]=a/s,++i);m[n+1]=i,p[n+1]=u}for(t=h.length-1;-1!==t;--t)h[t]=C[h[t]];return{L:l,U:f,P:T,Pinv:C}},numeric.ccsDFS0=function(r){this.k=Array(r),this.k1=Array(r),this.j=Array(r)},numeric.ccsDFS0.prototype.dfs=function(r,e,n,t,o,i,u){var a,s,c,l=0,f=o.length,m=this.k,h=this.k1,d=this.j;if(0===t[r])for(t[r]=1,d[0]=r,m[0]=s=e[i[r]],h[0]=c=e[i[r]+1];;){if(isNaN(s))throw new Error("Ow!");if(s>=c){if(o[f]=i[d[l]],0===l)return;++f,s=m[--l],c=h[l]}else 0===t[a=n[s]]?(t[a]=1,m[l]=s,d[++l]=a,s=e[a=i[a]],h[l]=c=e[a+1]):++s}},numeric.ccsLPSolve0=function(r,e,n,t,o,i,u,a){var s,c,l,f,m,h,d,p,g,v=r[0],y=r[1],x=r[2],w=(v.length,e[0]),b=e[1],T=e[2];for(c=w[o],l=w[o+1],t.length=0,s=c;s<l;++s)a.dfs(b[s],v,y,n,t,i,u);for(s=t.length-1;-1!==s;--s)n[u[f=t[s]]]=0;for(s=c;s!==l;++s)n[f=b[s]]=T[s];for(s=t.length-1;-1!==s;--s){for(p=u[f=t[s]],m=v[f],h=v[f+1],d=m;d<h;++d)if(y[d]===p){n[p]/=x[d];break}for(g=n[p],d=m;d<h;++d)n[y[d]]-=g*x[d];n[p]=g}},numeric.ccsLUP0=function(r,e){var n,t,o,i,u,a,s,c=r[0].length-1,l=[numeric.rep([c+1],0),[],[]],f=[numeric.rep([c+1],0),[],[]],m=l[0],h=l[1],d=l[2],p=f[0],g=f[1],v=f[2],y=numeric.rep([c],0),x=numeric.rep([c],0),w=numeric.ccsLPSolve0,b=(Math.max,Math.abs),T=numeric.linspace(0,c-1),C=numeric.linspace(0,c-1),M=new numeric.ccsDFS0(c);for(void 0===e&&(e=1),n=0;n<c;++n){for(w(l,r,y,x,n,C,T,M),i=-1,u=-1,t=x.length-1;-1!==t;--t)(o=x[t])<=n||(a=b(y[T[o]]))>i&&(u=o,i=a);for(b(y[T[n]])<e*i&&(t=T[n],i=T[u],T[n]=i,C[i]=n,T[u]=t,C[t]=u),i=m[n],u=p[n],s=y[T[n]],h[i]=T[n],d[i]=1,++i,t=x.length-1;-1!==t;--t)a=y[T[o=x[t]]],x[t]=0,y[T[o]]=0,o<=n?(g[u]=o,v[u]=a,++u):(h[i]=T[o],d[i]=a/s,++i);m[n+1]=i,p[n+1]=u}for(t=h.length-1;-1!==t;--t)h[t]=C[h[t]];return{L:l,U:f,P:T,Pinv:C}},numeric.ccsLUP=numeric.ccsLUP0,numeric.ccsDim=function(r){return[numeric.sup(r[1])+1,r[0].length-1]},numeric.ccsGetBlock=function(r,e,n){var t=numeric.ccsDim(r),o=t[0],i=t[1];void 0===e?e=numeric.linspace(0,o-1):"number"==typeof e&&(e=[e]),void 0===n?n=numeric.linspace(0,i-1):"number"==typeof n&&(n=[n]);var u,a,s,c,l=e.length,f=n.length,m=numeric.rep([i],0),h=[],d=[],p=[m,h,d],g=r[0],v=r[1],y=r[2],x=numeric.rep([o],0),w=0,b=numeric.rep([o],0);for(a=0;a<f;++a){var T=g[c=n[a]],C=g[c+1];for(u=T;u<C;++u)b[s=v[u]]=1,x[s]=y[u];for(u=0;u<l;++u)b[e[u]]&&(h[w]=u,d[w]=x[e[u]],++w);for(u=T;u<C;++u)b[s=v[u]]=0;m[a+1]=w}return p},numeric.ccsDot=function(r,e){var n,t,o,i,u,a,s,c,l,f,m,h=r[0],d=r[1],p=r[2],g=e[0],v=e[1],y=e[2],x=numeric.ccsDim(r),w=numeric.ccsDim(e),b=x[0],T=(x[1],w[1]),C=numeric.rep([b],0),M=numeric.rep([b],0),_=Array(b),S=numeric.rep([T],0),A=[],k=[],O=[S,A,k];for(o=0;o!==T;++o){for(i=g[o],u=g[o+1],l=0,t=i;t<u;++t)for(f=v[t],m=y[t],a=h[f],s=h[f+1],n=a;n<s;++n)0===M[c=d[n]]&&(_[l]=c,M[c]=1,l+=1),C[c]=C[c]+p[n]*m;for(u=(i=S[o])+l,S[o+1]=u,t=l-1;-1!==t;--t)m=i+t,n=_[t],A[m]=n,k[m]=C[n],M[n]=0,C[n]=0;S[o+1]=S[o]+l}return O},numeric.ccsLUPSolve=function(r,e){var n=r.L,t=r.U,o=(r.P,e[0]),i=!1;"object"!=typeof o&&(o=(e=[[0,e.length],numeric.linspace(0,e.length-1),e])[0],i=!0);var u,a,s,c,l,f,m=e[1],h=e[2],d=n[0].length-1,p=o.length-1,g=numeric.rep([d],0),v=Array(d),y=numeric.rep([d],0),x=Array(d),w=numeric.rep([p+1],0),b=[],T=[],C=numeric.ccsTSolve,M=0;for(u=0;u<p;++u){for(l=0,s=o[u],c=o[u+1],a=s;a<c;++a)f=r.Pinv[m[a]],x[l]=f,y[f]=h[a],++l;for(x.length=l,C(n,y,g,x,v),a=x.length-1;-1!==a;--a)y[x[a]]=0;if(C(t,g,y,v,x),i)return y;for(a=v.length-1;-1!==a;--a)g[v[a]]=0;for(a=x.length-1;-1!==a;--a)f=x[a],b[M]=f,T[M]=y[f],y[f]=0,++M;w[u+1]=M}return[w,b,T]},numeric.ccsbinop=function(r,e){return void 0===e&&(e=""),Function("X","Y","var Xi = X[0], Xj = X[1], Xv = X[2];\nvar Yi = Y[0], Yj = Y[1], Yv = Y[2];\nvar n = Xi.length-1,m = Math.max(numeric.sup(Xj),numeric.sup(Yj))+1;\nvar Zi = numeric.rep([n+1],0), Zj = [], Zv = [];\nvar x = numeric.rep([m],0),y = numeric.rep([m],0);\nvar xk,yk,zk;\nvar i,j,j0,j1,k,p=0;\n"+e+"for(i=0;i<n;++i) {\n j0 = Xi[i]; j1 = Xi[i+1];\n for(j=j0;j!==j1;++j) {\n k = Xj[j];\n x[k] = 1;\n Zj[p] = k;\n ++p;\n }\n j0 = Yi[i]; j1 = Yi[i+1];\n for(j=j0;j!==j1;++j) {\n k = Yj[j];\n y[k] = Yv[j];\n if(x[k] === 0) {\n Zj[p] = k;\n ++p;\n }\n }\n Zi[i+1] = p;\n j0 = Xi[i]; j1 = Xi[i+1];\n for(j=j0;j!==j1;++j) x[Xj[j]] = Xv[j];\n j0 = Zi[i]; j1 = Zi[i+1];\n for(j=j0;j!==j1;++j) {\n k = Zj[j];\n xk = x[k];\n yk = y[k];\n"+r+"\n Zv[j] = zk;\n }\n j0 = Xi[i]; j1 = Xi[i+1];\n for(j=j0;j!==j1;++j) x[Xj[j]] = 0;\n j0 = Yi[i]; j1 = Yi[i+1];\n for(j=j0;j!==j1;++j) y[Yj[j]] = 0;\n}\nreturn [Zi,Zj,Zv];")},function(){var k,A,B,C;for(k in numeric.ops2)A=isFinite(eval("1"+numeric.ops2[k]+"0"))?"[Y[0],Y[1],numeric."+k+"(X,Y[2])]":"NaN",B=isFinite(eval("0"+numeric.ops2[k]+"1"))?"[X[0],X[1],numeric."+k+"(X[2],Y)]":"NaN",C=isFinite(eval("1"+numeric.ops2[k]+"0"))&&isFinite(eval("0"+numeric.ops2[k]+"1"))?"numeric.ccs"+k+"MM(X,Y)":"NaN",numeric["ccs"+k+"MM"]=numeric.ccsbinop("zk = xk "+numeric.ops2[k]+"yk;"),numeric["ccs"+k]=Function("X","Y",'if(typeof X === "number") return '+A+';\nif(typeof Y === "number") return '+B+";\nreturn "+C+";\n")}(),numeric.ccsScatter=function(r){var e,n=r[0],t=r[1],o=r[2],i=numeric.sup(t)+1,u=n.length,a=numeric.rep([i],0),s=Array(u),c=Array(u),l=numeric.rep([i],0);for(e=0;e<u;++e)l[t[e]]++;for(e=0;e<i;++e)a[e+1]=a[e]+l[e];var f,m,h=a.slice(0);for(e=0;e<u;++e)s[f=h[m=t[e]]]=n[e],c[f]=o[e],h[m]=h[m]+1;return[a,s,c]},numeric.ccsGather=function(r){var e,n,t,o,i,u=r[0],a=r[1],s=r[2],c=u.length-1,l=a.length,f=Array(l),m=Array(l),h=Array(l);for(i=0,e=0;e<c;++e)for(t=u[e],o=u[e+1],n=t;n!==o;++n)m[i]=e,f[i]=a[n],h[i]=s[n],++i;return[f,m,h]},numeric.sdim=function r(e,n,t){if(void 0===n&&(n=[]),"object"!=typeof e)return n;var o;for(o in void 0===t&&(t=0),t in n||(n[t]=0),e.length>n[t]&&(n[t]=e.length),e)e.hasOwnProperty(o)&&r(e[o],n,t+1);return n},numeric.sclone=function r(e,n,t){void 0===n&&(n=0),void 0===t&&(t=numeric.sdim(e).length);var o,i=Array(e.length);if(n===t-1){for(o in e)e.hasOwnProperty(o)&&(i[o]=e[o]);return i}for(o in e)e.hasOwnProperty(o)&&(i[o]=r(e[o],n+1,t));return i},numeric.sdiag=function(r){var e,n,t=r.length,o=Array(t);for(e=t-1;e>=1;e-=2)n=e-1,o[e]=[],o[e][e]=r[e],o[n]=[],o[n][n]=r[n];return 0===e&&(o[0]=[],o[0][0]=r[e]),o},numeric.sidentity=function(r){return numeric.sdiag(numeric.rep([r],1))},numeric.stranspose=function(r){var e,n,t,o=[];for(e in r.length,r)if(r.hasOwnProperty(e))for(n in t=r[e])t.hasOwnProperty(n)&&("object"!=typeof o[n]&&(o[n]=[]),o[n][e]=t[n]);return o},numeric.sLUP=function(r,e){throw new Error("The function numeric.sLUP had a bug in it and has been removed. Please use the new numeric.ccsLUP function instead.")},numeric.sdotMM=function(r,e){var n,t,o,i,u,a,s,c=r.length,l=(e.length,numeric.stranspose(e)),f=l.length,m=Array(c);for(o=c-1;o>=0;o--){for(s=[],n=r[o],u=f-1;u>=0;u--){for(i in a=0,t=l[u],n)n.hasOwnProperty(i)&&i in t&&(a+=n[i]*t[i]);a&&(s[u]=a)}m[o]=s}return m},numeric.sdotMV=function(r,e){var n,t,o,i,u=r.length,a=Array(u);for(t=u-1;t>=0;t--){for(o in i=0,n=r[t])n.hasOwnProperty(o)&&e[o]&&(i+=n[o]*e[o]);i&&(a[t]=i)}return a},numeric.sdotVM=function(r,e){var n,t,o,i,u=[];for(n in r)if(r.hasOwnProperty(n))for(t in o=e[n],i=r[n],o)o.hasOwnProperty(t)&&(u[t]||(u[t]=0),u[t]+=i*o[t]);return u},numeric.sdotVV=function(r,e){var n,t=0;for(n in r)r[n]&&e[n]&&(t+=r[n]*e[n]);return t},numeric.sdot=function(r,e){var n=numeric.sdim(r).length,t=numeric.sdim(e).length;switch(1e3*n+t){case 0:return r*e;case 1001:return numeric.sdotVV(r,e);case 2001:return numeric.sdotMV(r,e);case 1002:return numeric.sdotVM(r,e);case 2002:return numeric.sdotMM(r,e);default:throw new Error("numeric.sdot not implemented for tensors of order "+n+" and "+t)}},numeric.sscatter=function(r){var e,n,t,o,i=r[0].length,u=r.length,a=[];for(n=i-1;n>=0;--n)if(r[u-1][n]){for(o=a,t=0;t<u-2;t++)o[e=r[t][n]]||(o[e]=[]),o=o[e];o[r[t][n]]=r[t+1][n]}return a},numeric.sgather=function r(e,n,t){var o,i,u;for(i in void 0===n&&(n=[]),void 0===t&&(t=[]),o=t.length,e)if(e.hasOwnProperty(i))if(t[o]=parseInt(i),"number"==typeof(u=e[i])){if(u){if(0===n.length)for(i=o+1;i>=0;--i)n[i]=[];for(i=o;i>=0;--i)n[i].push(t[i]);n[o+1].push(u)}}else r(u,n,t);return t.length>o&&t.pop(),n},numeric.cLU=function(r){var e,n,t,o,i,u,a=r[0],s=r[1],c=r[2],l=a.length,f=0;for(e=0;e<l;e++)a[e]>f&&(f=a[e]);f++;var m,h=Array(f),d=Array(f),p=numeric.rep([f],1/0),g=numeric.rep([f],-1/0);for(t=0;t<l;t++)e=a[t],(n=s[t])<p[e]&&(p[e]=n),n>g[e]&&(g[e]=n);for(e=0;e<f-1;e++)g[e]>g[e+1]&&(g[e+1]=g[e]);for(e=f-1;e>=1;e--)p[e]<p[e-1]&&(p[e-1]=p[e]);for(e=0;e<f;e++)d[e]=numeric.rep([g[e]-p[e]+1],0),h[e]=numeric.rep([e-p[e]],0),p[e],g[e];for(t=0;t<l;t++)d[e=a[t]][s[t]-p[e]]=c[t];for(e=0;e<f-1;e++)for(o=e-p[e],x=d[e],n=e+1;p[n]<=e&&n<f;n++)if(i=e-p[n],u=g[e]-e,m=(w=d[n])[i]/x[o]){for(t=1;t<=u;t++)w[t+i]-=m*x[t+o];h[n][e-p[n]]=m}var v,y,x=[],w=[],b=[],T=[],C=[],M=[];for(l=0,v=0,e=0;e<f;e++){for(o=p[e],i=g[e],y=d[e],n=e;n<=i;n++)y[n-o]&&(x[l]=e,w[l]=n,b[l]=y[n-o],l++);for(y=h[e],n=o;n<e;n++)y[n-o]&&(T[v]=e,C[v]=n,M[v]=y[n-o],v++);T[v]=e,C[v]=e,M[v]=1,v++}return{U:[x,w,b],L:[T,C,M]}},numeric.cLUsolve=function(r,e){var n,t,o=r.L,i=r.U,u=numeric.clone(e),a=o[0],s=o[1],c=o[2],l=i[0],f=i[1],m=i[2],h=l.length,d=(a.length,u.length);for(t=0,n=0;n<d;n++){for(;s[t]<n;)u[n]-=c[t]*u[s[t]],t++;t++}for(t=h-1,n=d-1;n>=0;n--){for(;f[t]>n;)u[n]-=m[t]*u[f[t]],t--;u[n]/=m[t],t--}return u},numeric.cgrid=function(r,e){"number"==typeof r&&(r=[r,r]);var n,t,o,i=numeric.rep(r,-1);for("function"!=typeof e&&(e="L"===e?function(e,n){return e>=r[0]/2||n<r[1]/2}:function(r,e){return!0}),o=0,n=1;n<r[0]-1;n++)for(t=1;t<r[1]-1;t++)e(n,t)&&(i[n][t]=o,o++);return i},numeric.cdelsq=function(r){var e,n,t,o,i,u=[[-1,0],[0,-1],[0,1],[1,0]],a=numeric.dim(r),s=a[0],c=a[1],l=[],f=[],m=[];for(e=1;e<s-1;e++)for(n=1;n<c-1;n++)if(!(r[e][n]<0)){for(t=0;t<4;t++)o=e+u[t][0],i=n+u[t][1],r[o][i]<0||(l.push(r[e][n]),f.push(r[o][i]),m.push(-1));l.push(r[e][n]),f.push(r[e][n]),m.push(4)}return[l,f,m]},numeric.cdotMV=function(r,e){var n,t,o,i=r[0],u=r[1],a=r[2],s=i.length;for(o=0,t=0;t<s;t++)i[t]>o&&(o=i[t]);for(o++,n=numeric.rep([o],0),t=0;t<s;t++)n[i[t]]+=a[t]*e[u[t]];return n},numeric.Spline=function(r,e,n,t,o){this.x=r,this.yl=e,this.yr=n,this.kl=t,this.kr=o},numeric.Spline.prototype._at=function(r,e){var n,t,o,i=this.x,u=this.yl,a=this.yr,s=this.kl,c=this.kr,l=numeric.add,f=numeric.sub,m=numeric.mul;n=f(m(s[e],i[e+1]-i[e]),f(a[e+1],u[e])),t=l(m(c[e+1],i[e]-i[e+1]),f(a[e+1],u[e]));var h=(o=(r-i[e])/(i[e+1]-i[e]))*(1-o);return l(l(l(m(1-o,u[e]),m(o,a[e+1])),m(n,h*(1-o))),m(t,h*o))},numeric.Spline.prototype.at=function(r){if("number"==typeof r){var e,n,t,o=this.x,i=o.length,u=Math.floor;for(e=0,n=i-1;n-e>1;)o[t=u((e+n)/2)]<=r?e=t:n=t;return this._at(r,e)}i=r.length;var a,s=Array(i);for(a=i-1;-1!==a;--a)s[a]=this.at(r[a]);return s},numeric.Spline.prototype.diff=function(){var r,e,n,t=this.x,o=this.yl,i=this.yr,u=this.kl,a=this.kr,s=o.length,c=u,l=a,f=Array(s),m=Array(s),h=numeric.add,d=numeric.mul,p=numeric.div,g=numeric.sub;for(r=s-1;-1!==r;--r)e=t[r+1]-t[r],n=g(i[r+1],o[r]),f[r]=p(h(d(n,6),d(u[r],-4*e),d(a[r+1],-2*e)),e*e),m[r+1]=p(h(d(n,-6),d(u[r],2*e),d(a[r+1],4*e)),e*e);return new numeric.Spline(t,c,l,f,m)},numeric.Spline.prototype.roots=function(){var r=[],e=this.x,n=this.yl,t=this.yr,o=this.kl,i=this.kr;"number"==typeof n[0]&&(n=[n],t=[t],o=[o],i=[i]);var u,a,s,c,l,f,m,h,d,p,g,v,y,x,w,b,T,C,M,_,S,A,k,O,P=n.length,N=e.length-1,j=(r=Array(P),Math.sqrt);for(u=0;u!==P;++u){for(c=n[u],l=t[u],f=o[u],m=i[u],h=[],a=0;a!==N;a++){for(a>0&&l[a]*c[a]<0&&h.push(e[a]),b=e[a+1]-e[a],e[a],g=c[a],v=l[a+1],d=f[a]/b,y=(p=m[a+1]/b)+3*g+2*d-3*v,x=3*(p+d+2*(g-v)),(w=(O=d-p+3*(g-v))*O+12*p*g)<=0?T=(C=y/x)>e[a]&&C<e[a+1]?[e[a],C,e[a+1]]:[e[a],e[a+1]]:(C=(y-j(w))/x,M=(y+j(w))/x,T=[e[a]],C>e[a]&&C<e[a+1]&&T.push(C),M>e[a]&&M<e[a+1]&&T.push(M),T.push(e[a+1])),S=T[0],C=this._at(S,a),s=0;s<T.length-1;s++)if(A=T[s+1],M=this._at(A,a),0!==C)if(0===M||C*M>0)S=A,C=M;else{for(var q=0;!((k=(C*A-M*S)/(C-M))<=S||k>=A);)if((_=this._at(k,a))*M>0)A=k,M=_,-1===q&&(C*=.5),q=-1;else{if(!(_*C>0))break;S=k,C=_,1===q&&(M*=.5),q=1}h.push(k),S=T[s+1],C=this._at(S,a)}else h.push(S),S=A,C=M;0===M&&h.push(A)}r[u]=h}return"number"==typeof this.yl[0]?r[0]:r},numeric.spline=function(r,e,n,t){var o,i=r.length,u=[],a=[],s=[],c=numeric.sub,l=numeric.mul,f=numeric.add;for(o=i-2;o>=0;o--)a[o]=r[o+1]-r[o],s[o]=c(e[o+1],e[o]);"string"!=typeof n&&"string"!=typeof t||(n=t="periodic");var m=[[],[],[]];switch(typeof n){case"undefined":u[0]=l(3/(a[0]*a[0]),s[0]),m[0].push(0,0),m[1].push(0,1),m[2].push(2/a[0],1/a[0]);break;case"string":u[0]=f(l(3/(a[i-2]*a[i-2]),s[i-2]),l(3/(a[0]*a[0]),s[0])),m[0].push(0,0,0),m[1].push(i-2,0,1),m[2].push(1/a[i-2],2/a[i-2]+2/a[0],1/a[0]);break;default:u[0]=n,m[0].push(0),m[1].push(0),m[2].push(1)}for(o=1;o<i-1;o++)u[o]=f(l(3/(a[o-1]*a[o-1]),s[o-1]),l(3/(a[o]*a[o]),s[o])),m[0].push(o,o,o),m[1].push(o-1,o,o+1),m[2].push(1/a[o-1],2/a[o-1]+2/a[o],1/a[o]);switch(typeof t){case"undefined":u[i-1]=l(3/(a[i-2]*a[i-2]),s[i-2]),m[0].push(i-1,i-1),m[1].push(i-2,i-1),m[2].push(1/a[i-2],2/a[i-2]);break;case"string":m[1][m[1].length-1]=0;break;default:u[i-1]=t,m[0].push(i-1),m[1].push(i-1),m[2].push(1)}u="number"!=typeof u[0]?numeric.transpose(u):[u];var h=Array(u.length);if("string"==typeof n)for(o=h.length-1;-1!==o;--o)h[o]=numeric.ccsLUPSolve(numeric.ccsLUP(numeric.ccsScatter(m)),u[o]),h[o][i-1]=h[o][0];else for(o=h.length-1;-1!==o;--o)h[o]=numeric.cLUsolve(numeric.cLU(m),u[o]);return h="number"==typeof e[0]?h[0]:numeric.transpose(h),new numeric.Spline(r,e,e,h,h)},numeric.fftpow2=function r(e,n){var t=e.length;if(1!==t){var o,i,u=Math.cos,a=Math.sin,s=Array(t/2),c=Array(t/2),l=Array(t/2),f=Array(t/2);for(i=t/2,o=t-1;-1!==o;--o)l[--i]=e[o],f[i]=n[o],--o,s[i]=e[o],c[i]=n[o];r(s,c),r(l,f),i=t/2;var m,h,d,p=-6.283185307179586/t;for(o=t-1;-1!==o;--o)-1==--i&&(i=t/2-1),h=u(m=p*o),d=a(m),e[o]=s[i]+h*l[i]-d*f[i],n[o]=c[i]+h*f[i]+d*l[i]}},numeric._ifftpow2=function r(e,n){var t=e.length;if(1!==t){var o,i,u=Math.cos,a=Math.sin,s=Array(t/2),c=Array(t/2),l=Array(t/2),f=Array(t/2);for(i=t/2,o=t-1;-1!==o;--o)l[--i]=e[o],f[i]=n[o],--o,s[i]=e[o],c[i]=n[o];r(s,c),r(l,f),i=t/2;var m,h,d,p=6.283185307179586/t;for(o=t-1;-1!==o;--o)-1==--i&&(i=t/2-1),h=u(m=p*o),d=a(m),e[o]=s[i]+h*l[i]-d*f[i],n[o]=c[i]+h*f[i]+d*l[i]}},numeric.ifftpow2=function(r,e){numeric._ifftpow2(r,e),numeric.diveq(r,r.length),numeric.diveq(e,e.length)},numeric.convpow2=function(r,e,n,t){var o,i,u,a,s;for(numeric.fftpow2(r,e),numeric.fftpow2(n,t),o=r.length-1;-1!==o;--o)i=r[o],a=e[o],u=n[o],s=t[o],r[o]=i*u-a*s,e[o]=i*s+a*u;numeric.ifftpow2(r,e)},numeric.T.prototype.fft=function(){var r,e,n=this.x,t=this.y,o=n.length,i=Math.log,u=i(2),a=Math.ceil(i(2*o-1)/u),s=Math.pow(2,a),c=numeric.rep([s],0),l=numeric.rep([s],0),f=Math.cos,m=Math.sin,h=-3.141592653589793/o,d=numeric.rep([s],0),p=numeric.rep([s],0);for(Math.floor(o/2),r=0;r<o;r++)d[r]=n[r];if(void 0!==t)for(r=0;r<o;r++)p[r]=t[r];for(c[0]=1,r=1;r<=s/2;r++)e=h*r*r,c[r]=f(e),l[r]=m(e),c[s-r]=f(e),l[s-r]=m(e);var g=new numeric.T(d,p),v=new numeric.T(c,l);return g=g.mul(v),numeric.convpow2(g.x,g.y,numeric.clone(v.x),numeric.neg(v.y)),(g=g.mul(v)).x.length=o,g.y.length=o,g},numeric.T.prototype.ifft=function(){var r,e,n=this.x,t=this.y,o=n.length,i=Math.log,u=i(2),a=Math.ceil(i(2*o-1)/u),s=Math.pow(2,a),c=numeric.rep([s],0),l=numeric.rep([s],0),f=Math.cos,m=Math.sin,h=3.141592653589793/o,d=numeric.rep([s],0),p=numeric.rep([s],0);for(Math.floor(o/2),r=0;r<o;r++)d[r]=n[r];if(void 0!==t)for(r=0;r<o;r++)p[r]=t[r];for(c[0]=1,r=1;r<=s/2;r++)e=h*r*r,c[r]=f(e),l[r]=m(e),c[s-r]=f(e),l[s-r]=m(e);var g=new numeric.T(d,p),v=new numeric.T(c,l);return g=g.mul(v),numeric.convpow2(g.x,g.y,numeric.clone(v.x),numeric.neg(v.y)),(g=g.mul(v)).x.length=o,g.y.length=o,g.div(o)},numeric.gradient=function(r,e){var n=e.length,t=r(e);if(isNaN(t))throw new Error("gradient: f(x) is a NaN!");var o,i,u,a,s,c,l,f,m,h=Math.max,d=numeric.clone(e),p=Array(n),g=(numeric.div,numeric.sub,h=Math.max,Math.abs),v=Math.min,y=0;for(o=0;o<n;o++)for(var x=h(1e-6*t,1e-8);;){if(++y>20)throw new Error("Numerical gradient fails");if(d[o]=e[o]+x,i=r(d),d[o]=e[o]-x,u=r(d),d[o]=e[o],isNaN(i)||isNaN(u))x/=16;else{if(p[o]=(i-u)/(2*x),a=e[o]-x,s=e[o],c=e[o]+x,l=(i-t)/x,f=(t-u)/x,m=h(g(p[o]),g(t),g(i),g(u),g(a),g(s),g(c),1e-8),!(v(h(g(l-p[o]),g(f-p[o]),g(l-f))/m,x/m)>.001))break;x/=16}}return p},numeric.uncmin=function(r,e,n,t,o,i,u){var a=numeric.gradient;void 0===u&&(u={}),void 0===n&&(n=1e-8),void 0===t&&(t=function(e){return a(r,e)}),void 0===o&&(o=1e3);var s,c,l=(e=numeric.clone(e)).length,f=r(e);if(isNaN(f))throw new Error("uncmin: f(x0) is a NaN!");var m=Math.max,h=numeric.norm2;n=m(n,numeric.epsilon);var d,p,g,v,y,x,w,b,T,C,M=u.Hinv||numeric.identity(l),_=numeric.dot,S=(numeric.inv,numeric.sub),A=numeric.add,k=numeric.tensor,O=numeric.div,P=numeric.mul,N=numeric.all,j=numeric.isFinite,q=numeric.neg,E=0,R="";for(p=t(e);E<o;){if("function"==typeof i&&i(E,e,f,p,M)){R="Callback returned true";break}if(!N(j(p))){R="Gradient has Infinity or NaN";break}if(!N(j(d=q(_(M,p))))){R="Search direction has Infinity or NaN";break}if((C=h(d))<n){R="Newton step smaller than tol";break}for(T=1,c=_(p,d),y=e;E<o&&!(T*C<n)&&(y=A(e,v=P(d,T)),(s=r(y))-f>=.1*T*c||isNaN(s));)T*=.5,++E;if(T*C<n){R="Line search step size smaller than tol";break}if(E===o){R="maxit reached during line search";break}b=_(x=S(g=t(y),p),v),w=_(M,x),M=S(A(M,P((b+_(x,w))/(b*b),k(v,v))),O(A(k(w,v),k(v,w)),b)),e=y,f=s,p=g,++E}return{solution:e,f,gradient:p,invHessian:M,iterations:E,message:R}},numeric.Dopri=function(r,e,n,t,o,i,u){this.x=r,this.y=e,this.f=n,this.ymid=t,this.iterations=o,this.events=u,this.message=i},numeric.Dopri.prototype._at=function(r,e){function n(r){return r*r}var t,o,i,u,a,s,c,l,f,m=this,h=m.x,d=m.y,p=m.f,g=m.ymid,v=(h.length,Math.floor,numeric.add),y=numeric.mul,x=numeric.sub;return t=h[e],o=h[e+1],u=d[e],a=d[e+1],i=t+.5*(o-t),s=g[e],c=x(p[e],y(u,1/(t-i)+2/(t-o))),l=x(p[e+1],y(a,1/(o-i)+2/(o-t))),v(v(v(v(y(u,(f=[n(r-o)*(r-i)/n(t-o)/(t-i),n(r-t)*n(r-o)/n(t-i)/n(o-i),n(r-t)*(r-i)/n(o-t)/(o-i),(r-t)*n(r-o)*(r-i)/n(t-o)/(t-i),(r-o)*n(r-t)*(r-i)/n(t-o)/(o-i)])[0]),y(s,f[1])),y(a,f[2])),y(c,f[3])),y(l,f[4]))},numeric.Dopri.prototype.at=function(r){var e,n,t,o=Math.floor;if("number"!=typeof r){var i=r.length,u=Array(i);for(e=i-1;-1!==e;--e)u[e]=this.at(r[e]);return u}var a=this.x;for(e=0,n=a.length-1;n-e>1;)a[t=o(.5*(e+n))]<=r?e=t:n=t;return this._at(r,e)},numeric.dopri=function(r,e,n,t,o,i,u){void 0===o&&(o=1e-6),void 0===i&&(i=1e3);var a,s,c,l,f,m,h,d,p,g,v,y,x,w=[r],b=[n],T=[t(r,n)],C=[],M=[.075,.225],_=[44/45,-56/15,32/9],S=[19372/6561,-25360/2187,64448/6561,-212/729],A=[9017/3168,-355/33,46732/5247,49/176,-5103/18656],k=[35/384,0,500/1113,125/192,-2187/6784,11/84],O=[.10013431883002395,0,.3918321794184259,-.02982460176594817,.05893268337240795,-.04497888809104361,.023904308236133973],P=[.2,.3,.8,8/9,1,1],N=[-71/57600,0,71/16695,-71/1920,17253/339200,-22/525,.025],j=0,q=(e-r)/10,E=0,R=numeric.add,L=numeric.mul,Y=(Math.max,Math.min),V=Math.abs,F=numeric.norminf,X=Math.pow,I=numeric.any,B=numeric.lt,D=numeric.and,G=(numeric.sub,new numeric.Dopri(w,b,T,C,-1,""));for("function"==typeof u&&(v=u(r,n));r<e&&E<i;)if(++E,r+q>e&&(q=e-r),a=t(r+P[0]*q,R(n,L(.2*q,T[j]))),s=t(r+P[1]*q,R(R(n,L(M[0]*q,T[j])),L(M[1]*q,a))),c=t(r+P[2]*q,R(R(R(n,L(_[0]*q,T[j])),L(_[1]*q,a)),L(_[2]*q,s))),l=t(r+P[3]*q,R(R(R(R(n,L(S[0]*q,T[j])),L(S[1]*q,a)),L(S[2]*q,s)),L(S[3]*q,c))),f=t(r+P[4]*q,R(R(R(R(R(n,L(A[0]*q,T[j])),L(A[1]*q,a)),L(A[2]*q,s)),L(A[3]*q,c)),L(A[4]*q,l))),m=t(r+q,p=R(R(R(R(R(n,L(T[j],q*k[0])),L(s,q*k[2])),L(c,q*k[3])),L(l,q*k[4])),L(f,q*k[5]))),(g="number"==typeof(h=R(R(R(R(R(L(T[j],q*N[0]),L(s,q*N[2])),L(c,q*N[3])),L(l,q*N[4])),L(f,q*N[5])),L(m,q*N[6])))?V(h):F(h))>o){if(r+(q=.2*q*X(o/g,.25))===r){G.msg="Step size became too small";break}}else{if(C[j]=R(R(R(R(R(R(n,L(T[j],q*O[0])),L(s,q*O[2])),L(c,q*O[3])),L(l,q*O[4])),L(f,q*O[5])),L(m,q*O[6])),w[++j]=r+q,b[j]=p,T[j]=m,"function"==typeof u){var U,H,W=r,$=r+.5*q;if(y=u($,C[j-1]),I(x=D(B(v,0),B(0,y)))||(W=$,v=y,y=u($=r+q,p),x=D(B(v,0),B(0,y))),I(x)){for(var z,K,Q=0,Z=1,J=1;;){if("number"==typeof v)H=(J*y*W-Z*v*$)/(J*y-Z*v);else for(H=$,d=v.length-1;-1!==d;--d)v[d]<0&&y[d]>0&&(H=Y(H,(J*y[d]*W-Z*v[d]*$)/(J*y[d]-Z*v[d])));if(H<=W||H>=$)break;K=u(H,U=G._at(H,j-1)),I(z=D(B(v,0),B(0,K)))?($=H,y=K,x=z,J=1,-1===Q?Z*=.5:Z=1,Q=-1):(W=H,v=K,Z=1,1===Q?J*=.5:J=1,Q=1)}return p=G._at(.5*(r+H),j-1),G.f[j]=t(H,U),G.x[j]=H,G.y[j]=U,G.ymid[j-1]=p,G.events=x,G.iterations=E,G}}r+=q,n=p,v=y,q=Y(.8*q*X(o/g,.25),4*q)}return G.iterations=E,G},numeric.LU=function(r,e){e=e||!1;var n,t,o,i,u,a,s,c,l,f=Math.abs,m=r.length,h=m-1,d=new Array(m);for(e||(r=numeric.clone(r)),o=0;o<m;++o){for(s=o,l=f((a=r[o])[o]),t=o+1;t<m;++t)l<(i=f(r[t][o]))&&(l=i,s=t);for(d[o]=s,s!=o&&(r[o]=r[s],r[s]=a,a=r[o]),u=a[o],n=o+1;n<m;++n)r[n][o]/=u;for(n=o+1;n<m;++n){for(c=r[n],t=o+1;t<h;++t)c[t]-=c[o]*a[t],c[++t]-=c[o]*a[t];t===h&&(c[t]-=c[o]*a[t])}}return{LU:r,P:d}},numeric.LUsolve=function(r,e){var n,t,o,i,u,a=r.LU,s=a.length,c=numeric.clone(e),l=r.P;for(n=s-1;-1!==n;--n)c[n]=e[n];for(n=0;n<s;++n)for(o=l[n],l[n]!==n&&(u=c[n],c[n]=c[o],c[o]=u),i=a[n],t=0;t<n;++t)c[n]-=c[t]*i[t];for(n=s-1;n>=0;--n){for(i=a[n],t=n+1;t<s;++t)c[n]-=c[t]*i[t];c[n]/=i[n]}return c},numeric.solve=function(r,e,n){return numeric.LUsolve(numeric.LU(r,n),e)},numeric.echelonize=function(r){var e,n,t,o,i,u,a,s,c=numeric.dim(r),l=c[0],f=c[1],m=numeric.identity(l),h=Array(l),d=Math.abs,p=numeric.diveq;for(r=numeric.clone(r),e=0;e<l;++e){for(t=0,i=r[e],u=m[e],n=1;n<f;++n)d(i[t])<d(i[n])&&(t=n);for(h[e]=t,p(u,i[t]),p(i,i[t]),n=0;n<l;++n)if(n!==e){for(s=(a=r[n])[t],o=f-1;-1!==o;--o)a[o]-=i[o]*s;for(a=m[n],o=l-1;-1!==o;--o)a[o]-=u[o]*s}}return{I:m,A:r,P:h}},numeric.__solveLP=function(r,e,n,t,o,i,u){var a,s,c,l,f=numeric.sum,m=(numeric.log,numeric.mul),h=numeric.sub,d=numeric.dot,p=numeric.div,g=numeric.add,v=r.length,y=n.length,x=!1,w=1,b=(numeric.transpose(e),numeric.svd,numeric.transpose),T=(numeric.leq,Math.sqrt),C=Math.abs,M=(numeric.muleq,numeric.norminf,numeric.any,Math.min),_=numeric.all,S=numeric.gt,A=Array(v),k=Array(y),O=(numeric.rep([y],1),numeric.solve),P=h(n,d(e,i)),N=d(r,r);for(c=0;c<o;++c){var j,q;for(j=y-1;-1!==j;--j)k[j]=p(e[j],P[j]);var E=b(k);for(j=v-1;-1!==j;--j)A[j]=f(E[j]);w=.25*C(N/d(r,A));var R=100*T(N/d(A,A));for((!isFinite(w)||w>R)&&(w=R),l=g(r,m(w,A)),s=d(E,k),j=v-1;-1!==j;--j)s[j][j]+=1;q=O(s,p(l,w),!0);var L=p(P,d(e,q)),Y=1;for(j=y-1;-1!==j;--j)L[j]<0&&(Y=M(Y,-.999*L[j]));if(a=h(i,m(q,Y)),!_(S(P=h(n,d(e,a)),0)))return{solution:i,message:"",iterations:c};if(i=a,w<t)return{solution:a,message:"",iterations:c};if(u){var V=d(r,l),F=d(e,l);for(x=!0,j=y-1;-1!==j;--j)if(V*F[j]<0){x=!1;break}}else x=!(i[v-1]>=0);if(x)return{solution:a,message:"Unbounded",iterations:c}}return{solution:i,message:"maximum iteration count exceeded",iterations:c}},numeric._solveLP=function(r,e,n,t,o){var i=r.length,u=n.length,a=(numeric.sum,numeric.log,numeric.mul,numeric.sub),s=numeric.dot,c=(numeric.div,numeric.add,numeric.rep([i],0).concat([1])),l=numeric.rep([u,1],-1),f=numeric.blockMatrix([[e,l]]),m=n,h=numeric.rep([i],0).concat(Math.max(0,numeric.sup(numeric.neg(n)))+1),d=numeric.__solveLP(c,f,m,t,o,h,!1),p=numeric.clone(d.solution);if(p.length=i,numeric.inf(a(n,s(e,p)))<0)return{solution:NaN,message:"Infeasible",iterations:d.iterations};var g=numeric.__solveLP(r,e,n,t,o-d.iterations,p,!0);return g.iterations+=d.iterations,g},numeric.solveLP=function(r,e,n,t,o,i,u){if(void 0===u&&(u=1e3),void 0===i&&(i=numeric.epsilon),void 0===t)return numeric._solveLP(r,e,n,i,u);var a,s=t.length,c=t[0].length,l=e.length,f=numeric.echelonize(t),m=numeric.rep([c],0),h=f.P,d=[];for(a=h.length-1;-1!==a;--a)m[h[a]]=1;for(a=c-1;-1!==a;--a)0===m[a]&&d.push(a);var p=numeric.getRange,g=numeric.linspace(0,s-1),v=numeric.linspace(0,l-1),y=p(t,g,d),x=p(e,v,h),w=p(e,v,d),b=numeric.dot,T=numeric.sub,C=b(x,f.I),M=T(w,b(C,y)),_=T(n,b(C,o)),S=Array(h.length),A=Array(d.length);for(a=h.length-1;-1!==a;--a)S[a]=r[h[a]];for(a=d.length-1;-1!==a;--a)A[a]=r[d[a]];var k=T(A,b(S,b(f.I,y))),O=numeric._solveLP(k,M,_,i,u),P=O.solution;if(P!=P)return O;var N=b(f.I,T(o,b(y,P))),j=Array(r.length);for(a=h.length-1;-1!==a;--a)j[h[a]]=N[a];for(a=d.length-1;-1!==a;--a)j[d[a]]=P[a];return{solution:j,message:O.message,iterations:O.iterations}},numeric.MPStoLP=function(r){function e(e){throw new Error("MPStoLP: "+e+"\nLine "+n+": "+r[n]+"\nCurrent state: "+a[u]+"\n")}r instanceof String&&r.split("\n");var n,t,o,i,u=0,a=["Initial state","NAME","ROWS","COLUMNS","RHS","BOUNDS","ENDATA"],s=r.length,c=0,l={},f=[],m=0,h={},d=0,p=[],g=[],v=[];for(n=0;n<s;++n){var y=(o=r[n]).match(/\S*/g),x=[];for(t=0;t<y.length;++t)""!==y[t]&&x.push(y[t]);if(0!==x.length){for(t=0;t<a.length&&o.substr(0,a[t].length)!==a[t];++t);if(t<a.length){if(u=t,1===t&&(i=x[1]),6===t)return{name:i,c:p,A:numeric.transpose(g),b:v,rows:l,vars:h}}else switch(u){case 0:case 1:e("Unexpected line");case 2:switch(x[0]){case"N":0===c?c=x[1]:e("Two or more N rows");break;case"L":l[x[1]]=m,f[m]=1,v[m]=0,++m;break;case"G":l[x[1]]=m,f[m]=-1,v[m]=0,++m;break;case"E":l[x[1]]=m,f[m]=0,v[m]=0,++m;break;default:e("Parse error "+numeric.prettyPrint(x))}break;case 3:h.hasOwnProperty(x[0])||(h[x[0]]=d,p[d]=0,g[d]=numeric.rep([m],0),++d);var w=h[x[0]];for(t=1;t<x.length;t+=2)if(x[t]!==c){var b=l[x[t]];g[w][b]=(f[b]<0?-1:1)*parseFloat(x[t+1])}else p[w]=parseFloat(x[t+1]);break;case 4:for(t=1;t<x.length;t+=2)v[l[x[t]]]=(f[l[x[t]]]<0?-1:1)*parseFloat(x[t+1]);break;case 5:break;case 6:e("Internal error")}}}e("Reached end of file without ENDATA")},numeric.seedrandom={pow:Math.pow,random:Math.random},function(r,e,n,t,o,i,u){function a(r){var e,t,o=this,i=r.length,u=0,a=o.i=o.j=o.m=0;for(o.S=[],o.c=[],i||(r=[i++]);u<n;)o.S[u]=u++;for(u=0;u<n;u++)a=l(a+(e=o.S[u])+r[u%i]),t=o.S[a],o.S[u]=t,o.S[a]=e;o.g=function(r){var e=o.S,t=l(o.i+1),i=e[t],u=l(o.j+i),a=e[u];e[t]=a,e[u]=i;for(var s=e[l(i+a)];--r;)t=l(t+1),a=e[u=l(u+(i=e[t]))],e[t]=a,e[u]=i,s=s*n+e[l(i+a)];return o.i=t,o.j=u,s},o.g(n)}function s(r,e,n,t,o){if(n=[],o=typeof r,e&&"object"==o)for(t in r)if(t.indexOf("S")<5)try{n.push(s(r[t],e-1))}catch(r){}return n.length?n:r+("string"!=o?"\0":"")}function c(r,e,n,t){for(r+="",n=0,t=0;t<r.length;t++)e[l(t)]=l((n^=19*e[l(t)])+r.charCodeAt(t));for(t in r="",e)r+=String.fromCharCode(e[t]);return r}function l(r){return r&n-1}e.seedrandom=function(t,l){var f,m=[];return t=c(s(l?[t,r]:arguments.length?t:[(new Date).getTime(),r,window],3),m),c((f=new a(m)).S,r),e.random=function(){for(var r=f.g(6),e=u,t=0;r<o;)r=(r+t)*n,e*=n,t=f.g(1);for(;r>=i;)r/=2,e/=2,t>>>=1;return(r+t)/e},t},u=e.pow(n,6),o=e.pow(2,o),i=2*o,c(e.random(),r)}([],numeric.seedrandom,256,0,52),function(r){function e(r){if("object"!=typeof r)return r;var n,t=[],o=r.length;for(n=0;n<o;n++)t[n+1]=e(r[n]);return t}function n(r){if("object"!=typeof r)return r;var e,t=[],o=r.length;for(e=1;e<o;e++)t[e-1]=n(r[e]);return t}r.solveQP=function(r,t,o,i,u,a){r=e(r),t=e(t),o=e(o);var s,c,l,f,m,h=[],d=[],p=[],g=[],v=[];if(u=u||0,a=a?e(a):[void 0,0],i=i?e(i):[],c=r.length-1,l=o[1].length-1,!i)for(s=1;s<=l;s+=1)i[s]=0;for(s=1;s<=l;s+=1)d[s]=0;for(f=Math.min(c,l),s=1;s<=c;s+=1)p[s]=0;for(h[1]=0,s=1;s<=2*c+f*(f+5)/2+2*l+1;s+=1)g[s]=0;for(s=1;s<=2;s+=1)v[s]=0;return function(r,e,n,t,o,i,u,a,s,c,l,f,m,h,d,p){function g(){for(h[1]=h[1]+1,C=P,b=1;b<=c;b+=1){for(C+=1,L=-a[b],T=1;T<=t;T+=1)L+=u[T][b]*o[T];if(Math.abs(L)<G&&(L=0),b>l)d[C]=L;else if(d[C]=-Math.abs(L),L>0){for(T=1;T<=t;T+=1)u[T][b]=-u[T][b];a[b]=-a[b]}}for(b=1;b<=m;b+=1)d[P+f[b]]=0;for(j=0,R=0,b=1;b<=c;b+=1)d[P+b]<R*d[E+b]&&(j=b,R=d[P+b]/d[E+b]);return 0===j?999:0}function v(){for(b=1;b<=t;b+=1){for(L=0,T=1;T<=t;T+=1)L+=r[T][b]*u[T][j];d[b]=L}for(M=A,b=1;b<=t;b+=1)d[M+b]=0;for(T=m+1;T<=t;T+=1)for(b=1;b<=t;b+=1)d[M+b]=d[M+b]+r[b][T]*d[T];for(B=!0,b=m;b>=1;b-=1){for(L=d[b],M=(C=O+b*(b+3)/2)-b,T=b+1;T<=m;T+=1)L-=d[C]*d[k+T],C+=T;if(L/=d[M],d[k+b]=L,f[b]<l)break;if(L<0)break;B=!1,S=b}if(!B)for(Y=d[N+S]/d[k+S],b=1;b<=m&&!(f[b]<l)&&!(d[k+b]<0);b+=1)(R=d[N+b]/d[k+b])<Y&&(Y=R,S=b);for(L=0,b=A+1;b<=A+t;b+=1)L+=d[b]*d[b];if(Math.abs(L)<=G){if(B)return p[1]=1,999;for(b=1;b<=m;b+=1)d[N+b]=d[N+b]-Y*d[k+b];return d[N+m+1]=d[N+m+1]+Y,700}for(L=0,b=1;b<=t;b+=1)L+=d[A+b]*u[b][j];for(V=-d[P+j]/L,D=!0,B||Y<V&&(V=Y,D=!1),b=1;b<=t;b+=1)o[b]=o[b]+V*d[A+b],Math.abs(o[b])<G&&(o[b]=0);for(i[1]=i[1]+V*L*(V/2+d[N+m+1]),b=1;b<=m;b+=1)d[N+b]=d[N+b]-V*d[k+b];if(d[N+m+1]=d[N+m+1]+V,!D){for(L=-a[j],T=1;T<=t;T+=1)L+=o[T]*u[T][j];if(j>l)d[P+j]=L;else if(d[P+j]=-Math.abs(L),L>0){for(T=1;T<=t;T+=1)u[T][j]=-u[T][j];a[j]=-a[j]}return 700}for(f[m+=1]=j,C=O+(m-1)*m/2+1,b=1;b<=m-1;b+=1)d[C]=d[b],C+=1;if(m===t)d[C]=d[t];else{for(b=t;b>=m+1&&0!==d[b]&&(F=Math.max(Math.abs(d[b-1]),Math.abs(d[b])),X=Math.min(Math.abs(d[b-1]),Math.abs(d[b])),R=d[b-1]>=0?Math.abs(F*Math.sqrt(1+X*X/(F*F))):-Math.abs(F*Math.sqrt(1+X*X/(F*F))),F=d[b-1]/R,X=d[b]/R,1!==F);b-=1)if(0===F)for(d[b-1]=X*R,T=1;T<=t;T+=1)R=r[T][b-1],r[T][b-1]=r[T][b],r[T][b]=R;else for(d[b-1]=R,I=X/(1+F),T=1;T<=t;T+=1)R=F*r[T][b-1]+X*r[T][b],r[T][b]=I*(r[T][b-1]+R)-r[T][b],r[T][b-1]=R;d[C]=d[m]}return 0}function y(){if(0===d[M=(C=O+S*(S+1)/2+1)+S])return 798;if(F=Math.max(Math.abs(d[M-1]),Math.abs(d[M])),X=Math.min(Math.abs(d[M-1]),Math.abs(d[M])),R=d[M-1]>=0?Math.abs(F*Math.sqrt(1+X*X/(F*F))):-Math.abs(F*Math.sqrt(1+X*X/(F*F))),F=d[M-1]/R,X=d[M]/R,1===F)return 798;if(0===F){for(b=S+1;b<=m;b+=1)R=d[M-1],d[M-1]=d[M],d[M]=R,M+=b;for(b=1;b<=t;b+=1)R=r[b][S],r[b][S]=r[b][S+1],r[b][S+1]=R}else{for(I=X/(1+F),b=S+1;b<=m;b+=1)R=F*d[M-1]+X*d[M],d[M]=I*(d[M-1]+R)-d[M],d[M-1]=R,M+=b;for(b=1;b<=t;b+=1)R=F*r[b][S]+X*r[b][S+1],r[b][S+1]=I*(r[b][S]+R)-r[b][S+1],r[b][S]=R}return 0}function x(){for(M=C-S,b=1;b<=S;b+=1)d[M]=d[C],C+=1,M+=1;return d[N+S]=d[N+S+1],f[S]=f[S+1],(S+=1)<m?797:0}function w(){return d[N+m]=d[N+m+1],d[N+m+1]=0,f[m]=0,m-=1,h[2]=h[2]+1,0}var b,T,C,M,_,S,A,k,O,P,N,j,q,E,R,L,Y,V,F,X,I,B,D,G,U,H,W;q=Math.min(t,c),C=2*t+q*(q+5)/2+2*c+1,G=1e-60;do{U=1+.1*(G+=G),H=1+.2*G}while(U<=1||H<=1);for(b=1;b<=t;b+=1)d[b]=e[b];for(b=t+1;b<=C;b+=1)d[b]=0;for(b=1;b<=c;b+=1)f[b]=0;if(_=[],0===p[1]){if(function(r,e,n,t){var o,i,u,a,s,c;for(i=1;i<=n;i+=1){if(t[1]=i,c=0,(u=i-1)<1){if((c=r[i][i]-c)<=0)break;r[i][i]=Math.sqrt(c)}else{for(a=1;a<=u;a+=1){for(s=r[a][i],o=1;o<a;o+=1)s-=r[o][i]*r[o][a];s/=r[a][a],r[a][i]=s,c+=s*s}if((c=r[i][i]-c)<=0)break;r[i][i]=Math.sqrt(c)}t[1]=0}}(r,0,t,_),0!==_[1])return void(p[1]=2);(function(r,e,n,t){var o,i,u,a;for(i=1;i<=n;i+=1){for(a=0,o=1;o<i;o+=1)a+=r[o][i]*t[o];t[i]=(t[i]-a)/r[i][i]}for(u=1;u<=n;u+=1)for(t[i=n+1-u]=t[i]/r[i][i],a=-t[i],o=1;o<i;o+=1)t[o]=t[o]+a*r[o][i]})(r,0,t,e),function(r,e,n){var t,o,i,u,a;for(i=1;i<=n;i+=1){for(r[i][i]=1/r[i][i],a=-r[i][i],t=1;t<i;t+=1)r[t][i]=a*r[t][i];if(n<(u=i+1))break;for(o=u;o<=n;o+=1)for(a=r[i][o],r[i][o]=0,t=1;t<=i;t+=1)r[t][o]=r[t][o]+a*r[t][i]}}(r,0,t)}else{for(T=1;T<=t;T+=1)for(o[T]=0,b=1;b<=T;b+=1)o[T]=o[T]+r[b][T]*e[b];for(T=1;T<=t;T+=1)for(e[T]=0,b=T;b<=t;b+=1)e[T]=e[T]+r[T][b]*o[b]}for(i[1]=0,T=1;T<=t;T+=1)for(o[T]=e[T],i[1]=i[1]+d[T]*o[T],d[T]=0,b=T+1;b<=t;b+=1)r[b][T]=0;for(i[1]=-i[1]/2,p[1]=0,E=(P=(O=(N=(k=(A=t)+t)+q)+q+1)+q*(q+1)/2)+c,b=1;b<=c;b+=1){for(L=0,T=1;T<=t;T+=1)L+=u[T][b]*u[T][b];d[E+b]=Math.sqrt(L)}for(m=0,h[1]=0,h[2]=0,W=0;;){if(999===(W=g()))return;for(;0!==(W=v());){if(999===W)return;if(700===W)if(S===m)w();else{for(;y(),797===(W=x()););w()}}}}(r,t,0,c,p,h,o,i,0,l,u,d,0,v,g,a),m="",1===a[1]&&(m="constraints are inconsistent, no solution!"),2===a[1]&&(m="matrix D in quadratic function is not positive definite!"),{solution:n(p),value:n(h),unconstrained_solution:n(t),iterations:n(v),iact:n(d),message:m}}}(numeric),numeric.svd=function(r){function e(r,e){return(r=Math.abs(r))>(e=Math.abs(e))?r*Math.sqrt(1+e*e/r/r):0==e?r:e*Math.sqrt(1+r*r/e/e)}var n,t=numeric.epsilon,o=1e-64/t,i=0,u=0,a=0,s=0,c=0,l=numeric.clone(r),f=l.length,m=l[0].length;if(f<m)throw"Need more rows than columns";var h=new Array(m),d=new Array(m);for(u=0;u<m;u++)h[u]=d[u]=0;var p=numeric.rep([m,m],0),g=0,v=0,y=0,x=0,w=0,b=0,T=0;for(u=0;u<m;u++){for(h[u]=v,T=0,c=u+1,a=u;a<f;a++)T+=l[a][u]*l[a][u];if(T<=o)v=0;else for(g=l[u][u],v=Math.sqrt(T),g>=0&&(v=-v),y=g*v-T,l[u][u]=g-v,a=c;a<m;a++){for(T=0,s=u;s<f;s++)T+=l[s][u]*l[s][a];for(g=T/y,s=u;s<f;s++)l[s][a]+=g*l[s][u]}for(d[u]=v,T=0,a=c;a<m;a++)T+=l[u][a]*l[u][a];if(T<=o)v=0;else{for(g=l[u][u+1],v=Math.sqrt(T),g>=0&&(v=-v),y=g*v-T,l[u][u+1]=g-v,a=c;a<m;a++)h[a]=l[u][a]/y;for(a=c;a<f;a++){for(T=0,s=c;s<m;s++)T+=l[a][s]*l[u][s];for(s=c;s<m;s++)l[a][s]+=T*h[s]}}(w=Math.abs(d[u])+Math.abs(h[u]))>x&&(x=w)}for(u=m-1;-1!=u;u+=-1){if(0!=v){for(y=v*l[u][u+1],a=c;a<m;a++)p[a][u]=l[u][a]/y;for(a=c;a<m;a++){for(T=0,s=c;s<m;s++)T+=l[u][s]*p[s][a];for(s=c;s<m;s++)p[s][a]+=T*p[s][u]}}for(a=c;a<m;a++)p[u][a]=0,p[a][u]=0;p[u][u]=1,v=h[u],c=u}for(u=m-1;-1!=u;u+=-1){for(c=u+1,v=d[u],a=c;a<m;a++)l[u][a]=0;if(0!=v){for(y=l[u][u]*v,a=c;a<m;a++){for(T=0,s=c;s<f;s++)T+=l[s][u]*l[s][a];for(g=T/y,s=u;s<f;s++)l[s][a]+=g*l[s][u]}for(a=u;a<f;a++)l[a][u]=l[a][u]/v}else for(a=u;a<f;a++)l[a][u]=0;l[u][u]+=1}for(t*=x,s=m-1;-1!=s;s+=-1)for(var C=0;C<50;C++){var M=!1;for(c=s;-1!=c;c+=-1){if(Math.abs(h[c])<=t){M=!0;break}if(Math.abs(d[c-1])<=t)break}if(!M){i=0,T=1;var _=c-1;for(u=c;u<s+1&&(g=T*h[u],h[u]=i*h[u],!(Math.abs(g)<=t));u++)for(y=e(g,v=d[u]),d[u]=y,i=v/y,T=-g/y,a=0;a<f;a++)w=l[a][_],b=l[a][u],l[a][_]=w*i+b*T,l[a][u]=-w*T+b*i}if(b=d[s],c==s){if(b<0)for(d[s]=-b,a=0;a<m;a++)p[a][s]=-p[a][s];break}if(C>=49)throw"Error: no convergence.";for(x=d[c],v=e(g=(((w=d[s-1])-b)*(w+b)+((v=h[s-1])-(y=h[s]))*(v+y))/(2*y*w),1),g=g<0?((x-b)*(x+b)+y*(w/(g-v)-y))/x:((x-b)*(x+b)+y*(w/(g+v)-y))/x,i=1,T=1,u=c+1;u<s+1;u++){for(v=h[u],w=d[u],y=T*v,v*=i,b=e(g,y),h[u-1]=b,g=x*(i=g/b)+v*(T=y/b),v=-x*T+v*i,y=w*T,w*=i,a=0;a<m;a++)x=p[a][u-1],b=p[a][u],p[a][u-1]=x*i+b*T,p[a][u]=-x*T+b*i;for(b=e(g,y),d[u-1]=b,g=(i=g/b)*v+(T=y/b)*w,x=-T*v+i*w,a=0;a<f;a++)w=l[a][u-1],b=l[a][u],l[a][u-1]=w*i+b*T,l[a][u]=-w*T+b*i}h[c]=0,h[s]=g,d[s]=x}for(u=0;u<d.length;u++)d[u]<t&&(d[u]=0);for(u=0;u<m;u++)for(a=u-1;a>=0;a--)if(d[a]<d[u]){for(i=d[a],d[a]=d[u],d[u]=i,s=0;s<l.length;s++)n=l[s][u],l[s][u]=l[s][a],l[s][a]=n;for(s=0;s<p.length;s++)n=p[s][u],p[s][u]=p[s][a],p[s][a]=n;u=a}return{U:l,S:d,V:p}}},111:(r,e,n)=>{"use strict";function t(r){r.sort();const e=r[Math.trunc(r.length/4)],n=r.length%2==0?(r[Math.trunc(r.length/2)]+r[Math.trunc(r.length/2)-1])/2:r[Math.trunc(r.length/2)],t=r[Math.trunc(3*r.length/4)],i=1.5*(t-e);let u=o(r,t+i);u<0&&(u=~u);let a=r[Math.max(0,u-1)];a<t&&(a=t);let s=o(r,e-i);s<0&&(s=~s);let c=r[s];return c>e&&(c=e),{q1:e,q2:n,q3:t,lowerAdjacentValue:c,upperAdjacentValue:a}}function o(r,e,n=0,t){if(0===r.length)return-1;if(void 0===t&&(t=r.length-1),e<r[n])return-1;if(e>r[t])return-(t+1);for(;t-n>1;){const o=Math.trunc((t+n)/2);if(e===r[o])return o;e<r[o]?t=o:n=o}return r[n]===e?n:0===r[t]?t:e<r[n]?-(n+1):-(t+1)}n.d(e,{G:()=>t})},875:(r,e,n)=>{"use strict";n.d(e,{K0:()=>g,Kp:()=>c,Qc:()=>l,XD:()=>f,ZY:()=>C,aC:()=>A,cY:()=>h,d8:()=>s,hR:()=>_,iC:()=>M,j2:()=>a,js:()=>u,kW:()=>p,sw:()=>d,ue:()=>S,vK:()=>m,yB:()=>v});var t=n(976),o=n(78),i=n(162);const u={CONSTANT:"constant",PROPORTIONAL:"proportional"},a="fit",s="fit",c=".fit",l="rgba(255,191,63,0.4)",f="rgba(255,238,204,0.3)",m={TOP:"top",BOTTOM:"bottom"};class h{constructor(){this.chartOptions={},this.seriesOptions={},this.series=[]}}const d=[t.Property.js("rSquared",t.TYPE.FLOAT,{userEditable:!1}),t.Property.js("auc",t.TYPE.FLOAT,{userEditable:!1}),t.Property.js("interceptY",t.TYPE.FLOAT,{userEditable:!1}),t.Property.js("interceptX",t.TYPE.FLOAT,{userEditable:!1}),t.Property.js("slope",t.TYPE.FLOAT,{userEditable:!1}),t.Property.js("top",t.TYPE.FLOAT,{userEditable:!1}),t.Property.js("bottom",t.TYPE.FLOAT,{userEditable:!1})],p=[t.Property.js("minX",t.TYPE.FLOAT,{description:"Minimum value of the X axis",nullable:!0}),t.Property.js("minY",t.TYPE.FLOAT,{description:"Minimum value of the Y axis",nullable:!0}),t.Property.js("maxX",t.TYPE.FLOAT,{description:"Maximum value of the X axis",nullable:!0}),t.Property.js("maxY",t.TYPE.FLOAT,{description:"Maximum value of the Y axis",nullable:!0}),t.Property.js("title",t.TYPE.STRING,{nullable:!0}),t.Property.js("xAxisName",t.TYPE.STRING,{description:"Label to show on the X axis. If not specified, corresponding data column name is used",nullable:!0}),t.Property.js("yAxisName",t.TYPE.STRING,{description:"Label to show on the Y axis. If not specified, corresponding data column name is used",nullable:!0}),t.Property.js("logX",t.TYPE.BOOL,{description:"Whether the X axis should be logarithmic",defaultValue:!1}),t.Property.js("logY",t.TYPE.BOOL,{description:"Whether the Y axis should be logarithmic",defaultValue:!1}),t.Property.js("allowXZeroes",t.TYPE.BOOL,{description:"Whether x zeroes allowed for logarithmic data or not",defaultValue:!0}),t.Property.js("mergeSeries",t.TYPE.BOOL,{description:"Whether to merge series or not",defaultValue:!1}),t.Property.js("showColumnLabel",t.TYPE.BOOL,{description:"Whether to show the column label in the legend or not",defaultValue:!1}),t.Property.js("showStatistics",t.TYPE.STRING_LIST,{description:"Whether specific statistics should be rendered",choices:d.map((r=>r.name)),inputType:"MultiChoice",friendlyName:"Statistics"})],g=[t.Property.js("fitFunction",t.TYPE.STRING,{category:"Fitting",choices:["sigmoid","linear"],defaultValue:"sigmoid"}),t.Property.js("pointColor",t.TYPE.STRING,{category:"Rendering",nullable:!0,inputType:"Color"}),t.Property.js("fitLineColor",t.TYPE.STRING,{category:"Rendering",nullable:!0,inputType:"Color"}),t.Property.js("outlierColor",t.TYPE.STRING,{category:"Rendering",nullable:!0,inputType:"Color"}),t.Property.js("errorModel",t.TYPE.STRING,{category:"Fitting",defaultValue:"constant",choices:["constant","proportional"],nullable:!1}),t.Property.js("connectDots",t.TYPE.BOOL,{category:"Fitting",defaultValue:!1}),t.Property.js("clickToToggle",t.TYPE.BOOL,{category:"Fitting",description:"Click on a point to mark it as outlier and refit",nullable:!0,defaultValue:!1}),t.Property.js("showFitLine",t.TYPE.BOOL,{category:"Fitting",defaultValue:!0}),t.Property.js("showPoints",t.TYPE.STRING,{category:"Fitting",description:"Whether points/candlesticks/none should be rendered",defaultValue:"points",choices:["points","candlesticks","both"]}),t.Property.js("showCurveConfidenceInterval",t.TYPE.BOOL,{category:"Fitting",description:"Whether confidence intervals should be rendered",defaultValue:!1,friendlyName:"Confidence Interval"}),t.Property.js("markerType",t.TYPE.STRING,{category:"Rendering",defaultValue:"circle",choices:["asterisk","circle","cross border","diamond","square","star","triangle bottom","triangle left","triangle right","triangle top"],nullable:!1}),t.Property.js("lineStyle",t.TYPE.STRING,{category:"Rendering",defaultValue:"solid",choices:["solid","dotted","dashed","dashdotted"],nullable:!1}),t.Property.js("droplines",t.TYPE.STRING_LIST,{description:"Whether specific droplines should be rendered",choices:["IC50"],inputType:"MultiChoice"}),t.Property.js("columnName",t.TYPE.STRING,{description:"Column name where the series is stored",defaultValue:""})],v="sigmoid";class y{}class x extends y{constructor(r,e,n,t){super(),this._name=r,this._parameterNames=t,this.y=e,this.getInitialParameters=n}get name(){return this._name}get parameterNames(){return this._parameterNames}y(r,e){throw new Error("Not implemented")}getInitialParameters(r,e){throw new Error("Not implemented")}}const w={linear:new class extends y{get name(){return"linear"}get parameterNames(){return["Slope","Intercept"]}y(r,e){return function(r,e){return r[0]*e+r[1]}(r,e)}getInitialParameters(r,e){let n=0,t=0;for(let e=1;e<r.length;e++)r[e]<r[n]&&(n=e),r[e]>r[t]&&(t=e);const o=r[t]-r[n],i=(e[t]-e[n])/o;return[i,e[t]-i*r[t]]}},sigmoid:new class extends y{get name(){return v}get parameterNames(){return["Top","Bottom","Slope","IC50"]}y(r,e){return function(r,e){const n=r[0],t=r[1],o=r[2],i=r[3];return i+(n-i)/(1+Math.pow(10,(e-o)*t))}(r,e)}getInitialParameters(r,e){const n=t.Rect.fromXYArrays(r,e),o=(n.bottom-n.top)/2+n.top;let i=n.bottom-n.top,u=0;for(let n=0;n<r.length;n++){const r=Math.abs(e[n]-o);r<i&&(i=r,u=n)}const a=r[u],s=e[0]>e[e.length-1]?1:-1;return[n.bottom,s,a,n.top]}}};function b(r){let e;switch(r){case u.CONSTANT:e=N;break;case u.PROPORTIONAL:e=j;break;default:e=N}return e}function T(r,e,n,t){return{getValue:t=>n(e,r,t).value,getGradient:(o,i)=>{for(let u=0;u<o.length;u++)i[u]=t.includes(u)?0:P(n,e,r,o,u);return i}}}function C(r){if("string"==typeof r)return w[r];if(!w[r.name]){const e=r.name,n=r.parameterNames,t=r.function.split("=>").map((r=>r.trim())),o=r.getInitialParameters.split("=>").map((r=>r.trim())),i=new Function(t[0].slice(1,t[0].length-1),`${t[1].includes(";")?"":"return "}${t[1]}`),u=new Function(o[0].slice(1,o[0].length-1),`return ${o[1]}`),a=new x(e,i,u,n);w[e]=a}return w[r.name]}function M(r,e,n,t){var i,u;const a=e.y,s=e.getInitialParameters(r.x,r.y),c=b(n),l=[];let f=!0;for(;f;){const e=T(r,a,c,l);if((0,o.U)(e,s),(0,o.U)(e,s),f=!1,!t)break;for(let r=0;r<t.length;r++){if(void 0!==(null===(i=t[r])||void 0===i?void 0:i.max)&&s[r]>t[r].max){f=!0,l.push(r),s[r]=t[r].max;break}if(void 0!==(null===(u=t[r])||void 0===u?void 0:u.min)&&s[r]<t[r].min){f=!0,l.push(r),s[r]=t[r].min;break}}}return{fittedCurve:_(a,s),parameters:s}}function _(r,e){return n=>r(e,n)}function S(r,e,n,t=.05,o){const a=b(o),s=o===u.PROPORTIONAL?a(n,r,e).mult:a(n,r,e).const,c=i.normal.inv(1-t/2,0,1);return{confidenceTop:r=>{const t=n(e,r);return o===u.CONSTANT?t+c*s:t+c*Math.abs(t)*s},confidenceBottom:r=>{const t=n(e,r);return o===u.CONSTANT?t-c*s:t-c*Math.abs(t)*s}}}function A(r,e,n,t=!0){const o=_(n,e);return{rSquared:t?O(o,r):void 0,auc:t?k(o,r):void 0,interceptX:e[2],interceptY:o(e[2]),slope:e[1],top:e[0],bottom:e[3]}}function k(r,e){let n=0;const t=Math.min(...e.x),o=Math.max(...e.x),i=(o-t)/1e3;for(let e=t;e<o;e+=i)n+=i*r(e);return n}function O(r,e){let n=0,t=0;const o=i.mean(e.y);for(let i=0;i<e.x.length;i++)n+=Math.pow(e.y[i]-r(e.x[i]),2),t+=Math.pow(e.y[i]-o,2);return 1-n/t}function P(r,e,n,t,o){const i=1e-4*t[o]==0?.001:1e-4*t[o],u=[],a=[];for(let r=0;r<t.length;r++)r===o?(u.push(t[r]+i),a.push(t[r]-i)):(u.push(t[r]),a.push(t[r]));return(r(e,n,u).value-r(e,n,a).value)/(2*i)}function N(r,e,n){const t=Math.PI;let o=0,i=0,u=0;const a=new Float32Array(e.x.length);for(let t=0;t<e.x.length;t++){const o=e.y[t],i=r(n,e.x[t]);a[t]=Math.pow(o-i,2)}for(let r=0;r<a.length;r++)i+=a[r];i/=a.length,o=Math.sqrt(i);for(let r=0;r<a.length;r++)u+=a[r]/i+Math.log(2*t*i);return{value:-u,const:o,mult:0}}function j(r,e,n){const t=Math.PI;let o=0,i=0,u=0;const a=new Float32Array(e.x.length);for(let t=0;t<e.x.length;t++){const o=e.y[t],i=r(n,e.x[t]);a[t]=Math.pow(o-i,2)}for(let r=0;r<a.length;r++)i+=a[r];i/=a.length,o=Math.sqrt(i);for(let r=0;r<a.length;r++)u+=a[r]/i+Math.log(2*t*i);return{value:-u,const:0,mult:o}}},416:(r,e,n)=>{"use strict";n.d(e,{LC:()=>p,PK:()=>d,TL:()=>u,Y6:()=>m,dU:()=>f,hq:()=>s,jG:()=>a,kG:()=>h,tq:()=>g});var t=n(976),o=n(875);function i(r){const e={};for(const n of r)null!==n.defaultValue&&(e[n.name]=n.defaultValue);return e}function u(){return{chartOptions:i(o.kW),seriesOptions:i(o.K0)}}function a(r){var e,n;return JSON.parse(null!==(e=(n=r.tags)[o.Kp])&&void 0!==e?e:n[o.Kp]=JSON.stringify(u()))}function s(r){var e,n;return JSON.parse(null!==(e=(n=r.tags)[o.Kp])&&void 0!==e?e:n[o.Kp]=JSON.stringify(u()))}function c(r){const e=[],n=[];for(let t=0;t<r.length;t++)e[t]=r[t].x,n[t]=r[t].y;return{xs:e,ys:n}}function l(r){const e=Math.floor(r.y.length/2),n=r.y.sort(((r,e)=>r-e));return n.length%2==0?(n[e-1]+n[e])/2:n[e]}function f(r){var e;const n=r.chartOptions;if((null===(e=r.series)||void 0===e?void 0:e.length)&&0!==r.series.length){const{xs:e,ys:o}=c(r.series[0].points);let i=t.Rect.fromXYArrays(e,o);for(let e=1;e<r.series.length;e++){const{xs:n,ys:o}=c(r.series[e].points);n.some((r=>void 0===r))||o.some((r=>void 0===r))||(i=i.union(t.Rect.fromXYArrays(n,o)))}return n?function(r,e){let n=r.x,o=r.y,i=r.width,u=r.height;return void 0!==e.minX&&null!==e.minX&&(!e.logX||e.logX&&e.minX>0)&&(i+=n-e.minX,n=e.minX),void 0!==e.maxX&&null!==e.maxX&&(!e.logX||e.logX&&e.maxX>0)&&(i+=e.maxX-(n+i)),void 0!==e.minY&&null!==e.minY&&(!e.logY||e.logY&&e.minY>0)&&(u+=o-e.minY,o=e.minY),void 0!==e.maxY&&null!==e.maxY&&(!e.logY||e.logY&&e.maxY>0)&&(u+=e.maxY-(o+u)),new t.Rect(n,o,i,u)}(i,n):i}return new t.Rect(0,0,1,1)}function m(r){return(0,o.ZY)(r.fitFunction)}function h(r,e){return(0,o.hR)(e.y,r.parameters)}function d(r,e,n){var t;const i={x:r.points.filter((r=>!r.outlier)).map((r=>(null==n?void 0:n.logX)?Math.log10(r.x):r.x)),y:r.points.filter((r=>!r.outlier)).map((r=>(null==n?void 0:n.logY)?Math.log10(r.y):r.y))};var u;return r.parameterBounds&&(null==n?void 0:n.logX)&&(r.parameterBounds[2]=((u=r.parameterBounds[2])&&(void 0!==u.max&&(u.max=Math.log10(u.max)),void 0!==u.min&&(u.min=0===u.min?-Number.MAX_VALUE:Math.log10(u.min))),u)),(0,o.iC)(function(r){const e={x:[],y:[]},n={x:[r.x[0]],y:[r.y[0]]};for(let t=1;t<r.x.length;t++){if(r.x[t]===n.x[0]){n.x[n.x.length]=r.x[t],n.y[n.y.length]=r.y[t];continue}const o=l(n);e.x[e.x.length]=n.x[0],e.y[e.y.length]=o,n.x=[r.x[t]],n.y=[r.y[t]]}const t=l(n);return e.x[e.x.length]=n.x[0],e.y[e.y.length]=t,e}(i),e,null!==(t=r.errorModel)&&void 0!==t?t:o.js.CONSTANT,r.parameterBounds)}function p(r,e,n,t){var i;const u=n?{x:r.points.map((r=>(null==t?void 0:t.logX)?Math.log10(r.x):r.x)),y:r.points.map((r=>(null==t?void 0:t.logY)?Math.log10(r.y):r.y))}:{x:r.points.filter((r=>!r.outlier)).map((r=>(null==t?void 0:t.logX)?Math.log10(r.x):r.x)),y:r.points.filter((r=>!r.outlier)).map((r=>(null==t?void 0:t.logY)?Math.log10(r.y):r.y))};return r.parameters||(r.parameters=d(r,e).parameters),(0,o.ue)(u,r.parameters,e.y,.05,null!==(i=r.errorModel)&&void 0!==i?i:o.js.CONSTANT)}function g(r,e,n){const t={x:r.points.filter((r=>!r.outlier)).map((r=>(null==n?void 0:n.logX)?Math.log10(r.x):r.x)),y:r.points.filter((r=>!r.outlier)).map((r=>(null==n?void 0:n.logY)?Math.log10(r.y):r.y))};return r.parameters||(r.parameters=d(r,e).parameters),(0,o.aC)(t,r.parameters,e.y,!0)}},766:(r,e,n)=>{"use strict";n.d(e,{l:()=>a});var t=n(976);const o=1e-30,i=new class{screenToWorld(r,e,n,t,o){return n+(o?1-r/e:r/e)*(t-n)}worldToScreen(r,e,n,t,o){return o?(1-(r-n)/(t-n))*e:(r-n)/(t-n)*e}},u=new class{screenToWorld(r,e,n,t,i){n=n<o?o:n;const u=Math.log(t),a=Math.log(n);return Math.exp(a+(u-a)*(i?e-r:r)/e)}worldToScreen(r,e,n,t,i){if(r<=0)return NaN;if(Math.abs(r-n)<o)return i?e:0;if(Math.abs(r-t)<o)return i?0:e;n=n<o?o:n,r=r<o?o:r;const u=e*Math.log(r/n)/Math.log(t/n);return i?e-u:u}};class a{get xt(){return this.logX?u:i}get yt(){return this.logY?u:i}constructor(r,e,n=!1,t=!1){this.logX=!1,this.logY=!1,this.inverseX=!1,this.inverseY=!1,this.world=r,this.screen=e,this.logX=n,this.logY=t}xToScreen(r){return this.screen.left+this.xt.worldToScreen(r,this.screen.width,this.world.minX,this.world.maxX,this.inverseX)}yToScreen(r){return this.screen.top+this.yt.worldToScreen(r,this.screen.height,this.world.minY,this.world.maxY,!this.inverseY)}xToWorld(r){return this.xt.screenToWorld(r-this.screen.left,this.screen.width,this.world.minX,this.world.maxX,this.inverseX)}yToWorld(r){return this.yt.screenToWorld(r-this.screen.top,this.screen.height,this.world.minY,this.world.maxY,!this.inverseY)}toScreen(r){return new t.Point(this.xToScreen(r.x),this.yToScreen(r.y))}toWorld(r){return new t.Point(this.xToWorld(r.x),this.yToWorld(r.y))}drawCoordinateGrid(r,e,n){e&&t.Paint.horzAxis(r,this.world.minX,this.world.maxX,e.x,e.y,e.width,e.height,this.logX,this.inverseX),n&&t.Paint.vertAxis(r,this.world.minY,this.world.maxY,n.x,n.y,n.width,n.height,this.logY,this.inverseY)}}},162:function(r){var e;r.exports=(e=function(r,e){var n=Array.prototype.concat,t=Array.prototype.slice,o=Object.prototype.toString;function i(e,n){var t=e>n?e:n;return r.pow(10,17-~~(r.log(t>0?t:-t)*r.LOG10E))}var u=Array.isArray||function(r){return"[object Array]"===o.call(r)};function a(r){return"[object Function]"===o.call(r)}function s(r){return"number"==typeof r&&r-r==0}function c(){return new c._init(arguments)}function l(){return 0}function f(){return 1}function m(r,e){return r===e?1:0}c.fn=c.prototype,c._init=function(r){if(u(r[0]))if(u(r[0][0])){a(r[1])&&(r[0]=c.map(r[0],r[1]));for(var e=0;e<r[0].length;e++)this[e]=r[0][e];this.length=r[0].length}else this[0]=a(r[1])?c.map(r[0],r[1]):r[0],this.length=1;else if(s(r[0]))this[0]=c.seq.apply(null,r),this.length=1;else{if(r[0]instanceof c)return c(r[0].toArray());this[0]=[],this.length=1}return this},c._init.prototype=c.prototype,c._init.constructor=c,c.utils={calcRdx:i,isArray:u,isFunction:a,isNumber:s,toVector:function(r){return n.apply([],r)}},c._random_fn=r.random,c.setRandom=function(r){if("function"!=typeof r)throw new TypeError("fn is not a function");c._random_fn=r},c.extend=function(r){var e,n;if(1===arguments.length){for(n in r)c[n]=r[n];return this}for(e=1;e<arguments.length;e++)for(n in arguments[e])r[n]=arguments[e][n];return r},c.rows=function(r){return r.length||1},c.cols=function(r){return r[0].length||1},c.dimensions=function(r){return{rows:c.rows(r),cols:c.cols(r)}},c.row=function(r,e){return u(e)?e.map((function(e){return c.row(r,e)})):r[e]},c.rowa=function(r,e){return c.row(r,e)},c.col=function(r,e){if(u(e)){var n=c.arange(r.length).map((function(){return new Array(e.length)}));return e.forEach((function(e,t){c.arange(r.length).forEach((function(o){n[o][t]=r[o][e]}))})),n}for(var t=new Array(r.length),o=0;o<r.length;o++)t[o]=[r[o][e]];return t},c.cola=function(r,e){return c.col(r,e).map((function(r){return r[0]}))},c.diag=function(r){for(var e=c.rows(r),n=new Array(e),t=0;t<e;t++)n[t]=[r[t][t]];return n},c.antidiag=function(r){for(var e=c.rows(r)-1,n=new Array(e),t=0;e>=0;e--,t++)n[t]=[r[t][e]];return n},c.transpose=function(r){var e,n,t,o,i,a=[];for(u(r[0])||(r=[r]),n=r.length,t=r[0].length,i=0;i<t;i++){for(e=new Array(n),o=0;o<n;o++)e[o]=r[o][i];a.push(e)}return 1===a.length?a[0]:a},c.map=function(r,e,n){var t,o,i,a,s;for(u(r[0])||(r=[r]),o=r.length,i=r[0].length,a=n?r:new Array(o),t=0;t<o;t++)for(a[t]||(a[t]=new Array(i)),s=0;s<i;s++)a[t][s]=e(r[t][s],t,s);return 1===a.length?a[0]:a},c.cumreduce=function(r,e,n){var t,o,i,a,s;for(u(r[0])||(r=[r]),o=r.length,i=r[0].length,a=n?r:new Array(o),t=0;t<o;t++)for(a[t]||(a[t]=new Array(i)),i>0&&(a[t][0]=r[t][0]),s=1;s<i;s++)a[t][s]=e(a[t][s-1],r[t][s]);return 1===a.length?a[0]:a},c.alter=function(r,e){return c.map(r,e,!0)},c.create=function(r,e,n){var t,o,i=new Array(r);for(a(e)&&(n=e,e=r),t=0;t<r;t++)for(i[t]=new Array(e),o=0;o<e;o++)i[t][o]=n(t,o);return i},c.zeros=function(r,e){return s(e)||(e=r),c.create(r,e,l)},c.ones=function(r,e){return s(e)||(e=r),c.create(r,e,f)},c.rand=function(r,e){return s(e)||(e=r),c.create(r,e,c._random_fn)},c.identity=function(r,e){return s(e)||(e=r),c.create(r,e,m)},c.symmetric=function(r){var e,n,t=r.length;if(r.length!==r[0].length)return!1;for(e=0;e<t;e++)for(n=0;n<t;n++)if(r[n][e]!==r[e][n])return!1;return!0},c.clear=function(r){return c.alter(r,l)},c.seq=function(r,e,n,t){a(t)||(t=!1);var o,u=[],s=i(r,e),c=(e*s-r*s)/((n-1)*s),l=r;for(o=0;l<=e&&o<n;l=(r*s+c*s*++o)/s)u.push(t?t(l,o):l);return u},c.arange=function(r,n,t){var o,i=[];if(t=t||1,n===e&&(n=r,r=0),r===n||0===t)return[];if(r<n&&t<0)return[];if(r>n&&t>0)return[];if(t>0)for(o=r;o<n;o+=t)i.push(o);else for(o=r;o>n;o+=t)i.push(o);return i},c.slice=function(){function r(r,n,t,o){var i,u=[],a=r.length;if(n===e&&t===e&&o===e)return c.copy(r);if(o=o||1,(n=(n=n||0)>=0?n:a+n)===(t=(t=t||r.length)>=0?t:a+t)||0===o)return[];if(n<t&&o<0)return[];if(n>t&&o>0)return[];if(o>0)for(i=n;i<t;i+=o)u.push(r[i]);else for(i=n;i>t;i+=o)u.push(r[i]);return u}return function(e,n){var t,o;return s((n=n||{}).row)?s(n.col)?e[n.row][n.col]:r(c.rowa(e,n.row),(t=n.col||{}).start,t.end,t.step):s(n.col)?r(c.cola(e,n.col),(o=n.row||{}).start,o.end,o.step):(o=n.row||{},t=n.col||{},r(e,o.start,o.end,o.step).map((function(e){return r(e,t.start,t.end,t.step)})))}}(),c.sliceAssign=function(n,t,o){var i,u;if(s(t.row)){if(s(t.col))return n[t.row][t.col]=o;t.col=t.col||{},t.col.start=t.col.start||0,t.col.end=t.col.end||n[0].length,t.col.step=t.col.step||1,i=c.arange(t.col.start,r.min(n.length,t.col.end),t.col.step);var a=t.row;return i.forEach((function(r,e){n[a][r]=o[e]})),n}if(s(t.col)){t.row=t.row||{},t.row.start=t.row.start||0,t.row.end=t.row.end||n.length,t.row.step=t.row.step||1,u=c.arange(t.row.start,r.min(n[0].length,t.row.end),t.row.step);var l=t.col;return u.forEach((function(r,e){n[r][l]=o[e]})),n}return o[0].length===e&&(o=[o]),t.row.start=t.row.start||0,t.row.end=t.row.end||n.length,t.row.step=t.row.step||1,t.col.start=t.col.start||0,t.col.end=t.col.end||n[0].length,t.col.step=t.col.step||1,u=c.arange(t.row.start,r.min(n.length,t.row.end),t.row.step),i=c.arange(t.col.start,r.min(n[0].length,t.col.end),t.col.step),u.forEach((function(r,e){i.forEach((function(t,i){n[r][t]=o[e][i]}))})),n},c.diagonal=function(r){var e=c.zeros(r.length,r.length);return r.forEach((function(r,n){e[n][n]=r})),e},c.copy=function(r){return r.map((function(r){return s(r)?r:r.map((function(r){return r}))}))};var h=c.prototype;return h.length=0,h.push=Array.prototype.push,h.sort=Array.prototype.sort,h.splice=Array.prototype.splice,h.slice=Array.prototype.slice,h.toArray=function(){return this.length>1?t.call(this):t.call(this)[0]},h.map=function(r,e){return c(c.map(this,r,e))},h.cumreduce=function(r,e){return c(c.cumreduce(this,r,e))},h.alter=function(r){return c.alter(this,r),this},function(r){for(var e=0;e<r.length;e++)!function(r){h[r]=function(e){var n,t=this;return e?(setTimeout((function(){e.call(t,h[r].call(t))})),this):(n=c[r](this),u(n)?c(n):n)}}(r[e])}("transpose clear symmetric rows cols dimensions diag antidiag".split(" ")),function(r){for(var e=0;e<r.length;e++)!function(r){h[r]=function(e,n){var t=this;return n?(setTimeout((function(){n.call(t,h[r].call(t,e))})),this):c(c[r](this,e))}}(r[e])}("row col".split(" ")),function(r){for(var e=0;e<r.length;e++)!function(r){h[r]=function(){return c(c[r].apply(null,arguments))}}(r[e])}("create zeros ones rand identity".split(" ")),c}(Math),function(r,e){var n=r.utils.isFunction;function t(r,e){return r-e}function o(r,n,t){return e.max(n,e.min(r,t))}r.sum=function(r){for(var e=0,n=r.length;--n>=0;)e+=r[n];return e},r.sumsqrd=function(r){for(var e=0,n=r.length;--n>=0;)e+=r[n]*r[n];return e},r.sumsqerr=function(e){for(var n,t=r.mean(e),o=0,i=e.length;--i>=0;)o+=(n=e[i]-t)*n;return o},r.sumrow=function(r){for(var e=0,n=r.length;--n>=0;)e+=r[n];return e},r.product=function(r){for(var e=1,n=r.length;--n>=0;)e*=r[n];return e},r.min=function(r){for(var e=r[0],n=0;++n<r.length;)r[n]<e&&(e=r[n]);return e},r.max=function(r){for(var e=r[0],n=0;++n<r.length;)r[n]>e&&(e=r[n]);return e},r.unique=function(r){for(var e={},n=[],t=0;t<r.length;t++)e[r[t]]||(e[r[t]]=!0,n.push(r[t]));return n},r.mean=function(e){return r.sum(e)/e.length},r.meansqerr=function(e){return r.sumsqerr(e)/e.length},r.geomean=function(n){var t=n.map(e.log),o=r.mean(t);return e.exp(o)},r.median=function(r){var e=r.length,n=r.slice().sort(t);return 1&e?n[e/2|0]:(n[e/2-1]+n[e/2])/2},r.cumsum=function(e){return r.cumreduce(e,(function(r,e){return r+e}))},r.cumprod=function(e){return r.cumreduce(e,(function(r,e){return r*e}))},r.diff=function(r){var e,n=[],t=r.length;for(e=1;e<t;e++)n.push(r[e]-r[e-1]);return n},r.rank=function(r){var e,n=[],o={};for(e=0;e<r.length;e++)o[s=r[e]]?o[s]++:(o[s]=1,n.push(s));var i=n.sort(t),u={},a=1;for(e=0;e<i.length;e++){var s,c=o[s=i[e]],l=(a+(a+c-1))/2;u[s]=l,a+=c}return r.map((function(r){return u[r]}))},r.mode=function(r){var e,n=r.length,o=r.slice().sort(t),i=1,u=0,a=0,s=[];for(e=0;e<n;e++)o[e]===o[e+1]?i++:(i>u?(s=[o[e]],u=i,a=0):i===u&&(s.push(o[e]),a++),i=1);return 0===a?s[0]:s},r.range=function(e){return r.max(e)-r.min(e)},r.variance=function(e,n){return r.sumsqerr(e)/(e.length-(n?1:0))},r.pooledvariance=function(e){return e.reduce((function(e,n){return e+r.sumsqerr(n)}),0)/(e.reduce((function(r,e){return r+e.length}),0)-e.length)},r.deviation=function(e){for(var n=r.mean(e),t=e.length,o=new Array(t),i=0;i<t;i++)o[i]=e[i]-n;return o},r.stdev=function(n,t){return e.sqrt(r.variance(n,t))},r.pooledstdev=function(n){return e.sqrt(r.pooledvariance(n))},r.meandev=function(n){for(var t=r.mean(n),o=[],i=n.length-1;i>=0;i--)o.push(e.abs(n[i]-t));return r.mean(o)},r.meddev=function(n){for(var t=r.median(n),o=[],i=n.length-1;i>=0;i--)o.push(e.abs(n[i]-t));return r.median(o)},r.coeffvar=function(e){return r.stdev(e)/r.mean(e)},r.quartiles=function(r){var n=r.length,o=r.slice().sort(t);return[o[e.round(n/4)-1],o[e.round(n/2)-1],o[e.round(3*n/4)-1]]},r.quantiles=function(r,n,i,u){var a,s,c,l,f,m=r.slice().sort(t),h=[n.length],d=r.length;for(void 0===i&&(i=3/8),void 0===u&&(u=3/8),a=0;a<n.length;a++)c=d*(s=n[a])+(i+s*(1-i-u)),l=e.floor(o(c,1,d-1)),f=o(c-l,0,1),h[a]=(1-f)*m[l-1]+f*m[l];return h},r.percentile=function(r,e,n){var o=r.slice().sort(t),i=e*(o.length+(n?1:-1))+(n?0:1),u=parseInt(i),a=i-u;return u+1<o.length?o[u-1]+a*(o[u]-o[u-1]):o[u-1]},r.percentileOfScore=function(r,e,n){var t,o,i=0,u=r.length,a=!1;for("strict"===n&&(a=!0),o=0;o<u;o++)t=r[o],(a&&t<e||!a&&t<=e)&&i++;return i/u},r.histogram=function(n,t){t=t||4;var o,i=r.min(n),u=(r.max(n)-i)/t,a=n.length,s=[];for(o=0;o<t;o++)s[o]=0;for(o=0;o<a;o++)s[e.min(e.floor((n[o]-i)/u),t-1)]+=1;return s},r.covariance=function(e,n){var t,o=r.mean(e),i=r.mean(n),u=e.length,a=new Array(u);for(t=0;t<u;t++)a[t]=(e[t]-o)*(n[t]-i);return r.sum(a)/(u-1)},r.corrcoeff=function(e,n){return r.covariance(e,n)/r.stdev(e,1)/r.stdev(n,1)},r.spearmancoeff=function(e,n){return e=r.rank(e),n=r.rank(n),r.corrcoeff(e,n)},r.stanMoment=function(n,t){for(var o=r.mean(n),i=r.stdev(n),u=n.length,a=0,s=0;s<u;s++)a+=e.pow((n[s]-o)/i,t);return a/n.length},r.skewness=function(e){return r.stanMoment(e,3)},r.kurtosis=function(e){return r.stanMoment(e,4)-3};var i=r.prototype;!function(e){for(var t=0;t<e.length;t++)!function(e){i[e]=function(t,o){var u=[],a=0,s=this;if(n(t)&&(o=t,t=!1),o)return setTimeout((function(){o.call(s,i[e].call(s,t))})),this;if(this.length>1){for(s=!0===t?this:this.transpose();a<s.length;a++)u[a]=r[e](s[a]);return u}return r[e](this[0],t)}}(e[t])}("cumsum cumprod".split(" ")),function(e){for(var t=0;t<e.length;t++)!function(e){i[e]=function(t,o){var u=[],a=0,s=this;if(n(t)&&(o=t,t=!1),o)return setTimeout((function(){o.call(s,i[e].call(s,t))})),this;if(this.length>1){for("sumrow"!==e&&(s=!0===t?this:this.transpose());a<s.length;a++)u[a]=r[e](s[a]);return!0===t?r[e](r.utils.toVector(u)):u}return r[e](this[0],t)}}(e[t])}("sum sumsqrd sumsqerr sumrow product min max unique mean meansqerr geomean median diff rank mode range variance deviation stdev meandev meddev coeffvar quartiles histogram skewness kurtosis".split(" ")),function(e){for(var t=0;t<e.length;t++)!function(e){i[e]=function(){var t,o=[],u=0,a=this,s=Array.prototype.slice.call(arguments);if(n(s[s.length-1])){t=s[s.length-1];var c=s.slice(0,s.length-1);return setTimeout((function(){t.call(a,i[e].apply(a,c))})),this}t=void 0;var l=function(n){return r[e].apply(a,[n].concat(s))};if(this.length>1){for(a=a.transpose();u<a.length;u++)o[u]=l(a[u]);return o}return l(this[0])}}(e[t])}("quantiles percentileOfScore".split(" "))}(e,Math),function(r,e){r.gammaln=function(r){var n,t,o,i=0,u=[76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18],a=1.000000000190015;for(o=(t=n=r)+5.5,o-=(n+.5)*e.log(o);i<6;i++)a+=u[i]/++t;return e.log(2.5066282746310007*a/n)-o},r.loggam=function(r){var n,t,o,i,u,a,s,c=[.08333333333333333,-.002777777777777778,.0007936507936507937,-.0005952380952380952,.0008417508417508418,-.001917526917526918,.00641025641025641,-.02955065359477124,.1796443723688307,-1.3924322169059];if(n=r,s=0,1==r||2==r)return 0;for(r<=7&&(n=r+(s=e.floor(7-r))),t=1/(n*n),o=2*e.PI,u=c[9],a=8;a>=0;a--)u*=t,u+=c[a];if(i=u/n+.5*e.log(o)+(n-.5)*e.log(n)-n,r<=7)for(a=1;a<=s;a++)i-=e.log(n-1),n-=1;return i},r.gammafn=function(r){var n,t,o,i,u=[-1.716185138865495,24.76565080557592,-379.80425647094563,629.3311553128184,866.9662027904133,-31451.272968848367,-36144.413418691176,66456.14382024054],a=[-30.8402300119739,315.35062697960416,-1015.1563674902192,-3107.771671572311,22538.11842098015,4755.846277527881,-134659.9598649693,-115132.2596755535],s=!1,c=0,l=0,f=0,m=r;if(r>171.6243769536076)return 1/0;if(m<=0){if(!(i=m%1+36e-17))return 1/0;s=(1&m?-1:1)*e.PI/e.sin(e.PI*i),m=1-m}for(o=m,t=m<1?m++:(m-=c=(0|m)-1)-1,n=0;n<8;++n)f=(f+u[n])*t,l=l*t+a[n];if(i=f/l+1,o<m)i/=o;else if(o>m)for(n=0;n<c;++n)i*=m,m++;return s&&(i=s/i),i},r.gammap=function(e,n){return r.lowRegGamma(e,n)*r.gammafn(e)},r.lowRegGamma=function(n,t){var o,i=r.gammaln(n),u=n,a=1/n,s=a,c=t+1-n,l=1/1e-30,f=1/c,m=f,h=1,d=-~(8.5*e.log(n>=1?n:1/n)+.4*n+17);if(t<0||n<=0)return NaN;if(t<n+1){for(;h<=d;h++)a+=s*=t/++u;return a*e.exp(-t+n*e.log(t)-i)}for(;h<=d;h++)m*=(f=1/(f=(o=-h*(h-n))*f+(c+=2)))*(l=c+o/l);return 1-m*e.exp(-t+n*e.log(t)-i)},r.factorialln=function(e){return e<0?NaN:r.gammaln(e+1)},r.factorial=function(e){return e<0?NaN:r.gammafn(e+1)},r.combination=function(n,t){return n>170||t>170?e.exp(r.combinationln(n,t)):r.factorial(n)/r.factorial(t)/r.factorial(n-t)},r.combinationln=function(e,n){return r.factorialln(e)-r.factorialln(n)-r.factorialln(e-n)},r.permutation=function(e,n){return r.factorial(e)/r.factorial(e-n)},r.betafn=function(n,t){if(!(n<=0||t<=0))return n+t>170?e.exp(r.betaln(n,t)):r.gammafn(n)*r.gammafn(t)/r.gammafn(n+t)},r.betaln=function(e,n){return r.gammaln(e)+r.gammaln(n)-r.gammaln(e+n)},r.betacf=function(r,n,t){var o,i,u,a,s=1e-30,c=1,l=n+t,f=n+1,m=n-1,h=1,d=1-l*r/f;for(e.abs(d)<s&&(d=s),a=d=1/d;c<=100&&(d=1+(i=c*(t-c)*r/((m+(o=2*c))*(n+o)))*d,e.abs(d)<s&&(d=s),h=1+i/h,e.abs(h)<s&&(h=s),a*=(d=1/d)*h,d=1+(i=-(n+c)*(l+c)*r/((n+o)*(f+o)))*d,e.abs(d)<s&&(d=s),h=1+i/h,e.abs(h)<s&&(h=s),a*=u=(d=1/d)*h,!(e.abs(u-1)<3e-7));c++);return a},r.gammapinv=function(n,t){var o,i,u,a,s,c,l=0,f=t-1,m=r.gammaln(t);if(n>=1)return e.max(100,t+100*e.sqrt(t));if(n<=0)return 0;for(t>1?(s=e.log(f),c=e.exp(f*(s-1)-m),a=n<.5?n:1-n,o=(2.30753+.27061*(i=e.sqrt(-2*e.log(a))))/(1+i*(.99229+.04481*i))-i,n<.5&&(o=-o),o=e.max(.001,t*e.pow(1-1/(9*t)-o/(3*e.sqrt(t)),3))):o=n<(i=1-t*(.253+.12*t))?e.pow(n/i,1/t):1-e.log(1-(n-i)/(1-i));l<12;l++){if(o<=0)return 0;if((o-=i=(u=(r.lowRegGamma(t,o)-n)/(i=t>1?c*e.exp(-(o-f)+f*(e.log(o)-s)):e.exp(-o+f*e.log(o)-m)))/(1-.5*e.min(1,u*((t-1)/o-1))))<=0&&(o=.5*(o+i)),e.abs(i)<1e-8*o)break}return o},r.erf=function(r){var n,t,o,i,u=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,1.5626441722e-8,-8.5238095915e-8,6.529054439e-9,5.059343495e-9,-9.91364156e-10,-2.27365122e-10,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18,-1523e-18,-94e-18,121e-18,-28e-18],a=u.length-1,s=!1,c=0,l=0;for(r<0&&(r=-r,s=!0),t=4*(n=2/(2+r))-2;a>0;a--)o=c,c=t*c-l+u[a],l=o;return i=n*e.exp(-r*r+.5*(u[0]+t*c)-l),s?i-1:1-i},r.erfc=function(e){return 1-r.erf(e)},r.erfcinv=function(n){var t,o,i,u,a=0;if(n>=2)return-100;if(n<=0)return 100;for(u=n<1?n:2-n,t=-.70711*((2.30753+.27061*(i=e.sqrt(-2*e.log(u/2))))/(1+i*(.99229+.04481*i))-i);a<2;a++)t+=(o=r.erfc(t)-u)/(1.1283791670955126*e.exp(-t*t)-t*o);return n<1?t:-t},r.ibetainv=function(n,t,o){var i,u,a,s,c,l,f,m,h,d,p=t-1,g=o-1,v=0;if(n<=0)return 0;if(n>=1)return 1;for(t>=1&&o>=1?(a=n<.5?n:1-n,l=(2.30753+.27061*(s=e.sqrt(-2*e.log(a))))/(1+s*(.99229+.04481*s))-s,n<.5&&(l=-l),f=(l*l-3)/6,m=2/(1/(2*t-1)+1/(2*o-1)),h=l*e.sqrt(f+m)/m-(1/(2*o-1)-1/(2*t-1))*(f+5/6-2/(3*m)),l=t/(t+o*e.exp(2*h))):(i=e.log(t/(t+o)),u=e.log(o/(t+o)),l=n<(s=e.exp(t*i)/t)/(h=s+(c=e.exp(o*u)/o))?e.pow(t*h*n,1/t):1-e.pow(o*h*(1-n),1/o)),d=-r.gammaln(t)-r.gammaln(o)+r.gammaln(t+o);v<10;v++){if(0===l||1===l)return l;if((l-=s=(c=(r.ibeta(l,t,o)-n)/(s=e.exp(p*e.log(l)+g*e.log(1-l)+d)))/(1-.5*e.min(1,c*(p/l-g/(1-l)))))<=0&&(l=.5*(l+s)),l>=1&&(l=.5*(l+s+1)),e.abs(s)<1e-8*l&&v>0)break}return l},r.ibeta=function(n,t,o){var i=0===n||1===n?0:e.exp(r.gammaln(t+o)-r.gammaln(t)-r.gammaln(o)+t*e.log(n)+o*e.log(1-n));return!(n<0||n>1)&&(n<(t+1)/(t+o+2)?i*r.betacf(n,t,o)/t:1-i*r.betacf(1-n,o,t)/o)},r.randn=function(n,t){var o,i,u,a,s;if(t||(t=n),n)return r.create(n,t,(function(){return r.randn()}));do{o=r._random_fn(),i=1.7156*(r._random_fn()-.5),s=(u=o-.449871)*u+(a=e.abs(i)+.386595)*(.196*a-.25472*u)}while(s>.27597&&(s>.27846||i*i>-4*e.log(o)*o*o));return i/o},r.randg=function(n,t,o){var i,u,a,s,c,l,f=n;if(o||(o=t),n||(n=1),t)return(l=r.zeros(t,o)).alter((function(){return r.randg(n)})),l;n<1&&(n+=1),i=n-1/3,u=1/e.sqrt(9*i);do{do{s=1+u*(c=r.randn())}while(s<=0);s*=s*s,a=r._random_fn()}while(a>1-.331*e.pow(c,4)&&e.log(a)>.5*c*c+i*(1-s+e.log(s)));if(n==f)return i*s;do{a=r._random_fn()}while(0===a);return e.pow(a,1/f)*i*s},function(e){for(var n=0;n<e.length;n++)!function(e){r.fn[e]=function(){return r(r.map(this,(function(n){return r[e](n)})))}}(e[n])}("gammaln gammafn factorial factorialln".split(" ")),function(e){for(var n=0;n<e.length;n++)!function(e){r.fn[e]=function(){return r(r[e].apply(null,arguments))}}(e[n])}("randn".split(" "))}(e,Math),function(r,e){function n(r,n,t,o){for(var i,u=0,a=1,s=1,c=1,l=0,f=0;e.abs((s-f)/s)>o;)f=s,a=c+(i=-(n+l)*(n+t+l)*r/(n+2*l)/(n+2*l+1))*a,s=(u=s+i*u)+(i=(l+=1)*(t-l)*r/(n+2*l-1)/(n+2*l))*s,u/=c=a+i*c,a/=c,s/=c,c=1;return s/n}function t(n,t,o){var i=[.9815606342467192,.9041172563704749,.7699026741943047,.5873179542866175,.3678314989981802,.1252334085114689],u=[.04717533638651183,.10693932599531843,.16007832854334622,.20316742672306592,.2334925365383548,.24914704581340277],a=.5*n;if(a>=8)return 1;var s,c=2*r.normal.cdf(a,0,1,1,0)-1;c=c>=e.exp(-50/o)?e.pow(c,o):0;for(var l=a,f=(8-a)/(s=n>3?2:3),m=l+f,h=0,d=o-1,p=1;p<=s;p++){for(var g=0,v=.5*(m+l),y=.5*(m-l),x=1;x<=12;x++){var w,b=v+y*(6<x?i[(w=12-x+1)-1]:-i[(w=x)-1]),T=b*b;if(T>60)break;var C=2*r.normal.cdf(b,0,1,1,0)*.5-2*r.normal.cdf(b,n,1,1,0)*.5;C>=e.exp(-30/d)&&(g+=C=u[w-1]*e.exp(-.5*T)*e.pow(C,d))}h+=g*=2*y*o/e.sqrt(2*e.PI),l=m,m+=f}return(c+=h)<=e.exp(-30/t)?0:(c=e.pow(c,t))>=1?1:c}!function(e){for(var n=0;n<e.length;n++)!function(e){r[e]=function r(e,n,t){return this instanceof r?(this._a=e,this._b=n,this._c=t,this):new r(e,n,t)},r.fn[e]=function(n,t,o){var i=r[e](n,t,o);return i.data=this,i},r[e].prototype.sample=function(n){var t=this._a,o=this._b,i=this._c;return n?r.alter(n,(function(){return r[e].sample(t,o,i)})):r[e].sample(t,o,i)},function(n){for(var t=0;t<n.length;t++)!function(n){r[e].prototype[n]=function(t){var o=this._a,i=this._b,u=this._c;return t||0===t||(t=this.data),"number"!=typeof t?r.fn.map.call(t,(function(t){return r[e][n](t,o,i,u)})):r[e][n](t,o,i,u)}}(n[t])}("pdf cdf inv".split(" ")),function(n){for(var t=0;t<n.length;t++)!function(n){r[e].prototype[n]=function(){return r[e][n](this._a,this._b,this._c)}}(n[t])}("mean median mode variance".split(" "))}(e[n])}("beta centralF cauchy chisquare exponential gamma invgamma kumaraswamy laplace lognormal noncentralt normal pareto studentt weibull uniform binomial negbin hypgeom poisson triangular tukey arcsine".split(" ")),r.extend(r.beta,{pdf:function(n,t,o){return n>1||n<0?0:1==t&&1==o?1:t<512&&o<512?e.pow(n,t-1)*e.pow(1-n,o-1)/r.betafn(t,o):e.exp((t-1)*e.log(n)+(o-1)*e.log(1-n)-r.betaln(t,o))},cdf:function(e,n,t){return e>1||e<0?1*(e>1):r.ibeta(e,n,t)},inv:function(e,n,t){return r.ibetainv(e,n,t)},mean:function(r,e){return r/(r+e)},median:function(e,n){return r.ibetainv(.5,e,n)},mode:function(r,e){return(r-1)/(r+e-2)},sample:function(e,n){var t=r.randg(e);return t/(t+r.randg(n))},variance:function(r,n){return r*n/(e.pow(r+n,2)*(r+n+1))}}),r.extend(r.centralF,{pdf:function(n,t,o){var i;return n<0?0:t<=2?0===n&&t<2?1/0:0===n&&2===t?1:1/r.betafn(t/2,o/2)*e.pow(t/o,t/2)*e.pow(n,t/2-1)*e.pow(1+t/o*n,-(t+o)/2):(i=t*n/(o+n*t),t*(o/(o+n*t))/2*r.binomial.pdf((t-2)/2,(t+o-2)/2,i))},cdf:function(e,n,t){return e<0?0:r.ibeta(n*e/(n*e+t),n/2,t/2)},inv:function(e,n,t){return t/(n*(1/r.ibetainv(e,n/2,t/2)-1))},mean:function(r,e){return e>2?e/(e-2):void 0},mode:function(r,e){return r>2?e*(r-2)/(r*(e+2)):void 0},sample:function(e,n){return 2*r.randg(e/2)/e/(2*r.randg(n/2)/n)},variance:function(r,e){if(!(e<=4))return 2*e*e*(r+e-2)/(r*(e-2)*(e-2)*(e-4))}}),r.extend(r.cauchy,{pdf:function(r,n,t){return t<0?0:t/(e.pow(r-n,2)+e.pow(t,2))/e.PI},cdf:function(r,n,t){return e.atan((r-n)/t)/e.PI+.5},inv:function(r,n,t){return n+t*e.tan(e.PI*(r-.5))},median:function(r){return r},mode:function(r){return r},sample:function(n,t){return r.randn()*e.sqrt(1/(2*r.randg(.5)))*t+n}}),r.extend(r.chisquare,{pdf:function(n,t){return n<0?0:0===n&&2===t?.5:e.exp((t/2-1)*e.log(n)-n/2-t/2*e.log(2)-r.gammaln(t/2))},cdf:function(e,n){return e<0?0:r.lowRegGamma(n/2,e/2)},inv:function(e,n){return 2*r.gammapinv(e,.5*n)},mean:function(r){return r},median:function(r){return r*e.pow(1-2/(9*r),3)},mode:function(r){return r-2>0?r-2:0},sample:function(e){return 2*r.randg(e/2)},variance:function(r){return 2*r}}),r.extend(r.exponential,{pdf:function(r,n){return r<0?0:n*e.exp(-n*r)},cdf:function(r,n){return r<0?0:1-e.exp(-n*r)},inv:function(r,n){return-e.log(1-r)/n},mean:function(r){return 1/r},median:function(r){return 1/r*e.log(2)},mode:function(){return 0},sample:function(n){return-1/n*e.log(r._random_fn())},variance:function(r){return e.pow(r,-2)}}),r.extend(r.gamma,{pdf:function(n,t,o){return n<0?0:0===n&&1===t?1/o:e.exp((t-1)*e.log(n)-n/o-r.gammaln(t)-t*e.log(o))},cdf:function(e,n,t){return e<0?0:r.lowRegGamma(n,e/t)},inv:function(e,n,t){return r.gammapinv(e,n)*t},mean:function(r,e){return r*e},mode:function(r,e){if(r>1)return(r-1)*e},sample:function(e,n){return r.randg(e)*n},variance:function(r,e){return r*e*e}}),r.extend(r.invgamma,{pdf:function(n,t,o){return n<=0?0:e.exp(-(t+1)*e.log(n)-o/n-r.gammaln(t)+t*e.log(o))},cdf:function(e,n,t){return e<=0?0:1-r.lowRegGamma(n,t/e)},inv:function(e,n,t){return t/r.gammapinv(1-e,n)},mean:function(r,e){return r>1?e/(r-1):void 0},mode:function(r,e){return e/(r+1)},sample:function(e,n){return n/r.randg(e)},variance:function(r,e){if(!(r<=2))return e*e/((r-1)*(r-1)*(r-2))}}),r.extend(r.kumaraswamy,{pdf:function(r,n,t){return 0===r&&1===n?t:1===r&&1===t?n:e.exp(e.log(n)+e.log(t)+(n-1)*e.log(r)+(t-1)*e.log(1-e.pow(r,n)))},cdf:function(r,n,t){return r<0?0:r>1?1:1-e.pow(1-e.pow(r,n),t)},inv:function(r,n,t){return e.pow(1-e.pow(1-r,1/t),1/n)},mean:function(e,n){return n*r.gammafn(1+1/e)*r.gammafn(n)/r.gammafn(1+1/e+n)},median:function(r,n){return e.pow(1-e.pow(2,-1/n),1/r)},mode:function(r,n){if(r>=1&&n>=1&&1!==r&&1!==n)return e.pow((r-1)/(r*n-1),1/r)},variance:function(){throw new Error("variance not yet implemented")}}),r.extend(r.lognormal,{pdf:function(r,n,t){return r<=0?0:e.exp(-e.log(r)-.5*e.log(2*e.PI)-e.log(t)-e.pow(e.log(r)-n,2)/(2*t*t))},cdf:function(n,t,o){return n<0?0:.5+.5*r.erf((e.log(n)-t)/e.sqrt(2*o*o))},inv:function(n,t,o){return e.exp(-1.4142135623730951*o*r.erfcinv(2*n)+t)},mean:function(r,n){return e.exp(r+n*n/2)},median:function(r){return e.exp(r)},mode:function(r,n){return e.exp(r-n*n)},sample:function(n,t){return e.exp(r.randn()*t+n)},variance:function(r,n){return(e.exp(n*n)-1)*e.exp(2*r+n*n)}}),r.extend(r.noncentralt,{pdf:function(n,t,o){return e.abs(o)<1e-14?r.studentt.pdf(n,t):e.abs(n)<1e-14?e.exp(r.gammaln((t+1)/2)-o*o/2-.5*e.log(e.PI*t)-r.gammaln(t/2)):t/n*(r.noncentralt.cdf(n*e.sqrt(1+2/t),t+2,o)-r.noncentralt.cdf(n,t,o))},cdf:function(n,t,o){var i=1e-14;if(e.abs(o)<i)return r.studentt.cdf(n,t);var u=!1;n<0&&(u=!0,o=-o);for(var a=r.normal.cdf(-o,0,1),s=i+1,c=s,l=n*n/(n*n+t),f=0,m=e.exp(-o*o/2),h=e.exp(-o*o/2-.5*e.log(2)-r.gammaln(1.5))*o;f<200||c>i||s>i;)c=s,f>0&&(m*=o*o/(2*f),h*=o*o/(2*(f+.5))),a+=.5*(s=m*r.beta.cdf(l,f+.5,t/2)+h*r.beta.cdf(l,f+1,t/2)),f++;return u?1-a:a}}),r.extend(r.normal,{pdf:function(r,n,t){return e.exp(-.5*e.log(2*e.PI)-e.log(t)-e.pow(r-n,2)/(2*t*t))},cdf:function(n,t,o){return.5*(1+r.erf((n-t)/e.sqrt(2*o*o)))},inv:function(e,n,t){return-1.4142135623730951*t*r.erfcinv(2*e)+n},mean:function(r){return r},median:function(r){return r},mode:function(r){return r},sample:function(e,n){return r.randn()*n+e},variance:function(r,e){return e*e}}),r.extend(r.pareto,{pdf:function(r,n,t){return r<n?0:t*e.pow(n,t)/e.pow(r,t+1)},cdf:function(r,n,t){return r<n?0:1-e.pow(n/r,t)},inv:function(r,n,t){return n/e.pow(1-r,1/t)},mean:function(r,n){if(!(n<=1))return n*e.pow(r,n)/(n-1)},median:function(r,n){return r*(n*e.SQRT2)},mode:function(r){return r},variance:function(r,n){if(!(n<=2))return r*r*n/(e.pow(n-1,2)*(n-2))}}),r.extend(r.studentt,{pdf:function(n,t){return t=t>1e100?1e100:t,1/(e.sqrt(t)*r.betafn(.5,t/2))*e.pow(1+n*n/t,-(t+1)/2)},cdf:function(n,t){var o=t/2;return r.ibeta((n+e.sqrt(n*n+t))/(2*e.sqrt(n*n+t)),o,o)},inv:function(n,t){var o=r.ibetainv(2*e.min(n,1-n),.5*t,.5);return o=e.sqrt(t*(1-o)/o),n>.5?o:-o},mean:function(r){return r>1?0:void 0},median:function(){return 0},mode:function(){return 0},sample:function(n){return r.randn()*e.sqrt(n/(2*r.randg(n/2)))},variance:function(r){return r>2?r/(r-2):r>1?1/0:void 0}}),r.extend(r.weibull,{pdf:function(r,n,t){return r<0||n<0||t<0?0:t/n*e.pow(r/n,t-1)*e.exp(-e.pow(r/n,t))},cdf:function(r,n,t){return r<0?0:1-e.exp(-e.pow(r/n,t))},inv:function(r,n,t){return n*e.pow(-e.log(1-r),1/t)},mean:function(e,n){return e*r.gammafn(1+1/n)},median:function(r,n){return r*e.pow(e.log(2),1/n)},mode:function(r,n){return n<=1?0:r*e.pow((n-1)/n,1/n)},sample:function(n,t){return n*e.pow(-e.log(r._random_fn()),1/t)},variance:function(n,t){return n*n*r.gammafn(1+2/t)-e.pow(r.weibull.mean(n,t),2)}}),r.extend(r.uniform,{pdf:function(r,e,n){return r<e||r>n?0:1/(n-e)},cdf:function(r,e,n){return r<e?0:r<n?(r-e)/(n-e):1},inv:function(r,e,n){return e+r*(n-e)},mean:function(r,e){return.5*(r+e)},median:function(e,n){return r.mean(e,n)},mode:function(){throw new Error("mode is not yet implemented")},sample:function(e,n){return e/2+n/2+(n/2-e/2)*(2*r._random_fn()-1)},variance:function(r,n){return e.pow(n-r,2)/12}}),r.extend(r.binomial,{pdf:function(n,t,o){return 0===o||1===o?t*o===n?1:0:r.combination(t,n)*e.pow(o,n)*e.pow(1-o,t-n)},cdf:function(t,o,i){var u,a=1e-10;if(t<0)return 0;if(t>=o)return 1;if(i<0||i>1||o<=0)return NaN;var s=i,c=(t=e.floor(t))+1,l=o-t,f=c+l,m=e.exp(r.gammaln(f)-r.gammaln(l)-r.gammaln(c)+c*e.log(s)+l*e.log(1-s));return u=s<(c+1)/(f+2)?m*n(s,c,l,a):1-m*n(1-s,l,c,a),e.round(1/a*(1-u))/(1/a)}}),r.extend(r.negbin,{pdf:function(n,t,o){return n===n>>>0&&(n<0?0:r.combination(n+t-1,t-1)*e.pow(1-o,n)*e.pow(o,t))},cdf:function(e,n,t){var o=0,i=0;if(e<0)return 0;for(;i<=e;i++)o+=r.negbin.pdf(i,n,t);return o}}),r.extend(r.hypgeom,{pdf:function(n,t,o,i){if(n!=n|0)return!1;if(n<0||n<o-(t-i))return 0;if(n>i||n>o)return 0;if(2*o>t)return 2*i>t?r.hypgeom.pdf(t-o-i+n,t,t-o,t-i):r.hypgeom.pdf(i-n,t,t-o,i);if(2*i>t)return r.hypgeom.pdf(o-n,t,o,t-i);if(o<i)return r.hypgeom.pdf(n,t,i,o);for(var u=1,a=0,s=0;s<n;s++){for(;u>1&&a<i;)u*=1-o/(t-a),a++;u*=(i-s)*(o-s)/((s+1)*(t-o-i+s+1))}for(;a<i;a++)u*=1-o/(t-a);return e.min(1,e.max(0,u))},cdf:function(n,t,o,i){if(n<0||n<o-(t-i))return 0;if(n>=i||n>=o)return 1;if(2*o>t)return 2*i>t?r.hypgeom.cdf(t-o-i+n,t,t-o,t-i):1-r.hypgeom.cdf(i-n-1,t,t-o,i);if(2*i>t)return 1-r.hypgeom.cdf(o-n-1,t,o,t-i);if(o<i)return r.hypgeom.cdf(n,t,i,o);for(var u=1,a=1,s=0,c=0;c<n;c++){for(;u>1&&s<i;){var l=1-o/(t-s);a*=l,u*=l,s++}u+=a*=(i-c)*(o-c)/((c+1)*(t-o-i+c+1))}for(;s<i;s++)u*=1-o/(t-s);return e.min(1,e.max(0,u))}}),r.extend(r.poisson,{pdf:function(n,t){return t<0||n%1!=0||n<0?0:e.pow(t,n)*e.exp(-t)/r.factorial(n)},cdf:function(e,n){var t=[],o=0;if(e<0)return 0;for(;o<=e;o++)t.push(r.poisson.pdf(o,n));return r.sum(t)},mean:function(r){return r},variance:function(r){return r},sampleSmall:function(n){var t=1,o=0,i=e.exp(-n);do{o++,t*=r._random_fn()}while(t>i);return o-1},sampleLarge:function(n){var t,o,i,u,a,s,c,l,f,m,h=n;for(u=e.sqrt(h),a=e.log(h),s=.02483*(c=.931+2.53*u)-.059,l=1.1239+1.1328/(c-3.4),f=.9277-3.6224/(c-2);;){if(o=e.random()-.5,i=e.random(),m=.5-e.abs(o),t=e.floor((2*s/m+c)*o+h+.43),m>=.07&&i<=f)return t;if(!(t<0||m<.013&&i>m)&&e.log(i)+e.log(l)-e.log(s/(m*m)+c)<=t*a-h-r.loggam(t+1))return t}},sample:function(r){return r<10?this.sampleSmall(r):this.sampleLarge(r)}}),r.extend(r.triangular,{pdf:function(r,e,n,t){return n<=e||t<e||t>n?NaN:r<e||r>n?0:r<t?2*(r-e)/((n-e)*(t-e)):r===t?2/(n-e):2*(n-r)/((n-e)*(n-t))},cdf:function(r,n,t,o){return t<=n||o<n||o>t?NaN:r<=n?0:r>=t?1:r<=o?e.pow(r-n,2)/((t-n)*(o-n)):1-e.pow(t-r,2)/((t-n)*(t-o))},inv:function(r,n,t,o){return t<=n||o<n||o>t?NaN:r<=(o-n)/(t-n)?n+(t-n)*e.sqrt(r*((o-n)/(t-n))):n+(t-n)*(1-e.sqrt((1-r)*(1-(o-n)/(t-n))))},mean:function(r,e,n){return(r+e+n)/3},median:function(r,n,t){return t<=(r+n)/2?n-e.sqrt((n-r)*(n-t))/e.sqrt(2):t>(r+n)/2?r+e.sqrt((n-r)*(t-r))/e.sqrt(2):void 0},mode:function(r,e,n){return n},sample:function(n,t,o){var i=r._random_fn();return i<(o-n)/(t-n)?n+e.sqrt(i*(t-n)*(o-n)):t-e.sqrt((1-i)*(t-n)*(t-o))},variance:function(r,e,n){return(r*r+e*e+n*n-r*e-r*n-e*n)/18}}),r.extend(r.arcsine,{pdf:function(r,n,t){return t<=n?NaN:r<=n||r>=t?0:2/e.PI*e.pow(e.pow(t-n,2)-e.pow(2*r-n-t,2),-.5)},cdf:function(r,n,t){return r<n?0:r<t?2/e.PI*e.asin(e.sqrt((r-n)/(t-n))):1},inv:function(r,n,t){return n+(.5-.5*e.cos(e.PI*r))*(t-n)},mean:function(r,e){return e<=r?NaN:(r+e)/2},median:function(r,e){return e<=r?NaN:(r+e)/2},mode:function(){throw new Error("mode is not yet implemented")},sample:function(n,t){return(n+t)/2+(t-n)/2*e.sin(2*e.PI*r.uniform.sample(0,1))},variance:function(r,n){return n<=r?NaN:e.pow(n-r,2)/8}}),r.extend(r.laplace,{pdf:function(r,n,t){return t<=0?0:e.exp(-e.abs(r-n)/t)/(2*t)},cdf:function(r,n,t){return t<=0?0:r<n?.5*e.exp((r-n)/t):1-.5*e.exp(-(r-n)/t)},mean:function(r){return r},median:function(r){return r},mode:function(r){return r},variance:function(r,e){return 2*e*e},sample:function(n,t){var o,i=r._random_fn()-.5;return n-t*((o=i)/e.abs(o))*e.log(1-2*e.abs(i))}}),r.extend(r.tukey,{cdf:function(n,o,i){var u=o,a=[.9894009349916499,.9445750230732326,.8656312023878318,.755404408355003,.6178762444026438,.45801677765722737,.2816035507792589,.09501250983763744],s=[.027152459411754096,.062253523938647894,.09515851168249279,.12462897125553388,.14959598881657674,.16915651939500254,.18260341504492358,.1894506104550685];if(n<=0)return 0;if(i<2||u<2)return NaN;if(!Number.isFinite(n))return 1;if(i>25e3)return t(n,1,u);var c,l=.5*i,f=l*e.log(i)-i*e.log(2)-r.gammaln(l),m=l-1,h=.25*i;c=i<=100?1:i<=800?.5:i<=5e3?.25:.125,f+=e.log(c);for(var d=0,p=1;p<=50;p++){for(var g=0,v=(2*p-1)*c,y=1;y<=16;y++){var x,w;8<y?(x=y-8-1,w=f+m*e.log(v+a[x]*c)-(a[x]*c+v)*h):(x=y-1,w=f+m*e.log(v-a[x]*c)+(a[x]*c-v)*h),w>=-30&&(g+=t(8<y?n*e.sqrt(.5*(a[x]*c+v)):n*e.sqrt(.5*(-a[x]*c+v)),1,u)*s[x]*e.exp(w))}if(p*c>=1&&g<=1e-14)break;d+=g}if(g>1e-14)throw new Error("tukey.cdf failed to converge");return d>1&&(d=1),d},inv:function(n,t,o){if(o<2||t<2)return NaN;if(n<0||n>1)return NaN;if(0===n)return 0;if(1===n)return 1/0;var i,u=function(r,n,t){var o=.5-.5*r,i=e.sqrt(e.log(1/(o*o))),u=i+((((-453642210148e-16*i-.204231210125)*i-.342242088547)*i-1)*i+.322232421088)/((((.0038560700634*i+.10353775285)*i+.531103462366)*i+.588581570495)*i+.099348462606);t<120&&(u+=(u*u*u+u)/t/4);var a=.8832-.2368*u;return t<120&&(a+=-1.214/t+1.208*u/t),u*(a*e.log(n-1)+1.4142)}(n,t,o),a=r.tukey.cdf(u,t,o)-n;i=a>0?e.max(0,u-1):u+1;for(var s,c=r.tukey.cdf(i,t,o)-n,l=1;l<50;l++)if(s=i-c*(i-u)/(c-a),a=c,u=i,s<0&&(s=0,c=-n),c=r.tukey.cdf(s,t,o)-n,i=s,e.abs(i-u)<1e-4)return s;throw new Error("tukey.inv failed to converge")}})}(e,Math),function(r,e){var n,t,o=Array.prototype.push,i=r.utils.isArray;function u(e){return i(e)||e instanceof r}r.extend({add:function(e,n){return u(n)?(u(n[0])||(n=[n]),r.map(e,(function(r,e,t){return r+n[e][t]}))):r.map(e,(function(r){return r+n}))},subtract:function(e,n){return u(n)?(u(n[0])||(n=[n]),r.map(e,(function(r,e,t){return r-n[e][t]||0}))):r.map(e,(function(r){return r-n}))},divide:function(e,n){return u(n)?(u(n[0])||(n=[n]),r.multiply(e,r.inv(n))):r.map(e,(function(r){return r/n}))},multiply:function(e,n){var t,o,i,a,s,c,l,f;if(void 0===e.length&&void 0===n.length)return e*n;if(s=e.length,c=e[0].length,l=r.zeros(s,i=u(n)?n[0].length:c),f=0,u(n)){for(;f<i;f++)for(t=0;t<s;t++){for(a=0,o=0;o<c;o++)a+=e[t][o]*n[o][f];l[t][f]=a}return 1===s&&1===f?l[0][0]:l}return r.map(e,(function(r){return r*n}))},outer:function(e,n){return r.multiply(e.map((function(r){return[r]})),[n])},dot:function(e,n){u(e[0])||(e=[e]),u(n[0])||(n=[n]);for(var t,o,i=1===e[0].length&&1!==e.length?r.transpose(e):e,a=1===n[0].length&&1!==n.length?r.transpose(n):n,s=[],c=0,l=i.length,f=i[0].length;c<l;c++){for(s[c]=[],t=0,o=0;o<f;o++)t+=i[c][o]*a[c][o];s[c]=t}return 1===s.length?s[0]:s},pow:function(n,t){return r.map(n,(function(r){return e.pow(r,t)}))},exp:function(n){return r.map(n,(function(r){return e.exp(r)}))},log:function(n){return r.map(n,(function(r){return e.log(r)}))},abs:function(n){return r.map(n,(function(r){return e.abs(r)}))},norm:function(r,n){var t=0,o=0;for(isNaN(n)&&(n=2),u(r[0])&&(r=r[0]);o<r.length;o++)t+=e.pow(e.abs(r[o]),n);return e.pow(t,1/n)},angle:function(n,t){return e.acos(r.dot(n,t)/(r.norm(n)*r.norm(t)))},aug:function(r,e){var n,t=[];for(n=0;n<r.length;n++)t.push(r[n].slice());for(n=0;n<t.length;n++)o.apply(t[n],e[n]);return t},inv:function(e){for(var n,t=e.length,o=e[0].length,i=r.identity(t,o),u=r.gauss_jordan(e,i),a=[],s=0;s<t;s++)for(a[s]=[],n=o;n<u[0].length;n++)a[s][n-o]=u[s][n];return a},det:function r(e){if(2===e.length)return e[0][0]*e[1][1]-e[0][1]*e[1][0];for(var n=0,t=0;t<e.length;t++){for(var o=[],i=1;i<e.length;i++){o[i-1]=[];for(var u=0;u<e.length;u++)u<t?o[i-1][u]=e[i][u]:u>t&&(o[i-1][u-1]=e[i][u])}var a=t%2?-1:1;n+=r(o)*e[0][t]*a}return n},gauss_elimination:function(n,t){var o,i,u,a,s=0,c=0,l=n.length,f=n[0].length,m=1,h=0,d=[];for(o=(n=r.aug(n,t))[0].length,s=0;s<l;s++){for(i=n[s][s],c=s,a=s+1;a<f;a++)i<e.abs(n[a][s])&&(i=n[a][s],c=a);if(c!=s)for(a=0;a<o;a++)u=n[s][a],n[s][a]=n[c][a],n[c][a]=u;for(c=s+1;c<l;c++)for(m=n[c][s]/n[s][s],a=s;a<o;a++)n[c][a]=n[c][a]-m*n[s][a]}for(s=l-1;s>=0;s--){for(h=0,c=s+1;c<=l-1;c++)h+=d[c]*n[s][c];d[s]=(n[s][o-1]-h)/n[s][s]}return d},gauss_jordan:function(n,t){var o,i,u,a=r.aug(n,t),s=a.length,c=a[0].length,l=0;for(i=0;i<s;i++){var f=i;for(u=i+1;u<s;u++)e.abs(a[u][i])>e.abs(a[f][i])&&(f=u);var m=a[i];for(a[i]=a[f],a[f]=m,u=i+1;u<s;u++)for(l=a[u][i]/a[i][i],o=i;o<c;o++)a[u][o]-=a[i][o]*l}for(i=s-1;i>=0;i--){for(l=a[i][i],u=0;u<i;u++)for(o=c-1;o>i-1;o--)a[u][o]-=a[i][o]*a[u][i]/l;for(a[i][i]/=l,o=s;o<c;o++)a[i][o]/=l}return a},triaUpSolve:function(e,n){var t,o=e[0].length,i=r.zeros(1,o)[0],u=!1;return null!=n[0].length&&(n=n.map((function(r){return r[0]})),u=!0),r.arange(o-1,-1,-1).forEach((function(u){t=r.arange(u+1,o).map((function(r){return i[r]*e[u][r]})),i[u]=(n[u]-r.sum(t))/e[u][u]})),u?i.map((function(r){return[r]})):i},triaLowSolve:function(e,n){var t,o=e[0].length,i=r.zeros(1,o)[0],u=!1;return null!=n[0].length&&(n=n.map((function(r){return r[0]})),u=!0),r.arange(o).forEach((function(o){t=r.arange(o).map((function(r){return e[o][r]*i[r]})),i[o]=(n[o]-r.sum(t))/e[o][o]})),u?i.map((function(r){return[r]})):i},lu:function(e){var n,t=e.length,o=r.identity(t),i=r.zeros(e.length,e[0].length);return r.arange(t).forEach((function(r){i[0][r]=e[0][r]})),r.arange(1,t).forEach((function(u){r.arange(u).forEach((function(t){n=r.arange(t).map((function(r){return o[u][r]*i[r][t]})),o[u][t]=(e[u][t]-r.sum(n))/i[t][t]})),r.arange(u,t).forEach((function(t){n=r.arange(u).map((function(r){return o[u][r]*i[r][t]})),i[u][t]=e[n.length][t]-r.sum(n)}))})),[o,i]},cholesky:function(n){var t,o=n.length,i=r.zeros(n.length,n[0].length);return r.arange(o).forEach((function(u){t=r.arange(u).map((function(r){return e.pow(i[u][r],2)})),i[u][u]=e.sqrt(n[u][u]-r.sum(t)),r.arange(u+1,o).forEach((function(e){t=r.arange(u).map((function(r){return i[u][r]*i[e][r]})),i[e][u]=(n[u][e]-r.sum(t))/i[u][u]}))})),i},gauss_jacobi:function(n,t,o,i){for(var u,a,s,c,l=0,f=0,m=n.length,h=[],d=[],p=[];l<m;l++)for(h[l]=[],d[l]=[],p[l]=[],f=0;f<m;f++)l>f?(h[l][f]=n[l][f],d[l][f]=p[l][f]=0):l<f?(d[l][f]=n[l][f],h[l][f]=p[l][f]=0):(p[l][f]=n[l][f],h[l][f]=d[l][f]=0);for(s=r.multiply(r.multiply(r.inv(p),r.add(h,d)),-1),a=r.multiply(r.inv(p),t),u=o,c=r.add(r.multiply(s,o),a),l=2;e.abs(r.norm(r.subtract(c,u)))>i;)u=c,c=r.add(r.multiply(s,u),a),l++;return c},gauss_seidel:function(n,t,o,i){for(var u,a,s,c,l,f=0,m=n.length,h=[],d=[],p=[];f<m;f++)for(h[f]=[],d[f]=[],p[f]=[],u=0;u<m;u++)f>u?(h[f][u]=n[f][u],d[f][u]=p[f][u]=0):f<u?(d[f][u]=n[f][u],h[f][u]=p[f][u]=0):(p[f][u]=n[f][u],h[f][u]=d[f][u]=0);for(c=r.multiply(r.multiply(r.inv(r.add(p,h)),d),-1),s=r.multiply(r.inv(r.add(p,h)),t),a=o,l=r.add(r.multiply(c,o),s),f=2;e.abs(r.norm(r.subtract(l,a)))>i;)a=l,l=r.add(r.multiply(c,a),s),f+=1;return l},SOR:function(n,t,o,i,u){for(var a,s,c,l,f,m=0,h=n.length,d=[],p=[],g=[];m<h;m++)for(d[m]=[],p[m]=[],g[m]=[],a=0;a<h;a++)m>a?(d[m][a]=n[m][a],p[m][a]=g[m][a]=0):m<a?(p[m][a]=n[m][a],d[m][a]=g[m][a]=0):(g[m][a]=n[m][a],d[m][a]=p[m][a]=0);for(l=r.multiply(r.inv(r.add(g,r.multiply(d,u))),r.subtract(r.multiply(g,1-u),r.multiply(p,u))),c=r.multiply(r.multiply(r.inv(r.add(g,r.multiply(d,u))),t),u),s=o,f=r.add(r.multiply(l,o),c),m=2;e.abs(r.norm(r.subtract(f,s)))>i;)s=f,f=r.add(r.multiply(l,s),c),m++;return f},householder:function(n){for(var t,o,i,u,a=n.length,s=n[0].length,c=0,l=[],f=[];c<a-1;c++){for(t=0,u=c+1;u<s;u++)t+=n[u][c]*n[u][c];for(t=(n[c+1][c]>0?-1:1)*e.sqrt(t),o=e.sqrt((t*t-n[c+1][c]*t)/2),(l=r.zeros(a,1))[c+1][0]=(n[c+1][c]-t)/(2*o),i=c+2;i<a;i++)l[i][0]=n[i][c]/(2*o);f=r.subtract(r.identity(a,s),r.multiply(r.multiply(l,r.transpose(l)),2)),n=r.multiply(f,r.multiply(n,f))}return n},QR:(n=r.sum,t=r.arange,function(o){var i,u,a,s=o.length,c=o[0].length,l=r.zeros(c,c);for(o=r.copy(o),u=0;u<c;u++){for(l[u][u]=e.sqrt(n(t(s).map((function(r){return o[r][u]*o[r][u]})))),i=0;i<s;i++)o[i][u]=o[i][u]/l[u][u];for(a=u+1;a<c;a++)for(l[u][a]=n(t(s).map((function(r){return o[r][u]*o[r][a]}))),i=0;i<s;i++)o[i][a]=o[i][a]-o[i][u]*l[u][a]}return[o,l]}),lstsq:function(e,n){var t=!1;void 0===n[0].length&&(n=n.map((function(r){return[r]})),t=!0);var o=r.QR(e),i=o[0],u=o[1],a=e[0].length,s=r.slice(i,{col:{end:a}}),c=function(e){var n=(e=r.copy(e)).length,t=r.identity(n);return r.arange(n-1,-1,-1).forEach((function(n){r.sliceAssign(t,{row:n},r.divide(r.slice(t,{row:n}),e[n][n])),r.sliceAssign(e,{row:n},r.divide(r.slice(e,{row:n}),e[n][n])),r.arange(n).forEach((function(o){var i=r.multiply(e[o][n],-1),u=r.slice(e,{row:o}),a=r.multiply(r.slice(e,{row:n}),i);r.sliceAssign(e,{row:o},r.add(u,a));var s=r.slice(t,{row:o}),c=r.multiply(r.slice(t,{row:n}),i);r.sliceAssign(t,{row:o},r.add(s,c))}))})),t}(r.slice(u,{row:{end:a}})),l=r.transpose(s);void 0===l[0].length&&(l=[l]);var f=r.multiply(r.multiply(c,l),n);return void 0===f.length&&(f=[[f]]),t?f.map((function(r){return r[0]})):f},jacobi:function(n){for(var t,o,i,u,a,s,c,l=1,f=n.length,m=r.identity(f,f),h=[];1===l;){for(a=n[0][1],i=0,u=1,t=0;t<f;t++)for(o=0;o<f;o++)t!=o&&a<e.abs(n[t][o])&&(a=e.abs(n[t][o]),i=t,u=o);for(s=n[i][i]===n[u][u]?n[i][u]>0?e.PI/4:-e.PI/4:e.atan(2*n[i][u]/(n[i][i]-n[u][u]))/2,(c=r.identity(f,f))[i][i]=e.cos(s),c[i][u]=-e.sin(s),c[u][i]=e.sin(s),c[u][u]=e.cos(s),m=r.multiply(m,c),n=r.multiply(r.multiply(r.inv(c),n),c),l=0,t=1;t<f;t++)for(o=1;o<f;o++)t!=o&&e.abs(n[t][o])>.001&&(l=1)}for(t=0;t<f;t++)h.push(n[t][t]);return[m,h]},rungekutta:function(r,e,n,t,o,i){var u,a,s;if(2===i)for(;t<=n;)o+=((u=e*r(t,o))+(a=e*r(t+e,o+u)))/2,t+=e;if(4===i)for(;t<=n;)o+=((u=e*r(t,o))+2*(a=e*r(t+e/2,o+u/2))+2*(s=e*r(t+e/2,o+a/2))+e*r(t+e,o+s))/6,t+=e;return o},romberg:function(r,n,t,o){for(var i,u,a,s,c,l=0,f=(t-n)/2,m=[],h=[],d=[];l<o/2;){for(c=r(n),a=n,s=0;a<=t;a+=f,s++)m[s]=a;for(i=m.length,a=1;a<i-1;a++)c+=(a%2!=0?4:2)*r(m[a]);c=f/3*(c+r(t)),d[l]=c,f/=2,l++}for(u=d.length,i=1;1!==u;){for(a=0;a<u-1;a++)h[a]=(e.pow(4,i)*d[a+1]-d[a])/(e.pow(4,i)-1);u=h.length,d=h,h=[],i++}return d},richardson:function(r,n,t,o){function i(r,e){for(var n,t=0,o=r.length;t<o;t++)r[t]===e&&(n=t);return n}for(var u,a,s,c,l,f=e.abs(t-r[i(r,t)+1]),m=0,h=[],d=[];o>=f;)u=i(r,t+o),a=i(r,t),h[m]=(n[u]-2*n[a]+n[2*a-u])/(o*o),o/=2,m++;for(c=h.length,s=1;1!=c;){for(l=0;l<c-1;l++)d[l]=(e.pow(4,s)*h[l+1]-h[l])/(e.pow(4,s)-1);c=d.length,h=d,d=[],s++}return h},simpson:function(r,e,n,t){for(var o,i=(n-e)/t,u=r(e),a=[],s=e,c=0,l=1;s<=n;s+=i,c++)a[c]=s;for(o=a.length;l<o-1;l++)u+=(l%2!=0?4:2)*r(a[l]);return i/3*(u+r(n))},hermite:function(r,e,n,t){for(var o,i=r.length,u=0,a=0,s=[],c=[],l=[],f=[];a<i;a++){for(s[a]=1,o=0;o<i;o++)a!=o&&(s[a]*=(t-r[o])/(r[a]-r[o]));for(c[a]=0,o=0;o<i;o++)a!=o&&(c[a]+=1/(r[a]-r[o]));l[a]=(1-2*(t-r[a])*c[a])*(s[a]*s[a]),f[a]=(t-r[a])*(s[a]*s[a]),u+=l[a]*e[a]+f[a]*n[a]}return u},lagrange:function(r,e,n){for(var t,o,i=0,u=0,a=r.length;u<a;u++){for(o=e[u],t=0;t<a;t++)u!=t&&(o*=(n-r[t])/(r[u]-r[t]));i+=o}return i},cubic_spline:function(e,n,t){for(var o,i,u=e.length,a=0,s=[],c=[],l=[],f=[],m=[],h=[];a<u-1;a++)f[a]=e[a+1]-e[a];for(l[0]=0,a=1;a<u-1;a++)l[a]=3/f[a]*(n[a+1]-n[a])-3/f[a-1]*(n[a]-n[a-1]);for(a=1;a<u-1;a++)s[a]=[],c[a]=[],s[a][a-1]=f[a-1],s[a][a]=2*(f[a-1]+f[a]),s[a][a+1]=f[a],c[a][0]=l[a];for(i=r.multiply(r.inv(s),c),o=0;o<u-1;o++)m[o]=(n[o+1]-n[o])/f[o]-f[o]*(i[o+1][0]+2*i[o][0])/3,h[o]=(i[o+1][0]-i[o][0])/(3*f[o]);for(o=0;o<u&&!(e[o]>t);o++);return n[o-=1]+(t-e[o])*m[o]+r.sq(t-e[o])*i[o]+(t-e[o])*r.sq(t-e[o])*h[o]},gauss_quadrature:function(){throw new Error("gauss_quadrature not yet implemented")},PCA:function(e){var n,t,o,i,u,a=e.length,s=e[0].length,c=0,l=[],f=[],m=[],h=[],d=[],p=[],g=[];for(c=0;c<a;c++)l[c]=r.sum(e[c])/s;for(c=0;c<s;c++)for(d[c]=[],n=0;n<a;n++)d[c][n]=e[n][c]-l[n];for(d=r.transpose(d),c=0;c<a;c++)for(p[c]=[],n=0;n<a;n++)p[c][n]=r.dot([d[c]],[d[n]])/(s-1);for(u=(o=r.jacobi(p))[0],f=o[1],g=r.transpose(u),c=0;c<f.length;c++)for(n=c;n<f.length;n++)f[c]<f[n]&&(t=f[c],f[c]=f[n],f[n]=t,m=g[c],g[c]=g[n],g[n]=m);for(i=r.transpose(d),c=0;c<a;c++)for(h[c]=[],n=0;n<i.length;n++)h[c][n]=r.dot([g[c]],[i[n]]);return[e,f,g,h]}}),function(e){for(var n=0;n<e.length;n++)!function(e){r.fn[e]=function(n,t){var o=this;return t?(setTimeout((function(){t.call(o,r.fn[e].call(o,n))}),15),this):"number"==typeof r[e](this,n)?r[e](this,n):r(r[e](this,n))}}(e[n])}("add divide multiply subtract dot pow exp log abs norm angle".split(" "))}(e,Math),function(r,e){var n=[].slice,t=r.utils.isNumber,o=r.utils.isArray;function i(r,n,t,o){if(r>1||t>1||r<=0||t<=0)throw new Error("Proportions should be greater than 0 and less than 1");var i=(r*n+t*o)/(n+o);return(r-t)/e.sqrt(i*(1-i)*(1/n+1/o))}r.extend({zscore:function(){var e=n.call(arguments);return t(e[1])?(e[0]-e[1])/e[2]:(e[0]-r.mean(e[1]))/r.stdev(e[1],e[2])},ztest:function(){var t,i=n.call(arguments);return o(i[1])?(t=r.zscore(i[0],i[1],i[3]),1===i[2]?r.normal.cdf(-e.abs(t),0,1):2*r.normal.cdf(-e.abs(t),0,1)):i.length>2?(t=r.zscore(i[0],i[1],i[2]),1===i[3]?r.normal.cdf(-e.abs(t),0,1):2*r.normal.cdf(-e.abs(t),0,1)):(t=i[0],1===i[1]?r.normal.cdf(-e.abs(t),0,1):2*r.normal.cdf(-e.abs(t),0,1))}}),r.extend(r.fn,{zscore:function(r,e){return(r-this.mean())/this.stdev(e)},ztest:function(n,t,o){var i=e.abs(this.zscore(n,o));return 1===t?r.normal.cdf(-i,0,1):2*r.normal.cdf(-i,0,1)}}),r.extend({tscore:function(){var t=n.call(arguments);return 4===t.length?(t[0]-t[1])/(t[2]/e.sqrt(t[3])):(t[0]-r.mean(t[1]))/(r.stdev(t[1],!0)/e.sqrt(t[1].length))},ttest:function(){var o,i=n.call(arguments);return 5===i.length?(o=e.abs(r.tscore(i[0],i[1],i[2],i[3])),1===i[4]?r.studentt.cdf(-o,i[3]-1):2*r.studentt.cdf(-o,i[3]-1)):t(i[1])?(o=e.abs(i[0]),1==i[2]?r.studentt.cdf(-o,i[1]-1):2*r.studentt.cdf(-o,i[1]-1)):(o=e.abs(r.tscore(i[0],i[1])),1==i[2]?r.studentt.cdf(-o,i[1].length-1):2*r.studentt.cdf(-o,i[1].length-1))}}),r.extend(r.fn,{tscore:function(r){return(r-this.mean())/(this.stdev(!0)/e.sqrt(this.cols()))},ttest:function(n,t){return 1===t?1-r.studentt.cdf(e.abs(this.tscore(n)),this.cols()-1):2*r.studentt.cdf(-e.abs(this.tscore(n)),this.cols()-1)}}),r.extend({anovafscore:function(){var t,o,i,u,a,s,c,l,f=n.call(arguments);if(1===f.length){for(a=new Array(f[0].length),c=0;c<f[0].length;c++)a[c]=f[0][c];f=a}for(o=new Array,c=0;c<f.length;c++)o=o.concat(f[c]);for(i=r.mean(o),t=0,c=0;c<f.length;c++)t+=f[c].length*e.pow(r.mean(f[c])-i,2);for(t/=f.length-1,s=0,c=0;c<f.length;c++)for(u=r.mean(f[c]),l=0;l<f[c].length;l++)s+=e.pow(f[c][l]-u,2);return t/(s/(o.length-f.length))},anovaftest:function(){var e,o,i,u,a=n.call(arguments);if(t(a[0]))return 1-r.centralF.cdf(a[0],a[1],a[2]);var s=r.anovafscore(a);for(e=a.length-1,i=0,u=0;u<a.length;u++)i+=a[u].length;return o=i-e-1,1-r.centralF.cdf(s,e,o)},ftest:function(e,n,t){return 1-r.centralF.cdf(e,n,t)}}),r.extend(r.fn,{anovafscore:function(){return r.anovafscore(this.toArray())},anovaftes:function(){var e,n=0;for(e=0;e<this.length;e++)n+=this[e].length;return r.ftest(this.anovafscore(),this.length-1,n-this.length)}}),r.extend({qscore:function(){var o,i,u,a,s,c=n.call(arguments);return t(c[0])?(o=c[0],i=c[1],u=c[2],a=c[3],s=c[4]):(o=r.mean(c[0]),i=r.mean(c[1]),u=c[0].length,a=c[1].length,s=c[2]),e.abs(o-i)/(s*e.sqrt((1/u+1/a)/2))},qtest:function(){var e,t=n.call(arguments);3===t.length?(e=t[0],t=t.slice(1)):7===t.length?(e=r.qscore(t[0],t[1],t[2],t[3],t[4]),t=t.slice(5)):(e=r.qscore(t[0],t[1],t[2]),t=t.slice(3));var o=t[0],i=t[1];return 1-r.tukey.cdf(e,i,o-i)},tukeyhsd:function(e){for(var n=r.pooledstdev(e),t=e.map((function(e){return r.mean(e)})),o=e.reduce((function(r,e){return r+e.length}),0),i=[],u=0;u<e.length;++u)for(var a=u+1;a<e.length;++a){var s=r.qtest(t[u],t[a],e[u].length,e[a].length,n,o,e.length);i.push([[u,a],s])}return i}}),r.extend({normalci:function(){var t,o=n.call(arguments),i=new Array(2);return t=4===o.length?e.abs(r.normal.inv(o[1]/2,0,1)*o[2]/e.sqrt(o[3])):e.abs(r.normal.inv(o[1]/2,0,1)*r.stdev(o[2])/e.sqrt(o[2].length)),i[0]=o[0]-t,i[1]=o[0]+t,i},tci:function(){var t,o=n.call(arguments),i=new Array(2);return t=4===o.length?e.abs(r.studentt.inv(o[1]/2,o[3]-1)*o[2]/e.sqrt(o[3])):e.abs(r.studentt.inv(o[1]/2,o[2].length-1)*r.stdev(o[2],!0)/e.sqrt(o[2].length)),i[0]=o[0]-t,i[1]=o[0]+t,i},significant:function(r,e){return r<e}}),r.extend(r.fn,{normalci:function(e,n){return r.normalci(e,n,this.toArray())},tci:function(e,n){return r.tci(e,n,this.toArray())}}),r.extend(r.fn,{oneSidedDifferenceOfProportions:function(e,n,t,o){var u=i(e,n,t,o);return r.ztest(u,1)},twoSidedDifferenceOfProportions:function(e,n,t,o){var u=i(e,n,t,o);return r.ztest(u,2)}})}(e,Math),e.models=function(){function r(r,n){var t=r.length,o=n[0].length-1,i=t-o-1,u=e.lstsq(n,r),a=e.multiply(n,u.map((function(r){return[r]}))).map((function(r){return r[0]})),s=e.subtract(r,a),c=e.mean(r),l=e.sum(a.map((function(r){return Math.pow(r-c,2)}))),f=e.sum(r.map((function(r,e){return Math.pow(r-a[e],2)}))),m=l+f;return{exog:n,endog:r,nobs:t,df_model:o,df_resid:i,coef:u,predict:a,resid:s,ybar:c,SST:m,SSE:l,SSR:f,R2:l/m}}function n(n){var t,o,i=(t=n.exog,o=t[0].length,e.arange(o).map((function(n){var i=e.arange(o).filter((function(r){return r!==n}));return r(e.col(t,n).map((function(r){return r[0]})),e.col(t,i))}))),u=Math.sqrt(n.SSR/n.df_resid),a=i.map((function(r){var e=r.SST,n=r.R2;return u/Math.sqrt(e*(1-n))})),s=n.coef.map((function(r,e){return(r-0)/a[e]})),c=s.map((function(r){var t=e.studentt.cdf(r,n.df_resid);return 2*(t>.5?1-t:t)})),l=e.studentt.inv(.975,n.df_resid),f=n.coef.map((function(r,e){var n=l*a[e];return[r-n,r+n]}));return{se:a,t:s,p:c,sigmaHat:u,interval95:f}}return{ols:function(t,o){var i=r(t,o),u=n(i),a=function(r){var n,t,o,i=r.R2/r.df_model/((1-r.R2)/r.df_resid);return{F_statistic:i,pvalue:1-(n=i,t=r.df_model,o=r.df_resid,e.beta.cdf(n/(o/t+n),t/2,o/2))}}(i),s=1-(1-i.R2)*((i.nobs-1)/i.df_resid);return i.t=u,i.f=a,i.adjust_R2=s,i}}}(),e.extend({buildxmatrix:function(){for(var r=new Array(arguments.length),n=0;n<arguments.length;n++)r[n]=[1].concat(arguments[n]);return e(r)},builddxmatrix:function(){for(var r=new Array(arguments[0].length),n=0;n<arguments[0].length;n++)r[n]=[1].concat(arguments[0][n]);return e(r)},buildjxmatrix:function(r){for(var n=new Array(r.length),t=0;t<r.length;t++)n[t]=r[t];return e.builddxmatrix(n)},buildymatrix:function(r){return e(r).transpose()},buildjymatrix:function(r){return r.transpose()},matrixmult:function(r,n){var t,o,i,u,a;if(r.cols()==n.rows()){if(n.rows()>1){for(u=[],t=0;t<r.rows();t++)for(u[t]=[],o=0;o<n.cols();o++){for(a=0,i=0;i<r.cols();i++)a+=r.toArray()[t][i]*n.toArray()[i][o];u[t][o]=a}return e(u)}for(u=[],t=0;t<r.rows();t++)for(u[t]=[],o=0;o<n.cols();o++){for(a=0,i=0;i<r.cols();i++)a+=r.toArray()[t][i]*n.toArray()[o];u[t][o]=a}return e(u)}},regress:function(r,n){var t=e.xtranspxinv(r),o=r.transpose(),i=e.matrixmult(e(t),o);return e.matrixmult(i,n)},regresst:function(r,n,t){var o=e.regress(r,n),i={anova:{}},u=e.jMatYBar(r,o);i.yBar=u;var a=n.mean();i.anova.residuals=e.residuals(n,u),i.anova.ssr=e.ssr(u,a),i.anova.msr=i.anova.ssr/(r[0].length-1),i.anova.sse=e.sse(n,u),i.anova.mse=i.anova.sse/(n.length-(r[0].length-1)-1),i.anova.sst=e.sst(n,a),i.anova.mst=i.anova.sst/(n.length-1),i.anova.r2=1-i.anova.sse/i.anova.sst,i.anova.r2<0&&(i.anova.r2=0),i.anova.fratio=i.anova.msr/i.anova.mse,i.anova.pvalue=e.anovaftest(i.anova.fratio,r[0].length-1,n.length-(r[0].length-1)-1),i.anova.rmse=Math.sqrt(i.anova.mse),i.anova.r2adj=1-i.anova.mse/i.anova.mst,i.anova.r2adj<0&&(i.anova.r2adj=0),i.stats=new Array(r[0].length);for(var s,c,l,f=e.xtranspxinv(r),m=0;m<o.length;m++)s=Math.sqrt(i.anova.mse*Math.abs(f[m][m])),c=Math.abs(o[m]/s),l=e.ttest(c,n.length-r[0].length-1,t),i.stats[m]=[o[m],s,c,l];return i.regress=o,i},xtranspx:function(r){return e.matrixmult(r.transpose(),r)},xtranspxinv:function(r){var n=e.matrixmult(r.transpose(),r);return e.inv(n)},jMatYBar:function(r,n){var t=e.matrixmult(r,n);return new e(t)},residuals:function(r,n){return e.matrixsubtract(r,n)},ssr:function(r,e){for(var n=0,t=0;t<r.length;t++)n+=Math.pow(r[t]-e,2);return n},sse:function(r,e){for(var n=0,t=0;t<r.length;t++)n+=Math.pow(r[t]-e[t],2);return n},sst:function(r,e){for(var n=0,t=0;t<r.length;t++)n+=Math.pow(r[t]-e,2);return n},matrixsubtract:function(r,n){for(var t=new Array(r.length),o=0;o<r.length;o++){t[o]=new Array(r[o].length);for(var i=0;i<r[o].length;i++)t[o][i]=r[o][i]-n[o][i]}return e(t)}}),e.jStat=e,e)},184:(r,e,n)=>{"use strict";n.d(e,{$:()=>u});var t=n(976),o=n(870),i=n(559);class u extends t.JsViewer{constructor(r){super(),this.canvas=o.canvas(),this.gridCellStyle=t.GridCellStyle.create(),this.renderer=r,this.root.append(this.canvas),this.canvas.style.width="100%",this.canvas.style.height="100%",o.tools.handleResize(this.canvas,((r,e)=>{this.canvas.width=r,this.canvas.height=e,this.render()}));const e=r=>e=>{this.gridCell&&r(this.gridCell,e)};this.canvas.onmousemove=e(this.renderer.onMouseMove),this.canvas.onmouseenter=e(this.renderer.onMouseEnter),this.canvas.onmouseleave=e(this.renderer.onMouseLeave)}static fromGridCell(r){const e=new u(new i.cv);return e.gridCell=r,e.render(),e}render(){if(!this.gridCell)return;const r=this.canvas.getContext("2d");r.clearRect(0,0,this.canvas.width,this.canvas.height),this.renderer.renderInternal(r,0,0,this.canvas.width,this.canvas.height,this.gridCell.dart,this.gridCellStyle)}}},840:(r,e,n)=>{"use strict";n.d(e,{DI:()=>u}),n(976);var t=n(469),o=n(363),i=(n(875),n(414),function(r,e,n,t){return new(n||(n=Promise))((function(o,i){function u(r){try{s(t.next(r))}catch(r){i(r)}}function a(r){try{s(t.throw(r))}catch(r){i(r)}}function s(r){var e;r.done?o(r.value):(e=r.value,e instanceof n?e:new n((function(r){r(e)}))).then(u,a)}s((t=t.apply(r,e||[])).next())}))});function u(){return i(this,void 0,void 0,(function*(){t.shell.windows.showContextPanel=!0;const r=yield t.data.loadTable(`${o._package.webRoot}files/curves-demo.csv`);t.shell.addTableView(r)}))}},188:(r,e,n)=>{"use strict";n.d(e,{No:()=>g,Z:()=>x,hS:()=>p});var t=n(976),o=n(870),i=n(416),u=n(875),a=n(559),s=n(184),c=n(711),l=function(r,e,n,t){return new(n||(n=Promise))((function(o,i){function u(r){try{s(t.next(r))}catch(r){i(r)}}function a(r){try{s(t.throw(r))}catch(r){i(r)}}function s(r){var e;r.done?o(r.value):(e=r.value,e instanceof n?e:new n((function(r){r(e)}))).then(u,a)}s((t=t.apply(r,e||[])).next())}))};const f="chartOptions",m="seriesOptions";var h;!function(r){r.DATAFRAME="Dataframe",r.COLUMN="Column",r.CELL="Cell"}(h||(h={}));const d={count:"totalCount",nulls:"missingValueCount",unique:"uniqueCount",values:"valueCount",min:"min",max:"max",sum:"sum",avg:"avg",stdev:"stdev",variance:"variance",skew:"skew",kurt:"kurt",med:"med",q1:"q1",q2:"q2",q3:"q3"};function p(r,e){const n=(0,i.Y6)(r);return r.parameters?e.logX&&r.parameters[2]>0&&(r.parameters[2]=Math.log10(r.parameters[2])):r.parameters=(0,i.PK)(r,n,e).parameters,(0,i.tq)(r,n,e)}function g(r,e){var n,o,i;const u={logX:null===(n=r.chartOptions)||void 0===n?void 0:n.logX,logY:null===(o=r.chartOptions)||void 0===o?void 0:o.logY},a=[],s=[],c=[],l=[],f=[],m=[],h=[];for(let e=0,n=0;e<(null===(i=r.series)||void 0===i?void 0:i.length);e++){if(r.series[e].points.every((r=>r.outlier)))continue;const t=p(r.series[e],u);a[n]=t.rSquared,s[n]=t.auc,c[n]=t.interceptX,l[n]=t.interceptY,f[n]=t.slope,m[n]=t.top,h[n]=t.bottom,n++}return{rSquared:t.Stats.fromValues(a)[d[e]],auc:t.Stats.fromValues(s)[d[e]],interceptX:t.Stats.fromValues(c)[d[e]],interceptY:t.Stats.fromValues(l)[d[e]],slope:t.Stats.fromValues(f)[d[e]],top:t.Stats.fromValues(m)[d[e]],bottom:t.Stats.fromValues(h)[d[e]]}}function v(r){for(let e=0;e<r.length;e++){const n=r.get(e);if(""===n)continue;const t=(0,c.f)(n);r.set(e,JSON.stringify(t))}r.setTag(a.Rj,"")}function y(r,e,n,t){var o;void 0===r.cell.column.temp[`${f}-custom-title`]&&function(r){var e,n;const t=r.columns.bySemTypeAll(u.j2);for(let r=0;r<t.length;r++){u.kW.map((e=>{t[r].temp[`${f}-custom-${e.name}`]=!1})),u.K0.map((e=>{t[r].temp[`${m}-custom-${e.name}`]=!1})),t[r].getTag(a.Rj)===a.NH&&v(t[r]);for(let o=0;o<t[r].length;o++){if(""===t[r].get(o))continue;const i=null!==(n=JSON.parse(null!==(e=t[r].get(o))&&void 0!==e?e:"{}"))&&void 0!==n?n:{};u.kW.map((e=>{i.chartOptions&&void 0!==i.chartOptions[e.name]&&(t[r].temp[`${f}-custom-${e.name}`]=!0)})),u.K0.map((e=>{if(i.series)for(const n of i.series)void 0!==n[e.name]&&(t[r].temp[`${m}-custom-${e.name}`]=!0)}))}}}(r.cell.dataFrame);const s=e.property.name,c=t===h.DATAFRAME?(0,i.jG)(r.cell.dataFrame):(0,i.hq)(r.cell.column);if(n===f?c.chartOptions[s]=e.value:n===m&&(c.seriesOptions[s]=e.value),t===h.CELL){const t=r.cell.value;if(""===t)return;const i=null!==(o=JSON.parse(null!=t?t:"{}"))&&void 0!==o?o:{};!function(r,e,n){const t=e.property.name;if(n===f){if(void 0===r.chartOptions)return;r.chartOptions[t]=e.value}else if(n===m){if(void 0===r.series)return;for(let n=0;n<r.series.length;n++)r.series[n][t]=e.value}}(i,e,n),r.cell.value=JSON.stringify(i)}else{let e;t===h.DATAFRAME?(r.cell.dataFrame.tags[u.Kp]=JSON.stringify(c),e=r.cell.dataFrame.columns.bySemTypeAll(u.j2)):(r.cell.column.tags[u.Kp]=JSON.stringify(c),e=[r.cell.column]);for(let r=0;r<e.length;r++){if(t===h.DATAFRAME){const t=(0,i.hq)(e[r]);n===f?delete t.chartOptions[s]:delete t.seriesOptions[s],e[r].tags[u.Kp]=JSON.stringify(t)}!1!==e[r].temp[`${n}-custom-${s}`]&&(e[r].init((t=>{var o,i;const u=e[r].get(t);if(""===u)return u;const a=null!==(i=JSON.parse(null!==(o=e[r].get(t))&&void 0!==o?o:"{}"))&&void 0!==i?i:{};if(n===f){if(void 0===a.chartOptions)return u;if(void 0===a.chartOptions[s])return u;delete a.chartOptions[s]}else{if(void 0===a.series)return u;let r=!1;for(const e of a.series)void 0!==e[s]&&(delete e[s],r=!0);if(a.seriesOptions&&delete a.seriesOptions[s],!r)return u}return JSON.stringify(a)})),e[r].temp[`${n}-custom-${s}`]=!1)}}r.grid.invalidate()}class x extends t.ObjectHandler{get type(){return"GridCell"}isApplicable(r){return r instanceof t.GridCell&&r.cellType===u.d8}renderProperties(r,e=null){var n,c,h,d,v,x,w,b,T,C,M;const _=o.accordion("Curves property panel"),S=t.Property.js("level",t.TYPE.STRING,{description:"Controls the level at which properties will be switched",defaultValue:"Column",choices:["Dataframe","Column","Cell"],nullable:!1}),A=o.input.forProperty(S);o.tooltip.bind(A.captionLabel,"Controls the level at which properties will be switched");const k=(0,a.W$)(r),O=(0,i.hq)(r.cell.column),P=(0,i.jG)(r.cell.dataFrame),N={onValueChanged:e=>y(r,e,m,A.value)},j={onValueChanged:e=>y(r,e,f,A.value)};(0,a.fi)(null===(n=P.seriesOptions)||void 0===n?void 0:n.pointColor)||(0,a.fi)(null===(c=O.seriesOptions)||void 0===c?void 0:c.pointColor)||(k.seriesOptions?(0,a.fi)(k.seriesOptions.pointColor)||(k.seriesOptions.pointColor=t.Color.toHtml(t.Color.getCategoricalColor(0))):(0,a.fi)(k.series?k.series[0].pointColor:"")||(k.series[0].pointColor=t.Color.toHtml(t.Color.getCategoricalColor(0)))),(0,a.fi)(null===(h=P.seriesOptions)||void 0===h?void 0:h.fitLineColor)||(0,a.fi)(null===(d=O.seriesOptions)||void 0===d?void 0:d.fitLineColor)||(k.seriesOptions?(0,a.fi)(k.seriesOptions.fitLineColor)||(k.seriesOptions.fitLineColor=t.Color.toHtml(t.Color.getCategoricalColor(0))):(0,a.fi)(k.series?k.series[0].fitLineColor:"")||(k.series[0].fitLineColor=t.Color.toHtml(t.Color.getCategoricalColor(0)))),(0,a.fi)(null===(v=P.seriesOptions)||void 0===v?void 0:v.outlierColor)||(0,a.fi)(null===(x=O.seriesOptions)||void 0===x?void 0:x.outlierColor)||(k.seriesOptions?(0,a.fi)(k.seriesOptions.outlierColor)||(k.seriesOptions.outlierColor=t.Color.toHtml(t.Color.red)):(0,a.fi)(k.series?k.series[0].outlierColor:"")||(k.series[0].outlierColor=t.Color.toHtml(t.Color.red))),(0,a.BI)(u.K0,O.seriesOptions,k.seriesOptions?k.seriesOptions:k.series&&null!==(w=k.series[0])&&void 0!==w?w:{}),(0,a.BI)(u.K0,P.seriesOptions,k.seriesOptions?k.seriesOptions:k.series&&null!==(b=k.series[0])&&void 0!==b?b:{}),(0,a.BI)(u.kW,O.chartOptions,k.chartOptions?k.chartOptions:{}),(0,a.BI)(u.kW,P.chartOptions,k.chartOptions?k.chartOptions:{}),(null===(T=k.chartOptions)||void 0===T?void 0:T.allowXZeroes)&&(null===(C=k.chartOptions)||void 0===C?void 0:C.logX)&&(null===(M=k.series)||void 0===M?void 0:M.some((r=>r.points.some((r=>0===r.x)))))&&(0,a.kb)(k);const q=o.form([A]),E=u.K0.map((r=>o.input.forProperty(r,k.seriesOptions?k.seriesOptions:k.series[0],N)));o.forms.addGroup(q,"Series options",E),o.forms.addGroup(q,"Chart options",u.kW.map((r=>o.input.forProperty(r,k.chartOptions,j)))),_.addPane("Options",(()=>q));const R=t.Property.js("series",t.TYPE.STRING,{description:"Controls whether to show series statistics or aggregated statistics",defaultValue:"All",choices:["all","aggregated"],nullable:!1}),L=o.input.forProperty(R,null,{onValueChanged(r){_.getPane("Fit").root.lastElementChild.replaceChildren(F())}}),Y=t.Property.js("aggregation type",t.TYPE.STRING,{description:"Controls which aggregation to use on the series statistics",defaultValue:"med",choices:Object.values(t.STATS),nullable:!1}),V=o.input.forProperty(Y,null,{onValueChanged(r){_.getPane("Fit").root.lastElementChild.replaceChildren(F())}});function F(){var e,n,a;const s=o.divV("aggregated"===L.stringValue?[L.root,V.root]:[L.root]),c=(0,i.dU)(k);if(c.x<=0&&k.chartOptions&&(k.chartOptions.logX=!1),c.y<=0&&k.chartOptions&&(k.chartOptions.logY=!1),"all"===L.stringValue){const i={logX:null===(e=k.chartOptions)||void 0===e?void 0:e.logX,logY:null===(n=k.chartOptions)||void 0===n?void 0:n.logY};for(let e=0;e<k.series.length;e++){const n=k.series[e],c=p(n,i),f=n.fitLineColor&&t.Color.fromHtml(n.fitLineColor)?n.fitLineColor:t.Color.toHtml(t.Color.getCategoricalColor(e));s.appendChild(o.panel([o.h1(null!==(a=n.name)&&void 0!==a?a:"series "+e,{style:{color:f}}),o.input.form(c,u.sw,{onCreated:i=>i.root.appendChild(o.iconFA("plus",(()=>l(this,void 0,void 0,(function*(){const o={df:r.cell.dataFrame,colName:r.gridColumn.name,propName:i.property.name,seriesName:n.name,seriesNumber:e};yield t.Func.find({name:"addStatisticsColumn"})[0].prepare(o).call(void 0,void 0,{processed:!1})}))),`Calculate ${i.property.name} for the whole column`))})]))}}else{const e=g(k,V.stringValue);s.appendChild(o.panel([o.h1(`series ${V.stringValue}`),o.input.form(e,u.sw,{onCreated:e=>e.root.appendChild(o.iconFA("plus",(()=>l(this,void 0,void 0,(function*(){const n={df:r.cell.dataFrame,colName:r.gridColumn.name,propName:e.property.name,aggrType:V.stringValue};yield t.Func.find({name:"addAggrStatisticsColumn"})[0].prepare(n).call(void 0,void 0,{processed:!1})}))),`Calculate ${e.property.name} ${V.stringValue} for the whole column`))})]))}return s}return _.addPane("Fit",(()=>F())),_.addPane("Chart",(()=>s.$.fromGridCell(r).root)),_.root}}},711:(r,e,n)=>{"use strict";n.d(e,{f:()=>c});var t=n(976),o=n(875);const i={x:"xAxis",y:"yAxis"},u={min:"min",max:"max"};function a(r){var e,n,i;const u=null===(n=null===(e=r.getElementsByTagName("params")[0])||void 0===e?void 0:e.childNodes[0].nodeValue)||void 0===n?void 0:n.split(",").map(Number);let a=null===(i=r.getElementsByTagName("function")[0])||void 0===i?void 0:i.getAttribute("type");a=a&&"sigif"!==a?a:o.yB;const s=r.getElementsByTagName("settings")[0].getAttribute("markerColor"),c=r.getElementsByTagName("settings")[0].getAttribute("color"),l=!!r.getElementsByTagName("settings")[0].getAttribute("drawLine"),f={name:r.getAttribute("name"),fitFunction:a,markerType:t.MARKER_TYPE.CIRCLE,pointColor:s,fitLineColor:c,showFitLine:l,showPoints:"points",showCurveConfidenceInterval:!1,clickToToggle:!1};return u&&(f.parameters=[u[2],u[1],u[0],u[3]]),f}function s(r){const e=function(r){var e,n,t;const o=null===(e=r.getElementsByTagName("x")[0].childNodes[0].nodeValue)||void 0===e?void 0:e.split(","),i=null===(n=r.getElementsByTagName("y")[0].childNodes[0].nodeValue)||void 0===n?void 0:n.split(","),u=null===(t=r.getElementsByTagName("mask")[0].childNodes[0].nodeValue)||void 0===t?void 0:t.split(""),a=[];for(let r=0;r<o.length;r++)a[r]={x:+o[r],y:+i[r],outlier:!Boolean(u[r])};return a}(r),n=a(r),t={points:e};return Object.assign(t,n),t}function c(r){const e=(new DOMParser).parseFromString(r,"text/xml"),n=e.getElementsByTagName("grid")[0],t=(c=e.getElementsByTagName("settings")[0],{minX:+(o=n).getElementsByTagName(i.x)[0].getAttribute(u.min),minY:+o.getElementsByTagName(i.y)[0].getAttribute(u.min),maxX:+o.getElementsByTagName(i.x)[0].getAttribute(u.max),maxY:+o.getElementsByTagName(i.y)[0].getAttribute(u.max),xAxisName:c.getAttribute("xLabel"),yAxisName:c.getAttribute("yLabel"),logX:!!c.getAttribute("logX")});var o,c;const l=e.getElementsByTagName("seriesCollection")[0],f=a(l.getElementsByTagName("series")[0]),m=function(r){const e=[],n=r.getElementsByTagName("series").length;for(let t=0;t<n;t++){const n=r.getElementsByTagName("series")[t];e[t]=s(n)}return e}(l);return{chartOptions:t,seriesOptions:f,series:m}}},559:(r,e,n)=>{"use strict";n.d(e,{cv:()=>Y,Rj:()=>g,NH:()=>v,W$:()=>S,fi:()=>k,BI:()=>M,Qp:()=>_,kb:()=>L});var t=n(976),o=n(469),i=n(870),u=n(875),a=n(111),s=n(766);const c=window,l=new Intl.NumberFormat("en-US",{minimumFractionDigits:2,maximumFractionDigits:2});class f{static getUniqueName(r,e,n){return c.grok_Utils_GetUniqueName(r,e,null==n?void 0:n.auto,null==n?void 0:n.idx,null==n?void 0:n.render,null==n?void 0:n.choices)}static isEmpty(r){return null==r||""==r}static formatNumber(r){return l.format(r)}}var m=n(416),h=n(711),d=n(184),p=n(188);const g=".fitChartFormat",v="3dx",y=100,x=18,w=4,b=3.5,T={solid:[],dotted:[1,1],dashed:[5,5],dashdotted:[5,5,2,5]};function C(r,e,n){var o;t.Paint.marker(r,t.MARKER_TYPE.OUTLIER,e.midX,e.midY,t.Color.red,(o=.8*Math.min(e.width,e.height),0,30,Math.min(Math.max(o,0),30)))}function M(r,e,n){if(e&&n)for(const t of r)!(t.name in n)&&t.name in e&&(n[t.name]=e[t.name])}function _(r){if(0===r.length)return null;const e={points:[],name:r[0].name,fitFunction:r[0].fitFunction,markerType:r[0].markerType,lineStyle:r[0].lineStyle,pointColor:r[0].pointColor,fitLineColor:r[0].fitLineColor,confidenceIntervalColor:r[0].confidenceIntervalColor,outlierColor:r[0].outlierColor,connectDots:r[0].connectDots,showFitLine:r[0].showFitLine,showPoints:r[0].showPoints,showCurveConfidenceInterval:r[0].showCurveConfidenceInterval,errorModel:r[0].errorModel,clickToToggle:r[0].clickToToggle,labels:r[0].labels,droplines:r[0].droplines,columnName:r[0].columnName};for(const n of r)e.points=[...e.points,...n.points];return e}function S(r){var e,n,o,i,a;let s=r.cell.value;s.includes("|")&&(s=s.replaceAll("|",""));const c=(null===(n=null===(e=r.cell)||void 0===e?void 0:e.column)||void 0===n?void 0:n.type)===t.TYPE.STRING?r.cell.column.getTag(g)===v?(0,h.f)(s):null!==(o=JSON.parse(null!=s?s:"{}"))&&void 0!==o?o:{}:(0,m.TL)(),l=r.cell.column?(0,m.hq)(r.cell.column):{},f=r.cell.column?(0,m.jG)(r.cell.dataFrame):{};null!==(i=c.series)&&void 0!==i||(c.series=[]),null!==(a=c.chartOptions)&&void 0!==a||(c.chartOptions=l.chartOptions),M(u.kW,l.chartOptions,c.chartOptions),M(u.kW,f.chartOptions,c.chartOptions);for(const r of c.series)M(u.K0,l.seriesOptions,r),M(u.K0,f.seriesOptions,r);return c}function A(r,e,n){if(r.width<y||r.height<55)return[r,void 0,void 0];const t=e?45:38,o=e?30:15,i=n?25:5;return[r.cutLeft(t).cutBottom(o).cutTop(i).cutRight(x),r.getBottom(o).getTop(i).cutLeft(t).cutRight(x),r.getLeft(t).getRight(x).cutBottom(o).cutTop(i)]}function k(r){return null!=r&&""!==r&&void 0!==t.Color.fromHtml(r)}function O(r,e,n,t){r.moveTo(t.xToScreen(e)-w/2,t.yToScreen(n)),r.lineTo(t.xToScreen(e)+w/2,t.yToScreen(n))}function P(r,e,n,o,i,u){O(r,e,n.lowerAdjacentValue,o),r.moveTo(o.xToScreen(e),o.yToScreen(n.lowerAdjacentValue)),r.lineTo(o.xToScreen(e),o.yToScreen(n.upperAdjacentValue)),O(r,e,n.upperAdjacentValue,o),t.Paint.marker(r,t.MARKER_TYPE.CIRCLE,o.xToScreen(e),o.yToScreen(n.q2),u,b*i)}function N(r,e,n,o,i,u,a){for(let i=0;i<e.points.length;i++){const s=e.points[i],c=e.connectDots?u:s.outlier?s.outlierColor&&t.Color.fromHtml(s.outlierColor)?t.Color.fromHtml(s.outlierColor):a:s.color&&t.Color.fromHtml(s.color)?t.Color.fromHtml(s.color):u,l=s.marker?s.marker:e.markerType,f=e.connectDots?4*o:s.outlier?12*o:s.size?s.size:4*o;t.Paint.marker(r,e.connectDots?l:s.outlier?t.MARKER_TYPE.OUTLIER:l,n.xToScreen(s.x),n.yToScreen(s.y),c,f),s.stdev&&!s.outlier&&(r.strokeStyle=t.Color.toHtml(c),r.beginPath(),r.moveTo(n.xToScreen(s.x),n.yToScreen(s.y+s.stdev)),r.lineTo(n.xToScreen(s.x),n.yToScreen(s.y-s.stdev)),r.stroke())}}function j(r,e,n,o,i){for(let u=0,s=null;u<e.points.length;u++){const c=e.points[u];if(c.outlier)continue;const l=u+1<e.points.length&&e.points[u+1].x===c.x;if(!s&&l)s=u;else if(null!==s&&!l){const l=[];for(let r=s,n=0;r<=u;r++,n++)l[n]=e.points[r].y;const f=(0,a.G)(l);if(r.beginPath(),P(r,c.x,f,n,o,i),r.stroke(),"both"===e.showPoints)for(let i=0;i<l.length;i++)(l[i]<f.lowerAdjacentValue||l[i]>f.upperAdjacentValue)&&t.Paint.marker(r,t.MARKER_TYPE.OUTLIER,n.xToScreen(c.x),n.yToScreen(l[i]),e.pointColor?t.Color.fromHtml(e.pointColor):t.Color.scatterPlotMarker,6*o);s=null}}}function q(r,e,n,t,o,i,a,s){r.beginPath();const c=i?a?45:38:0,l=i?x:0,f=o===u.vK.TOP?e.confidenceTop:e.confidenceBottom;for(let e=c;e<=n.width-l;e++){const o=n.x+e,i=s.logX?Math.log10(t.xToWorld(o)):t.xToWorld(o),u=s.logY?t.yToScreen(Math.pow(10,f(i))):t.yToScreen(f(i));e===c?r.moveTo(o,u):r.lineTo(o,u)}r.stroke()}function E(r,e,n,t,o,i,u){r.beginPath();const a=o?i?45:38:0,s=o?x:0;for(let o=a;o<=n.width-s;o++){const i=n.x+o,s=u.logX?Math.log10(t.xToWorld(i)):t.xToWorld(i),c=u.logY?t.yToScreen(Math.pow(10,e.confidenceTop(s))):t.yToScreen(e.confidenceTop(s));o===a?r.moveTo(i,c):r.lineTo(i,c)}for(let o=n.width-s;o>=a;o--){const i=n.x+o,a=u.logX?Math.log10(t.xToWorld(i)):t.xToWorld(i),s=u.logY?t.yToScreen(Math.pow(10,e.confidenceBottom(a))):t.yToScreen(e.confidenceBottom(a));r.lineTo(i,s)}r.closePath(),r.fill()}function R(r,e,n,t,o,i){i.logX&&(n=Math.pow(10,n));const u=i.logX?Math.log10(n):n,a=i.logY?Math.pow(10,o(u)):o(u);r.moveTo(e.xToScreen(t.minX),e.yToScreen(a)),r.lineTo(e.xToScreen(n),e.yToScreen(a)),r.lineTo(e.xToScreen(n),e.yToScreen(t.minY))}function L(r){var e;for(let n=0;n<(null===(e=r.series)||void 0===e?void 0:e.length);n++){const e=r.series[n];if(e.points.every((r=>0!==r.x)))continue;let t=Number.MAX_VALUE,o=0,i=0;const u=[];for(let r=0;r<e.points.length;r++)e.points[r].x<t&&0!==e.points[r].x&&(t=e.points[r].x),e.points[r].x>o&&0!==e.points[r].x&&(o=e.points[r].x),u.includes(e.points[r].x)||(u[u.length]=e.points[r].x,i++);const a=Math.pow(10,Math.log10(t)-(Math.log10(o)-Math.log10(t)/(i-1)));for(let r=0;r<e.points.length;r++)0===e.points[r].x&&(e.points[r].x=a)}}class Y extends t.GridCellRenderer{get name(){return u.d8}get cellType(){return u.d8}getDefaultSize(r){return{width:220,height:150}}onClick(r,e){var n,t,u,a,c,l,f,d,x,w,b;if(!r.cell.value)return;const T=r.cell.column.getTag(g)===v?(0,h.f)(r.cell.value):S(r);if(0===(null===(n=T.series)||void 0===n?void 0:n.length))return void(o.shell.o=i.divText("No series to show",{style:{color:"red"}}));if(null===(t=T.series)||void 0===t?void 0:t.some((r=>0===r.points.length)))return void(o.shell.o=i.divText("There were series with no points",{style:{color:"red"}}));if(null===(u=T.series)||void 0===u?void 0:u.some((r=>r.points.every((r=>0===r.x)))))return void(o.shell.o=i.divText("There were series with all x zeroes",{style:{color:"red"}}));if(null===(a=T.series)||void 0===a?void 0:a.some((r=>r.points.every((r=>0===r.y)))))return void(o.shell.o=i.divText("There were series with all y zeroes",{style:{color:"red"}}));o.shell.o=r;const C=r.bounds.inflate(-6,-6),M=A(C,r.bounds.width>=180&&r.bounds.height>=140,r.bounds.width>=275&&r.bounds.height>=225)[0],_=(0,m.dU)(T),k=new s.l(_,M,null!==(l=null===(c=T.chartOptions)||void 0===c?void 0:c.logX)&&void 0!==l&&l,null!==(d=null===(f=T.chartOptions)||void 0===f?void 0:f.logY)&&void 0!==d&&d);for(let n=0;n<(null===(x=T.series)||void 0===x?void 0:x.length);n++)if(!(T.series[n].connectDots||!T.series[n].clickToToggle||"points"!==T.series[n].showPoints||C.width<y||C.height<55))for(let t=0;t<T.series[n].points.length;t++){const o=T.series[n].points[t],i=k.xToScreen(o.x),u=k.yToScreen(o.y),a=(o.outlier?12:4)/2+2;if(e.offsetX>=i-a&&e.offsetX<=i+a&&e.offsetY>=u-a&&e.offsetY<=u+a){o.outlier=!o.outlier;const e=r.grid.dataFrame.columns.byTags({".sourceColumn":r.cell.column.name});if(e)for(const t of e){const e={logX:null===(w=T.chartOptions)||void 0===w?void 0:w.logX,logY:null===(b=T.chartOptions)||void 0===b?void 0:b.logY},o=null!==t.tags[".seriesAggregation"]?(0,p.No)(T,t.tags[".seriesAggregation"]):t.tags[".seriesNumber"]===n?(0,p.hS)(T.series[n],e):null;null!==o&&t.set(r.cell.rowIndex,o[t.tags[".statistics"]])}if(r.cell.column.getTag(g)!==v){const e=JSON.parse(r.cell.value);e.series[n].points[t].outlier=o.outlier,r.cell.value=JSON.stringify(e)}return}}}onDoubleClick(r,e){if(!r.cell.value)return;const n=d.$.fromGridCell(r),t=i.dialog({title:"Edit chart"}).add(n.root).show({resizable:!0}).root.getElementsByClassName("d4-dialog-contents dlg-edit-chart")[0].firstChild;n.canvas.width=t.clientWidth,n.canvas.height=t.clientHeight,n.render(),t.style.width="100%",t.style.height="100%",i.tools.handleResize(t,((r,e)=>{n.canvas.width=r,n.canvas.height=e,n.render()}))}renderCurves(r,e,n,o,i,a){var c,l,h,d,p,g,v,w,b,C,M,_,S,k,O,P,Y,V,F,X,I,B,D,G,U,H,W,$,z,K,Q,Z;r.save(),r.beginPath(),r.rect(e,n,o,i),r.clip(),(null===(c=a.chartOptions)||void 0===c?void 0:c.allowXZeroes)&&(null===(l=a.chartOptions)||void 0===l?void 0:l.logX)&&(null===(h=a.series)||void 0===h?void 0:h.some((r=>r.points.some((r=>0===r.x)))))&&L(a);const J=new t.Rect(e,n,o,i).inflate(-6,-6),rr=J.width>=y&&J.height>=55,er=o>=180&&i>=140&&!!(null===(d=a.chartOptions)||void 0===d?void 0:d.xAxisName)&&!!a.chartOptions.yAxisName,nr=o>=275&&i>=225&&!!(null===(p=a.chartOptions)||void 0===p?void 0:p.title),tr=o>=325&&i>=275,or=o>=120&&i>=110,[ir,ur,ar]=A(J,er,nr),sr=(0,m.dU)(a);(sr.x<0&&a.chartOptions||0===sr.x&&a.chartOptions&&!a.chartOptions.allowXZeroes)&&(a.chartOptions.logX=!1),sr.y<=0&&a.chartOptions&&(a.chartOptions.logY=!1);const cr=new s.l(sr,ir,null!==(v=null===(g=a.chartOptions)||void 0===g?void 0:g.logX)&&void 0!==v&&v,null!==(b=null===(w=a.chartOptions)||void 0===w?void 0:w.logY)&&void 0!==b&&b),lr=Math.min(ir.width,ir.height),fr=lr>100?1:.2+lr/100*.8,mr={logX:null===(C=a.chartOptions)||void 0===C?void 0:C.logX,logY:null===(M=a.chartOptions)||void 0===M?void 0:M.logY};r.save(),r.font='11px Roboto, "Roboto Local"',cr.drawCoordinateGrid(r,ur,ar),r.restore();for(let e=0;e<(null===(_=a.series)||void 0===_?void 0:_.length);e++){const n=a.series[e];if(n.points.some((r=>void 0===r.x||void 0===r.y)))continue;if((o<70||i<45)&&(n.showPoints="",a.chartOptions&&(a.chartOptions.showStatistics=[])),n.points.sort(((r,e)=>r.x-e.x)),null!==(S=n.connectDots)&&void 0!==S&&S){r.strokeStyle=n.pointColor&&t.Color.fromHtml(n.pointColor)?n.pointColor:t.Color.toHtml(t.Color.getCategoricalColor(e)),r.lineWidth=2*fr,r.beginPath();for(let e=0;e<n.points.length;e++){const t=n.points[e].x,o=n.points[e].y,i=cr.xToScreen(t),u=cr.yToScreen(o);0===e?r.moveTo(i,u):r.lineTo(i,u)}r.stroke()}let s=!0;const c=(0,m.Y6)(n);let l=null;if(!n.connectDots||n.showFitLine)if(n.parameters)(null===(k=a.chartOptions)||void 0===k?void 0:k.logX)&&n.parameters[2]>0&&(n.parameters[2]=Math.log10(n.parameters[2])),l=(0,m.kG)(n,c);else{const r=(0,m.PK)(n,c,mr);l=r.fittedCurve,n.parameters=r.parameters,s=!1}if(null===(O=n.showPoints)||void 0===O||O){const o=n.pointColor&&t.Color.fromHtml(n.pointColor)?n.pointColor:t.Color.toHtml(t.Color.getCategoricalColor(e)),i=n.outlierColor&&t.Color.fromHtml(n.outlierColor)?t.Color.fromHtml(n.outlierColor):t.Color.red;r.strokeStyle=o,n.connectDots&&""!=n.showPoints||"points"===n.showPoints?N(r,n,cr,fr,0,t.Color.fromHtml(o),i):["candlesticks","both"].includes(n.showPoints)&&j(r,n,cr,fr,t.Color.fromHtml(o))}if(null===(P=n.showFitLine)||void 0===P||P){const o=n.fitLineColor&&t.Color.fromHtml(n.fitLineColor)?n.fitLineColor:t.Color.toHtml(t.Color.getCategoricalColor(e));r.save(),r.strokeStyle=o,r.lineWidth=2*fr,r.beginPath(),n.lineStyle&&r.setLineDash(T[n.lineStyle]);const i=rr?er?45:38:0,u=rr?x:0;for(let e=i;e<=J.width-u;e++){const n=J.x+e,t=(null===(Y=a.chartOptions)||void 0===Y?void 0:Y.logX)?Math.log10(cr.xToWorld(n)):cr.xToWorld(n),o=(null===(V=a.chartOptions)||void 0===V?void 0:V.logY)?cr.yToScreen(Math.pow(10,l(t))):cr.yToScreen(l(t));e===i?r.moveTo(n,o):r.lineTo(n,o)}r.stroke(),r.restore()}if((null===(F=n.showFitLine)||void 0===F||F)&&null!==(X=n.showCurveConfidenceInterval)&&void 0!==X&&X){r.strokeStyle=null!==(I=n.confidenceIntervalColor)&&void 0!==I?I:u.Qc,r.fillStyle=null!==(B=n.confidenceIntervalColor)&&void 0!==B?B:u.XD;const e=(0,m.LC)(n,c,s,mr);q(r,e,J,cr,u.vK.TOP,rr,er,mr),q(r,e,J,cr,u.vK.BOTTOM,rr,er,mr),E(r,e,J,cr,rr,er,mr)}if((null===(D=n.showFitLine)||void 0===D||D)&&n.droplines&&or){r.save(),r.strokeStyle="blue",r.lineWidth=fr,r.beginPath(),r.setLineDash([5,5]);for(let e=0;e<n.droplines.length;e++)"IC50"===n.droplines[e]&&R(r,cr,n.parameters[2],sr,l,mr);r.stroke(),r.restore()}if((null===(G=n.showFitLine)||void 0===G||G)&&(null===(U=a.chartOptions)||void 0===U?void 0:U.showStatistics)){const o=(0,m.tq)(n,c,mr);for(let i=0;i<a.chartOptions.showStatistics.length;i++){const s=a.chartOptions.showStatistics[i],c=u.sw.find((r=>r.name===s));if(c){const u=f.formatNumber(c.get(o)),a=n.fitLineColor&&t.Color.fromHtml(n.fitLineColor)?n.fitLineColor:t.Color.toHtml(t.Color.getCategoricalColor(e));r.fillStyle=a,r.textAlign="left",r.fillText(c.name+": "+u,ir.x+5,ir.y+20+20*i)}}}}if(nr&&(r.font='12px Roboto, "Roboto Local"',r.textAlign="center",r.fillStyle="black",r.fillText(null===(H=a.chartOptions)||void 0===H?void 0:H.title,ir.midX-5,n+15)),er){r.font='11px Roboto, "Roboto Local"',r.textAlign="center",r.fillStyle="black",r.fillText(null===(W=a.chartOptions)||void 0===W?void 0:W.xAxisName,ir.midX-5,n+i-10),r.translate(e,n),r.rotate(-Math.PI/2);const t=nr?25:5;r.fillText(null===($=a.chartOptions)||void 0===$?void 0:$.yAxisName,-(ir.height/2+t+15),15),r.restore()}if(tr){r.font='11px Roboto, "Roboto Local"';for(let e=0;e<(null===(z=a.series)||void 0===z?void 0:z.length);e++){r.beginPath();const n=a.series[e],o=n.fitLineColor&&t.Color.fromHtml(n.fitLineColor)?n.fitLineColor:t.Color.toHtml(t.Color.getCategoricalColor(e)),i=n.pointColor&&t.Color.fromHtml(n.pointColor)?t.Color.fromHtml(n.pointColor):t.Color.getCategoricalColor(e);r.strokeStyle=o,r.lineWidth=2*fr;const u=`${(null===(K=a.chartOptions)||void 0===K?void 0:K.showColumnLabel)&&null!==(Q=n.columnName)&&void 0!==Q?Q:""} ${null!==(Z=n.name)&&void 0!==Z?Z:""}`,s=r.measureText(u).width;r.moveTo(ir.maxX-s-25,ir.y+20-4+20*e),r.lineTo(ir.maxX-s-5,ir.y+20-4+20*e);const c=n.markerType?n.markerType:t.MARKER_TYPE.CIRCLE;t.Paint.marker(r,c,ir.maxX-s-25+10,ir.y+20-4+20*e,i,4*fr),r.fillStyle="black",r.fillText(u,ir.maxX-s,ir.y+20+20*e),r.stroke()}r.restore()}r.restore()}render(r,e,n,o,i,u,a){var s,c,l,f,m,d,p;if(o<20||i<10)return;if(!u.cell.value)return;const y=(null===(s=u.cell.column)||void 0===s?void 0:s.getTag(g))===v?(0,h.f)(u.cell.value):S(u),x=new t.Rect(e,n,o,i).inflate(-6,-6);0!==(null===(c=y.series)||void 0===c?void 0:c.length)?(null===(l=y.series)||void 0===l?void 0:l.some((r=>0===r.points.length)))||(null===(f=y.series)||void 0===f?void 0:f.some((r=>r.points.every((r=>0===r.x)))))||(null===(m=y.series)||void 0===m?void 0:m.some((r=>r.points.every((r=>0===r.y)))))?C(r,x):(null===(d=y.series)||void 0===d||d.forEach((r=>r.columnName=u.cell.column.name)),(null===(p=y.chartOptions)||void 0===p?void 0:p.mergeSeries)&&(y.series=[_(y.series)]),this.renderCurves(r,e,n,o,i,y)):C(r,x)}onMouseMove(r,e){var n,o,u,a,c;if(!r.cell.value)return;if(r.bounds.width<70||r.bounds.height<45){const n=i.canvas(300,200);this.render(n.getContext("2d"),0,0,300,200,r,null);const t=i.divV([n]);i.tooltip.show(t,e.x,e.y)}const l=r.cell.column.getTag(g)===v?(0,h.f)(r.cell.value):S(r),f=r.bounds.inflate(-6,-6);if(f.width>=70&&f.height>=45){const h=A(f,r.bounds.width>=180&&r.bounds.height>=140,r.bounds.width>=275&&r.bounds.height>=225)[0],d=(0,m.dU)(l),p=new s.l(d,h,null!==(o=null===(n=l.chartOptions)||void 0===n?void 0:n.logX)&&void 0!==o&&o,null!==(a=null===(u=l.chartOptions)||void 0===u?void 0:u.logY)&&void 0!==a&&a);for(let r=0;r<(null===(c=l.series)||void 0===c?void 0:c.length);r++)if("points"===l.series[r].showPoints)for(let n=0;n<l.series[r].points.length;n++){const o=l.series[r].points[n],u=p.xToScreen(o.x),a=p.yToScreen(o.y),s=(o.outlier?12:4)/2+2;if(e.offsetX>=u-s&&e.offsetX<=u+s&&e.offsetY>=a-s&&e.offsetY<=a+s)return i.tooltip.show(i.divV([i.divText(`x: ${t.format(o.x,"#0.000")}`),i.divText(`y: ${t.format(o.y,"#0.000")}`)]),e.x+16,e.y+16),void(!l.series[r].connectDots&&l.series[r].clickToToggle&&f.width>=y&&f.height>=55&&(document.body.style.cursor="pointer"))}i.tooltip.hide()}document.body.style.cursor="default"}}},363:(r,e,n)=>{"use strict";n.r(e),n.d(e,{_FitViewer:()=>b,_initCurves:()=>C,_package:()=>p,addAggrStatisticsColumn:()=>_,addStatisticsColumn:()=>M,curveFitDemo:()=>T,fitCellRenderer:()=>w});var t=n(976),o=n(188),i=n(559),u=n(870),a=n(184),s=n(875);const c=rxjs.operators,l=rxjs;class f extends a.${constructor(){super(new i.cv),this.curvesColumnNames=[],this.showSelectedRowsCurves=!1,this.showCurrentRowCurve=!0,this.showMouseOverRowCurve=!0,this.mergeColumnSeries=!1,this.rows=[],this.data=new s.cY,this.curvesColumnNames=this.addProperty("curvesColumnNames",t.TYPE.COLUMN_LIST),this.showSelectedRowsCurves=this.bool("showSelectedRowsCurves",!1,{description:"Adds curves from the selected rows"}),this.showCurrentRowCurve=this.bool("showCurrentRowCurve",!0),this.showMouseOverRowCurve=this.bool("showMouseOverRowCurve",!0),this.mergeColumnSeries=this.bool("mergeColumnSeries",!1);for(const r of s.kW)this.addProperty("mergeSeries"===r.name?"mergeCellSeries":r.name,r.propertyType,r.defaultValue,r.options)}static fromChartData(r){let e=new f;return e.data=r,e.render(),e}applyViewerProperties(){(0,i.BI)(s.kW,this,this.data.chartOptions)}createChartData(){var r,e,n,o,u,a;if(0===(null===(r=this.curvesColumnNames)||void 0===r?void 0:r.length))return;this.rows.length=0,this.showCurrentRowCurve&&-1!==this.dataFrame.currentRowIdx&&this.rows.push(this.dataFrame.currentRowIdx),this.showMouseOverRowCurve&&-1!==this.dataFrame.mouseOverRowIdx&&this.rows.push(this.dataFrame.mouseOverRowIdx),this.showSelectedRowsCurves&&-1!==this.dataFrame.mouseOverRowIdx&&this.rows.push(...this.dataFrame.selection.getSelectedIndexes()),this.data=new s.cY;const c=null===(e=this.tableView)||void 0===e?void 0:e.grid;this.data.chartOptions.showColumnLabel=this.props.get("showColumnLabel");const l=this.props.get("mergeCellSeries");for(const r of this.curvesColumnNames){const e=[];for(const t of new Set(this.rows)){const o=c.cell(r,c.tableRowToGrid(t)),u=(0,i.W$)(o);null===(n=u.series)||void 0===n||n.forEach((r=>r.columnName=o.cell.column.name)),l&&(u.series=[(0,i.Qp)(u.series)]),e.push(...u.series)}this.mergeColumnSeries?null===(o=this.data.series)||void 0===o||o.push((0,i.Qp)(e)):null===(u=this.data.series)||void 0===u||u.push(...e)}null===(a=this.data.series)||void 0===a||a.forEach(((r,e)=>{var n,o,i;r.pointColor=t.Color.toHtml(t.Color.getCategoricalColor((null===(n=this.data.series)||void 0===n?void 0:n.length)>20?0:e)),r.fitLineColor=t.Color.toHtml(t.Color.getCategoricalColor((null===(o=this.data.series)||void 0===o?void 0:o.length)>20?0:e)),r.showCurveConfidenceInterval=!1,r.droplines=[],(null===(i=this.data.series)||void 0===i?void 0:i.length)>20&&(r.showPoints="",r.lineStyle="solid")}))}onPropertyChanged(r){var e;"curvesColumnNames"===(null==r?void 0:r.name)&&this.props.set("showColumnLabel",(null===(e=this.curvesColumnNames)||void 0===e?void 0:e.length)>1),this.applyViewerProperties(),this.createChartData(),this.render()}onTableAttached(){var r;const e=null===(r=this.tableView)||void 0===r?void 0:r.grid,n=this.dataFrame.columns.bySemType(s.j2);null!==n&&(this.curvesColumnNames=[n.name]),(0,l.merge)(this.dataFrame.onCurrentCellChanged,e.onCellMouseEnter,this.dataFrame.onSelectionChanged).pipe((0,c.debounce)((r=>(0,l.interval)(50)))).subscribe((r=>{this.createChartData(),this.render()}))}_showErrorMessage(r){this.root.appendChild(u.divText(r,"d4-viewer-error"))}_removeErrorMessage(){const r=this.root.getElementsByClassName("d4-viewer-error")[0];r&&this.root.removeChild(r)}render(){var r;const e=this.canvas.getContext("2d");e.clearRect(0,0,this.canvas.width,this.canvas.height),0!==(null===(r=this.curvesColumnNames)||void 0===r?void 0:r.length)?(this._removeErrorMessage(),this.renderer.renderCurves(e,0,0,this.canvas.width,this.canvas.height,this.data)):this._showErrorMessage("The MultiCurveViewer viewer requires a minimum of 1 curves column.")}}var m=n(840),h=n(711),d=function(r,e,n,t){return new(n||(n=Promise))((function(o,i){function u(r){try{s(t.next(r))}catch(r){i(r)}}function a(r){try{s(t.throw(r))}catch(r){i(r)}}function s(r){var e;r.done?o(r.value):(e=r.value,e instanceof n?e:new n((function(r){r(e)}))).then(u,a)}s((t=t.apply(r,e||[])).next())}))};const p=new t.Package,g=".sourceColumn",v=".seriesNumber",y=".seriesAggregation",x=".statistics";function w(){return new i.cv}function b(){return new f}function T(){return d(this,void 0,void 0,(function*(){yield(0,m.DI)()}))}function C(){t.ObjectHandler.register(new o.Z)}function M(r,e,n,u,a){var s;const c=t.Viewer.grid(r),l=c.col(e),f=t.Column.float(`${e}_${u}_${n}`,null===(s=l.column)||void 0===s?void 0:s.length);f.tags[g]=e,f.tags[v]=a,f.tags[x]=n,f.init((r=>{var u,s,l,f,m;const d=t.GridCell.fromColumnRow(c,e,c.tableRowToGrid(r));if(""===d.cell.value)return null;const p=d.cell.column.getTag(i.Rj)===i.NH?(0,h.f)(d.cell.value):(0,i.W$)(d);if(void 0===p.series[a]||p.series[a].points.every((r=>r.outlier)))return null;(null===(u=p.chartOptions)||void 0===u?void 0:u.allowXZeroes)&&(null===(s=p.chartOptions)||void 0===s?void 0:s.logX)&&(null===(l=p.series)||void 0===l?void 0:l.some((r=>r.points.some((r=>0===r.x)))))&&(0,i.kb)(p);const g={logX:null===(f=p.chartOptions)||void 0===f?void 0:f.logX,logY:null===(m=p.chartOptions)||void 0===m?void 0:m.logY};return(0,o.hS)(p.series[a],g)[n]})),r.columns.insert(f,l.idx)}function _(r,e,n,u){var a;const s=t.Viewer.grid(r),c=s.col(e),l=t.Column.float(`${e}_${u}_${n}`,null===(a=c.column)||void 0===a?void 0:a.length);l.tags[g]=e,l.tags[y]=u,l.tags[x]=n,l.init((r=>{var a,c,l,f;const m=t.GridCell.fromColumnRow(s,e,s.tableRowToGrid(r));if(""===m.cell.value)return null;const d=m.cell.column.getTag(i.Rj)===i.NH?(0,h.f)(m.cell.value):(0,i.W$)(m);return(null===(a=d.series)||void 0===a?void 0:a.every((r=>r.points.every((r=>r.outlier)))))?null:((null===(c=d.chartOptions)||void 0===c?void 0:c.allowXZeroes)&&(null===(l=d.chartOptions)||void 0===l?void 0:l.logX)&&(null===(f=d.series)||void 0===f?void 0:f.some((r=>r.points.some((r=>0===r.x)))))&&(0,i.kb)(d),(0,o.No)(d,u)[n])})),r.columns.insert(l,c.idx)}},976:r=>{"use strict";r.exports=DG},469:r=>{"use strict";r.exports=grok},870:r=>{"use strict";r.exports=ui},414:r=>{"use strict";r.exports=wu}},__webpack_module_cache__={};function __webpack_require__(r){var e=__webpack_module_cache__[r];if(void 0!==e)return e.exports;var n=__webpack_module_cache__[r]={exports:{}};return __webpack_modules__[r].call(n.exports,n,n.exports,__webpack_require__),n.exports}__webpack_require__.n=r=>{var e=r&&r.__esModule?()=>r.default:()=>r;return __webpack_require__.d(e,{a:e}),e},__webpack_require__.d=(r,e)=>{for(var n in e)__webpack_require__.o(e,n)&&!__webpack_require__.o(r,n)&&Object.defineProperty(r,n,{enumerable:!0,get:e[n]})},__webpack_require__.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(r){if("object"==typeof window)return window}}(),__webpack_require__.o=(r,e)=>Object.prototype.hasOwnProperty.call(r,e),__webpack_require__.r=r=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})};var __webpack_exports__=__webpack_require__(363);curves=__webpack_exports__})();
2
2
  //# sourceMappingURL=package.js.map