/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.math.estimation; import java.io.Serializable; /** * This class represents measurements in estimation problems. * *
This abstract class implements all the methods needed to handle * measurements in a general way. It defines neither the {@link * #getTheoreticalValue getTheoreticalValue} nor the {@link * #getPartial getPartial} methods, which should be defined by * sub-classes according to the specific problem.
* *The {@link #getTheoreticalValue getTheoreticalValue} and {@link * #getPartial getPartial} methods must always use the current * estimate of the parameters set by the solver in the problem. These * parameters can be retrieved through the {@link * EstimationProblem#getAllParameters * EstimationProblem.getAllParameters} method if the measurements are * independent of the problem, or directly if they are implemented as * inner classes of the problem.
* *The instances for which the ignored
flag is set
* through the {@link #setIgnored setIgnored} method are ignored by the
* solvers. This can be used to reject wrong measurements at some
* steps of the estimation.
The theoretical value is the value expected for this measurement * if the model and its parameter were all perfectly known.
*The value must be computed using the current estimate of the parameters * set by the solver in the problem.
* * @return theoretical value */ public abstract double getTheoreticalValue(); /** * Get the partial derivative of the {@link #getTheoreticalValue * theoretical value} according to the parameter. *The value must be computed using the current estimate of the parameters * set by the solver in the problem.
* * @param parameter parameter against which the partial derivative * should be computed * @return partial derivative of the {@link #getTheoreticalValue * theoretical value} */ public abstract double getPartial(EstimatedParameter parameter); /** * Set the ignore flag to the specified value * Setting the ignore flag to true allow to reject wrong * measurements, which sometimes can be detected only rather late. * * @param ignored value for the ignore flag */ public void setIgnored(boolean ignored) { this.ignored = ignored; } /** * Check if this measurement should be ignored * * @return true if the measurement should be ignored */ public boolean isIgnored() { return ignored; } }