Skip to content

Commit cc6f040

Browse files
authored
Added weights to the MovingWindowRegressor
1 parent 4866b52 commit cc6f040

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

app/engine/utils/MovingWindowRegressor.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
'use strict'
2-
/*
3-
Open Rowing Monitor, https://github.com/JaapvanEkris/openrowingmonitor
4-
*/
52
/**
6-
* This implements a Moving Regression Algorithm to obtain a coefficients, first (angular velocity) and
3+
* @copyright [OpenRowingMonitor]{@link https://github.com/JaapvanEkris/openrowingmonitor}
4+
*
5+
* @file This implements a Moving Regression Algorithm to obtain a coefficients, first (angular velocity) and
76
* second derivative (angular acceleration) at the front of the flank
87
*/
98
import { createTSQuadraticSeries } from './TSQuadraticSeries.js'
@@ -22,8 +21,8 @@ export function createMovingRegressor (bandwith) {
2221
* @param {float} the x value of the datapoint
2322
* @param {float} the y value of the datapoint
2423
*/
25-
function push (x, y) {
26-
quadraticTheilSenRegressor.push(x, y)
24+
function push (x, y, w = 1) {
25+
quadraticTheilSenRegressor.push(x, y, w)
2726

2827
// Let's shift the matrix to make room for a new datapoint
2928
if (aMatrix.length >= flankLength) {
@@ -165,6 +164,9 @@ export function createMovingRegressor (bandwith) {
165164
}
166165
}
167166

167+
/**
168+
* Resets the series to its initial state
169+
*/
168170
function reset () {
169171
quadraticTheilSenRegressor.reset()
170172
let i = aMatrix.length
@@ -198,6 +200,10 @@ export function createMovingRegressor (bandwith) {
198200
cMatrix = []
199201
}
200202

203+
/**
204+
* @param {integer} position - position to be retrieved, starting at 0
205+
* @returns {float} X value at that specific postion in the series
206+
*/
201207
function Xget (position = 0) {
202208
if (position < quadraticTheilSenRegressor.length()) {
203209
return quadraticTheilSenRegressor.X.get(position)
@@ -206,6 +212,10 @@ export function createMovingRegressor (bandwith) {
206212
}
207213
}
208214

215+
/**
216+
* @param {integer} position - position to be retrieved, starting at 0
217+
* @returns {float} Y value at that specific postion in the series
218+
*/
209219
function Yget (position = 0) {
210220
if (position < quadraticTheilSenRegressor.length()) {
211221
return quadraticTheilSenRegressor.Y.get(position)

0 commit comments

Comments
 (0)