Skip to content
Arthur Guiot edited this page May 18, 2018 · 1 revision

Get the average of a list of numbers like that:

t.average(10, 20, 15) // 15 => BigNumber

If you have an array, use the ... operator

t.average(...[10, 20, 15]) // 15 => BigNumber

Get the median of a list of numbers like that:

t.median(53, 64, 22, 32) // 42.5 => BigNumber

If you have an array, use the ... operator

t.median(...[53, 64, 22, 32]) // 42.5 => BigNumber

Uses the same algorithm as Excel

Get the correlation of two Arrays like that:

t.correlation([3, 2, 4, 5, 6], [9, 7, 12, 15, 17]) // ≈ 0.997054486 => BigNumber

TheoremJS supports regression up to infinity degree (in theory), but you can be certain that regressions up to the 50th degree should be fine.

You need to input a set point that follows TheoremJS notation, and the highest degree you want.

t.regression({
    0: 2,
    1: 5,
    3: 11
}, 1) // f(x) = 3x + 2 => Polynomial

t.regression({
    0: 1,
    1: 3,
    2: 9
}, 2) // f(x) = 2x^2 + 1 => Polynomial

This is how it looks:

Regression with TheoremJS and DescartesJS

Clone this wiki locally