MCPcopy Create free account
hub / github.com/alignoth/alignoth / Os

Function Os

resources/vega.min.js:4889–4933  ·  view source on GitHub ↗
(t, e, n, r)

Source from the content-addressed store, hash-verified

4887 };
4888 }
4889 function Os(t, e, n, r) {
4890 if (0 === r) return Es(t, e, n);
4891 if (1 === r) return $s(t, e, n);
4892 if (2 === r) return Ns(t, e, n);
4893 const [i, o, a, s] = Cs(t, e, n),
4894 u = i.length,
4895 l = [],
4896 c = [],
4897 f = r + 1;
4898 let h, d, p, g, m;
4899 for (h = 0; h < f; ++h) {
4900 for (p = 0, g = 0; p < u; ++p) g += Math.pow(i[p], h) * o[p];
4901 for (l.push(g), m = new Float64Array(f), d = 0; d < f; ++d) {
4902 for (p = 0, g = 0; p < u; ++p) g += Math.pow(i[p], h + d);
4903 m[d] = g;
4904 }
4905 c.push(m);
4906 }
4907 c.push(l);
4908 const y = (function (t) {
4909 const e = t.length - 1,
4910 n = [];
4911 let r, i, o, a, s;
4912 for (r = 0; r < e; ++r) {
4913 for (a = r, i = r + 1; i < e; ++i)
4914 Math.abs(t[r][i]) > Math.abs(t[r][a]) && (a = i);
4915 for (o = r; o < e + 1; ++o)
4916 ((s = t[o][r]), (t[o][r] = t[o][a]), (t[o][a] = s));
4917 for (i = r + 1; i < e; ++i)
4918 for (o = e; o >= r; o--) t[o][i] -= (t[o][r] * t[r][i]) / t[r][r];
4919 }
4920 for (i = e - 1; i >= 0; --i) {
4921 for (s = 0, o = i + 1; o < e; ++o) s += t[o][i] * n[o];
4922 n[i] = (t[e][i] - s) / t[i][i];
4923 }
4924 return n;
4925 })(c),
4926 v = (t) => {
4927 t -= a;
4928 let e = s + y[0] + y[1] * t + y[2] * t * t;
4929 for (h = 3; h < f; ++h) e += y[h] * Math.pow(t, h);
4930 return e;
4931 };
4932 return { coef: Rs(f, y, -a, s), predict: v, rSquared: Ss(t, e, n, s, v) };
4933 }
4934 function Rs(t, e, n, r) {
4935 const i = Array(t);
4936 let o, a, s, u;

Callers

nothing calls this directly

Calls 6

$sFunction · 0.85
CsFunction · 0.85
SsFunction · 0.85
EsFunction · 0.70
NsFunction · 0.70
RsFunction · 0.70

Tested by

no test coverage detected