double standardError = unfilteredInRangeVariable.getDoubleValue() - getDoubleValue(); double wrappingError; if(unfilteredInRangeVariable.getDoubleValue() > getDoubleValue()) wrappingError = lowerLimit - getDoubleValue() + unfilteredInRangeVariable.getDoubleValue() - upperLimit; wrappingError = upperLimit - getDoubleValue() + unfilteredInRangeVariable.getDoubleValue() - lowerLimit; temporaryOutputVariable.set(getDoubleValue()); if ((getDoubleValue() + error.getDoubleValue()) >= upperLimit) temporaryOutputVariable.set(getDoubleValue() - range); if ((getDoubleValue() + error.getDoubleValue()) < lowerLimit) temporaryOutputVariable.set(getDoubleValue() + range);
double standardError = unfilteredInRangeVariable.getDoubleValue() - getDoubleValue(); double wrappingError; if(unfilteredInRangeVariable.getDoubleValue() > getDoubleValue()) wrappingError = lowerLimit - getDoubleValue() + unfilteredInRangeVariable.getDoubleValue() - upperLimit; wrappingError = upperLimit - getDoubleValue() + unfilteredInRangeVariable.getDoubleValue() - lowerLimit; temporaryOutputVariable.set(getDoubleValue()); if ((getDoubleValue() + error.getDoubleValue()) >= upperLimit) temporaryOutputVariable.set(getDoubleValue() - range); if ((getDoubleValue() + error.getDoubleValue()) < lowerLimit) temporaryOutputVariable.set(getDoubleValue() + range);
@ContinuousIntegrationTest(estimatedDuration = 0.0) @Test(timeout=60000) public void testNoisyFixedPosition() { // Use a reasonably large alpha for a reasonably large amount of noise YoVariableRegistry registry = new YoVariableRegistry("testRegistry"); YoDouble alpha = new YoDouble("alpha", registry); alpha.set(0.8); YoDouble positionVariable = new YoDouble("positionVariable", registry); AlphaFilteredWrappingYoVariable alphaFilteredWrappingYoVariable = new AlphaFilteredWrappingYoVariable("alphaFilteredWrappingYoVariable", "", registry, positionVariable, alpha, 0.0, 20.0); double pseudoNoise = 0; positionVariable.set(10.0); for (int i = 0; i < 10000; i++) { // Oscillate the position about some uniformly distributed fixed point slightly larger than 10 if (i % 2 == 0) { pseudoNoise = random.nextDouble(); } positionVariable.add(Math.pow(-1, i) * pseudoNoise); alphaFilteredWrappingYoVariable.update(); } assertEquals(10.0, alphaFilteredWrappingYoVariable.getDoubleValue(), 1.0); }
assertTrue(MathTools.epsilonEquals(alphaFilteredWrappingYoVariable.getDoubleValue(), -2.0, 1e-10)); assertTrue(MathTools.epsilonEquals(alphaFilteredWrappingYoVariable.getDoubleValue(), -2.0, 1e-10)); assertTrue(MathTools.epsilonEquals(alphaFilteredWrappingYoVariable.getDoubleValue(), 3.0, 1e-10)); assertTrue(MathTools.epsilonEquals(alphaFilteredWrappingYoVariable.getDoubleValue(), -2.0, 1e-10)); assertTrue(MathTools.epsilonEquals(alphaFilteredWrappingYoVariable.getDoubleValue(), 2.0, 1e-10)); assertTrue(MathTools.epsilonEquals(alphaFilteredWrappingYoVariable.getDoubleValue(), -2.0, 1e-10)); assertTrue(MathTools.epsilonEquals(alphaFilteredWrappingYoVariable.getDoubleValue(), 6.5, 1e-10)); assertTrue(MathTools.epsilonEquals(alphaFilteredWrappingYoVariable.getDoubleValue(), -2.0, 1e-10));
double lastError = getErrorConsideringWrap(alphaFilteredWrappingYoVariable.getDoubleValue(), positionVariable.getDoubleValue(),lowerLimit, upperLimit); for (int convergeAlphaCount = 0; convergeAlphaCount < 100; convergeAlphaCount++) double currentError = getErrorConsideringWrap(alphaFilteredWrappingYoVariable.getDoubleValue(), positionVariable.getDoubleValue(),lowerLimit, upperLimit); assertTrue(Math.abs(currentError) < Math.abs(lastError));