(window.webpackJsonp=window.webpackJsonp||[]).push([[177],{944:function(e,t,r){"use strict";r.r(t),r.d(t,"loess",(function(){return s})),r.d(t,"regression",(function(){return l}));var a=r(35),n=r(10),i=r(1);function o(e,t){var r,a,n,i,o,s,u=[],l=function(e){return e(i)};if(null==t)u.push(e);else for(r={},a=0,n=e.length;a<n;++a)i=e[a],(s=r[o=t.map(l)])||(r[o]=s=[],s.dims=o,u.push(s)),s.push(i);return u}function s(e){n.g.call(this,null,e)}s.Definition={type:"Loess",metadata:{generates:!0},params:[{name:"x",type:"field",required:!0},{name:"y",type:"field",required:!0},{name:"groupby",type:"field",array:!0},{name:"bandwidth",type:"number",default:.3},{name:"as",type:"string",array:!0}]},Object(i.z)(s,n.g,{transform(e,t){const r=t.fork(t.NO_SOURCE|t.NO_FIELDS);if(!this.value||t.changed()||e.modified()){const s=o(t.materialize(t.SOURCE).source,e.groupby),u=(e.groupby||[]).map(i.h),l=u.length,d=e.as||[Object(i.h)(e.x),Object(i.h)(e.y)],c=[];s.forEach(t=>{Object(a.z)(t,e.x,e.y,e.bandwidth||.3).forEach(e=>{const r={};for(let e=0;e<l;++e)r[u[e]]=t.dims[e];r[d[0]]=e[0],r[d[1]]=e[1],c.push(Object(n.l)(r))})}),this.value&&(r.rem=this.value),this.value=r.add=r.source=c}return r}});const u={linear:a.y,log:a.A,exp:a.x,pow:a.C,quad:a.D,poly:a.B};function l(e){n.g.call(this,null,e)}l.Definition={type:"Regression",metadata:{generates:!0},params:[{name:"x",type:"field",required:!0},{name:"y",type:"field",required:!0},{name:"groupby",type:"field",array:!0},{name:"method",type:"string",default:"linear",values:Object.keys(u)},{name:"order",type:"number",default:3},{name:"extent",type:"number",array:!0,length:2},{name:"params",type:"boolean",default:!1},{name:"as",type:"string",array:!0}]},Object(i.z)(l,n.g,{transform(e,t){const r=t.fork(t.NO_SOURCE|t.NO_FIELDS);if(!this.value||t.changed()||e.modified()){const s=o(t.materialize(t.SOURCE).source,e.groupby),l=(e.groupby||[]).map(i.h),d=e.method||"linear",c=e.order||3,p=((e,t)=>"poly"===e?t:"quad"===e?2:1)(d,c),f=e.as||[Object(i.h)(e.x),Object(i.h)(e.y)],h=u[d],m=[];let y=e.extent;Object(i.w)(u,d)||Object(i.o)("Invalid regression method: "+d),null!=y&&"log"===d&&y[0]<=0&&(t.dataflow.warn("Ignoring extent with values <= 0 for log regression."),y=null),s.forEach(r=>{if(r.length<=p)return void t.dataflow.warn("Skipping regression with more parameters than data points.");const o=h(r,e.x,e.y,c);if(e.params)return void m.push(Object(n.l)({keys:r.dims,coef:o.coef,rSquared:o.rSquared}));const s=y||Object(i.q)(r,e.x),u=e=>{const t={};for(let e=0;e<l.length;++e)t[l[e]]=r.dims[e];t[f[0]]=e[0],t[f[1]]=e[1],m.push(Object(n.l)(t))};"linear"===d?s.forEach(e=>u([e,o.predict(e)])):Object(a.E)(o.predict,s,25,200).forEach(u)}),this.value&&(r.rem=this.value),this.value=r.add=r.source=m}return r}})}}]);