public void enableInputCentering(final int i) { final SignalSmoother avgInput = new SignalSmoother(1.0 - this.inertia); if (this.inertia == 1.0) { avgInput.freeze(); } this.avgInputs.set(i, avgInput); }
private Vector input(final Vector x, final boolean update) { final Vector result = x.copy(); for (int i = 0; i < this.avgInputs.size(); i++) { final SignalSmoother avgInput = this.avgInputs.get(i); if (avgInput != null) { if (update) { final double oldAvgInput = avgInput.getSmoothedValue(); avgInput.addValue(x.get(i)); this.offset += this.coefficients.get(i) * (avgInput.getSmoothedValue() - oldAvgInput); } result.add(i, -avgInput.getSmoothedValue()); } } return result; }
/** * Sets the inertia of this regression to the given value. * * @param inertia the new intertia; must be in (0, 1] */ public void setInertia(final double inertia) { if (inertia <= 0 || inertia > 1) { throw new IllegalArgumentException("lambda must be in (0,1]"); } this.inertia = inertia; for (int i = 0; i < this.avgInputs.size(); i++) { final SignalSmoother avgInput = this.avgInputs.get(i); if (avgInput != null) { if (inertia < 1.0) { avgInput.setInnovationWeight(1.0 - inertia); } else { avgInput.freeze(); } } } }