{"version":3,"sources":["jsdelivr-header.js","/npm/ml-regression-exponential@3.0.2/lib/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACNA,aAEA,IAAI,iBAAmB,QAAQ,sBAC3B,yBAA2B,QAAQ,+BAEvC,MAAM,8BAA8B,iBAAiB,eACnD,WAAA,CAAY,EAAG,GACb,SACU,IAAN,GACF,KAAK,EAAI,EAAE,EACX,KAAK,EAAI,EAAE,IAEX,iBAAiB,iBAAiB,EAAG,GACrC,QAAQ,KAAM,EAAG,GAErB,CAEA,QAAA,CAAS,GACP,OAAO,KAAK,EAAI,KAAK,IAAI,EAAQ,KAAK,EACxC,CAEA,MAAA,GACE,MAAO,CACL,KAAM,wBACN,EAAG,KAAK,EACR,EAAG,KAAK,EAEZ,CAEA,QAAA,CAAS,GACP,MAAO,UAAU,iBAAiB,iBAChC,KAAK,EACL,WACQ,iBAAiB,iBAAiB,KAAK,EAAG,SACtD,CAEA,OAAA,CAAQ,GACN,OAAI,KAAK,GAAK,EACL,UAAU,iBAAiB,iBAChC,KAAK,EACL,QACK,iBAAiB,iBAAiB,KAAK,EAAG,OAE1C,iBAAiB,iBAAiB,iBACvC,KAAK,EACL,UACO,iBAAiB,kBAAkB,KAAK,EAAG,OAExD,CAEA,WAAO,CAAK,GACV,GAAkB,0BAAd,EAAK,KACP,MAAM,IAAI,UAAU,sCAEtB,OAAO,IAAI,uBAAsB,EAAM,EACzC,EAGF,SAAS,QAAQ,EAAI,EAAG,GACtB,MAAM,EAAI,EAAE,OACN,EAAK,IAAI,MAAM,GACrB,IAAK,IAAI,EAAI,EAAG,EAAI,EAAG,IACrB,EAAG,GAAK,KAAK,IAAI,EAAE,IAGrB,MAAM,EAAS,IAAI,yBAAyB,uBAAuB,EAAG,GACtE,EAAG,EAAI,EAAO,MACd,EAAG,EAAI,KAAK,IAAI,EAAO,UACzB,CAEA,QAAQ,sBAAwB","file":"/npm/ml-regression-exponential@3.0.2/lib/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/ml-regression-exponential@3.0.2/lib/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","'use strict';\n\nvar mlRegressionBase = require('ml-regression-base');\nvar mlRegressionSimpleLinear = require('ml-regression-simple-linear');\n\nclass ExponentialRegression extends mlRegressionBase.BaseRegression {\n  constructor(x, y) {\n    super();\n    if (x === true) {\n      this.A = y.A;\n      this.B = y.B;\n    } else {\n      mlRegressionBase.checkArrayLength(x, y);\n      regress(this, x, y);\n    }\n  }\n\n  _predict(input) {\n    return this.B * Math.exp(input * this.A);\n  }\n\n  toJSON() {\n    return {\n      name: 'exponentialRegression',\n      A: this.A,\n      B: this.B,\n    };\n  }\n\n  toString(precision) {\n    return `f(x) = ${mlRegressionBase.maybeToPrecision(\n      this.B,\n      precision,\n    )} * e^(${mlRegressionBase.maybeToPrecision(this.A, precision)} * x)`;\n  }\n\n  toLaTeX(precision) {\n    if (this.A >= 0) {\n      return `f(x) = ${mlRegressionBase.maybeToPrecision(\n        this.B,\n        precision,\n      )}e^{${mlRegressionBase.maybeToPrecision(this.A, precision)}x}`;\n    } else {\n      return `f(x) = \\\\frac{${mlRegressionBase.maybeToPrecision(\n        this.B,\n        precision,\n      )}}{e^{${mlRegressionBase.maybeToPrecision(-this.A, precision)}x}}`;\n    }\n  }\n\n  static load(json) {\n    if (json.name !== 'exponentialRegression') {\n      throw new TypeError('not a exponential regression model');\n    }\n    return new ExponentialRegression(true, json);\n  }\n}\n\nfunction regress(er, x, y) {\n  const n = x.length;\n  const yl = new Array(n);\n  for (let i = 0; i < n; i++) {\n    yl[i] = Math.log(y[i]);\n  }\n\n  const linear = new mlRegressionSimpleLinear.SimpleLinearRegression(x, yl);\n  er.A = linear.slope;\n  er.B = Math.exp(linear.intercept);\n}\n\nexports.ExponentialRegression = ExponentialRegression;\n"]}