(self.webpackChunkcausalvis=self.webpackChunkcausalvis||[]).push([[254],{2254:function(r,n){var t,o;t=function(r){"use strict";var n=Object.assign||function(r){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(r[o]=t[o])}return r};function t(r){if(Array.isArray(r)){for(var n=0,t=Array(r.length);n<r.length;n++)t[n]=r[n];return t}return Array.from(r)}var o={order:2,precision:2,period:null};function e(r,n){var t=[],o=[];r.forEach((function(r,e){null!==r[1]&&(o.push(r),t.push(n[e]))}));var e=o.reduce((function(r,n){return r+n[1]}),0)/o.length,i=o.reduce((function(r,n){var t=n[1]-e;return r+t*t}),0);return 1-o.reduce((function(r,n,o){var e=t[o],i=n[1]-e[1];return r+i*i}),0)/i}function i(r,n){var t=Math.pow(10,n);return Math.round(r*t)/t}var a={linear:function(r,n){for(var t=[0,0,0,0,0],o=0,a=0;a<r.length;a++)null!==r[a][1]&&(o++,t[0]+=r[a][0],t[1]+=r[a][1],t[2]+=r[a][0]*r[a][0],t[3]+=r[a][0]*r[a][1],t[4]+=r[a][1]*r[a][1]);var u=o*t[2]-t[0]*t[0],c=o*t[3]-t[0]*t[1],p=0===u?0:i(c/u,n.precision),s=i(t[1]/o-p*t[0]/o,n.precision),f=function(r){return[i(r,n.precision),i(p*r+s,n.precision)]},l=r.map((function(r){return f(r[0])}));return{points:l,predict:f,equation:[p,s],r2:i(e(r,l),n.precision),string:0===s?"y = "+p+"x":"y = "+p+"x + "+s}},exponential:function(r,n){for(var t=[0,0,0,0,0,0],o=0;o<r.length;o++)null!==r[o][1]&&(t[0]+=r[o][0],t[1]+=r[o][1],t[2]+=r[o][0]*r[o][0]*r[o][1],t[3]+=r[o][1]*Math.log(r[o][1]),t[4]+=r[o][0]*r[o][1]*Math.log(r[o][1]),t[5]+=r[o][0]*r[o][1]);var a=t[1]*t[2]-t[5]*t[5],u=Math.exp((t[2]*t[3]-t[5]*t[4])/a),c=(t[1]*t[4]-t[5]*t[3])/a,p=i(u,n.precision),s=i(c,n.precision),f=function(r){return[i(r,n.precision),i(p*Math.exp(s*r),n.precision)]},l=r.map((function(r){return f(r[0])}));return{points:l,predict:f,equation:[p,s],string:"y = "+p+"e^("+s+"x)",r2:i(e(r,l),n.precision)}},logarithmic:function(r,n){for(var t=[0,0,0,0],o=r.length,a=0;a<o;a++)null!==r[a][1]&&(t[0]+=Math.log(r[a][0]),t[1]+=r[a][1]*Math.log(r[a][0]),t[2]+=r[a][1],t[3]+=Math.pow(Math.log(r[a][0]),2));var u=i((o*t[1]-t[2]*t[0])/(o*t[3]-t[0]*t[0]),n.precision),c=i((t[2]-u*t[0])/o,n.precision),p=function(r){return[i(r,n.precision),i(i(c+u*Math.log(r),n.precision),n.precision)]},s=r.map((function(r){return p(r[0])}));return{points:s,predict:p,equation:[c,u],string:"y = "+c+" + "+u+" ln(x)",r2:i(e(r,s),n.precision)}},power:function(r,n){for(var t=[0,0,0,0,0],o=r.length,a=0;a<o;a++)null!==r[a][1]&&(t[0]+=Math.log(r[a][0]),t[1]+=Math.log(r[a][1])*Math.log(r[a][0]),t[2]+=Math.log(r[a][1]),t[3]+=Math.pow(Math.log(r[a][0]),2));var u=(o*t[1]-t[0]*t[2])/(o*t[3]-Math.pow(t[0],2)),c=(t[2]-u*t[0])/o,p=i(Math.exp(c),n.precision),s=i(u,n.precision),f=function(r){return[i(r,n.precision),i(i(p*Math.pow(r,s),n.precision),n.precision)]},l=r.map((function(r){return f(r[0])}));return{points:l,predict:f,equation:[p,s],string:"y = "+p+"x^"+s,r2:i(e(r,l),n.precision)}},polynomial:function(r,n){for(var o=[],a=[],u=0,c=0,p=r.length,s=n.order+1,f=0;f<s;f++){for(var l=0;l<p;l++)null!==r[l][1]&&(u+=Math.pow(r[l][0],f)*r[l][1]);o.push(u),u=0;for(var h=[],v=0;v<s;v++){for(var g=0;g<p;g++)null!==r[g][1]&&(c+=Math.pow(r[g][0],f+v));h.push(c),c=0}a.push(h)}a.push(o);for(var M=function(r,n){for(var t=r,o=r.length-1,e=[n],i=0;i<o;i++){for(var a=i,u=i+1;u<o;u++)Math.abs(t[i][u])>Math.abs(t[i][a])&&(a=u);for(var c=i;c<o+1;c++){var p=t[c][i];t[c][i]=t[c][a],t[c][a]=p}for(var s=i+1;s<o;s++)for(var f=o;f>=i;f--)t[f][s]-=t[f][i]*t[i][s]/t[i][i]}for(var l=o-1;l>=0;l--){for(var h=0,v=l+1;v<o;v++)h+=t[v][l]*e[v];e[l]=(t[o][l]-h)/t[l][l]}return e}(a,s).map((function(r){return i(r,n.precision)})),d=function(r){return[i(r,n.precision),i(M.reduce((function(n,t,o){return n+t*Math.pow(r,o)}),0),n.precision)]},y=r.map((function(r){return d(r[0])})),w="y = ",x=M.length-1;x>=0;x--)w+=x>1?M[x]+"x^"+x+" + ":1===x?M[x]+"x + ":M[x];return{string:w,points:y,predict:d,equation:[].concat(t(M)).reverse(),r2:i(e(r,y),n.precision)}}};r.exports=Object.keys(a).reduce((function(r,t){return n({_round:i},r,(c=function(r,e){return a[t](r,n({},o,e))},(u=t)in(e={})?Object.defineProperty(e,u,{value:c,enumerable:!0,configurable:!0,writable:!0}):e[u]=c,e));var e,u,c}),{})},void 0===(o=t.apply(n,[r]))||(r.exports=o)}}]);