-
Notifications
You must be signed in to change notification settings - Fork 4
/
interactive.js
14 lines (11 loc) · 3.66 KB
/
interactive.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// Inject everpolate: https://raw.githubusercontent.com/BorisChumichev/everpolate/master/everpolate.browserified.min.js
!function (e) { if ("object" == typeof exports && "undefined" != typeof module) module.exports = e(); else if ("function" == typeof define && define.amd) define([], e); else { var r; "undefined" != typeof window ? r = window : "undefined" != typeof global ? r = global : "undefined" != typeof self && (r = self), r.everpolate = e() } }(function () { return function e(r, t, n) { function o(i, u) { if (!t[i]) { if (!r[i]) { var s = "function" == typeof require && require; if (!u && s) return s(i, !0); if (f) return f(i, !0); var a = new Error("Cannot find module '" + i + "'"); throw a.code = "MODULE_NOT_FOUND", a } var l = t[i] = { exports: {} }; r[i][0].call(l.exports, function (e) { var t = r[i][1][e]; return o(t ? t : e) }, l, l.exports, e, r, t, n) } return t[i].exports } for (var f = "function" == typeof require && require, i = 0; i < n.length; i++)o(n[i]); return o }({ 1: [function (e, r) { "use strict"; r.exports.polynomial = e("./polynomial.js"), r.exports.linear = e("./linear.js"), r.exports.linearRegression = e("./linearRegression.js"), r.exports.step = e("./step.js") }, { "./linear.js": 3, "./linearRegression.js": 4, "./polynomial.js": 5, "./step.js": 6 }], 2: [function (e, r) { "use strict"; r.exports.makeItArrayIfItsNot = function (e) { return "[object Array]" !== Object.prototype.toString.call(e) ? [e] : e }, r.exports.findIntervalLeftBorderIndex = function (e, r) { if (e < r[0]) return 0; if (e > r[r.length - 1]) return r.length - 1; for (var t = 0, n = r.length - 1; n - t !== 1;) { var o = t + Math.floor((n - t) / 2); e >= r[o] ? t = o : n = o } return t } }, {}], 3: [function (e, r) { "use strict"; function t(e, r, t) { var f = []; return e = o.makeItArrayIfItsNot(e), e.forEach(function (e) { var i = o.findIntervalLeftBorderIndex(e, r); i == r.length - 1 && i-- , f.push(n(e, r[i], t[i], r[i + 1], t[i + 1])) }), f } function n(e, r, t, n, o) { var f = (o - t) / (n - r), i = -f * r + t; return f * e + i } var o = e("./help"); r.exports = t }, { "./help": 2 }], 4: [function (e, r) { "use strict"; function t(e, r) { for (var t = {}, o = e, f = r, i = f.length, u = 0, s = 0, a = 0, l = 0, p = 0, c = 0; c < f.length; c++)u += o[c], s += f[c], a += o[c] * f[c], l += o[c] * o[c], p += f[c] * f[c]; return t.slope = (i * a - u * s) / (i * l - u * u), t.intercept = (s - t.slope * u) / i, t.rSquared = Math.pow((i * a - u * s) / Math.sqrt((i * l - u * u) * (i * p - s * s)), 2), t.evaluate = function (e) { var r = n.makeItArrayIfItsNot(e), t = [], o = this; return r.forEach(function (e) { t.push(o.slope * e + o.intercept) }), t }, t } r.exports = t; var n = e("./help") }, { "./help": 2 }], 5: [function (e, r) { "use strict"; function t(e, r, t) { var f = []; return e = o.makeItArrayIfItsNot(e), e.forEach(function (e) { f.push(n(e, r, t)) }), f } function n(e, r, t) { for (var n = [t], o = 1; o < r.length; o++) { n.push([]); for (var f = 1; o >= f; f++)n[f][o] = ((e - r[o - f]) * n[f - 1][o] - (e - r[o]) * n[f - 1][o - 1]) / (r[o] - r[o - f]) } return n[f - 1][o - 1] } var o = e("./help"); r.exports = t }, { "./help": 2 }], 6: [function (e, r) { "use strict"; function t(e, r, t) { var o = []; return e = n.makeItArrayIfItsNot(e), e.forEach(function (e) { o.push(t[n.findIntervalLeftBorderIndex(e, r)]) }), o } var n = e("./help"); r.exports = t }, { "./help": 2 }] }, {}, [1])(1) });
var f = cb_obj.value
var times = source.data.times
var y = source.data.y
var all_results = source.data.all_results
var theta_values = source.data.theta_values
for (var i = 0; i < times.length; i++) {
y[i] = everpolate.linear(f, theta_values[i], all_results[i])
}
source.change.emit();