| 119667 | } |
| 119668 | // License: https://github.com/HarryStevens/d3-regression/blob/master/LICENSE |
| 119669 | function rSquared(data, x, y, uY, predict) { |
| 119670 | let SSE = 0, SST = 0; |
| 119671 | visitPoints(data, x, y, (dx, dy)=>{ |
| 119672 | const sse = dy - predict(dx), sst = dy - uY; |
| 119673 | SSE += sse * sse; |
| 119674 | SST += sst * sst; |
| 119675 | }); |
| 119676 | return 1 - SSE / SST; |
| 119677 | } |
| 119678 | // License: https://github.com/HarryStevens/d3-regression/blob/master/LICENSE |
| 119679 | function linear(data, x1, y) { |
| 119680 | let X = 0, Y = 0, XY = 0, X2 = 0, n = 0; |