001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     *
009     *      http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    package org.apache.commons.math3.fitting;
018    
019    import java.io.Serializable;
020    
021    /**
022     * This class is a simple container for weighted observed point in
023     * {@link CurveFitter curve fitting}.
024     * <p>Instances of this class are guaranteed to be immutable.</p>
025     * @version $Id: WeightedObservedPoint.java 1416643 2012-12-03 19:37:14Z tn $
026     * @since 2.0
027     */
028    public class WeightedObservedPoint implements Serializable {
029        /** Serializable version id. */
030        private static final long serialVersionUID = 5306874947404636157L;
031        /** Weight of the measurement in the fitting process. */
032        private final double weight;
033        /** Abscissa of the point. */
034        private final double x;
035        /** Observed value of the function at x. */
036        private final double y;
037    
038        /**
039         * Simple constructor.
040         *
041         * @param weight Weight of the measurement in the fitting process.
042         * @param x Abscissa of the measurement.
043         * @param y Ordinate of the measurement.
044         */
045        public WeightedObservedPoint(final double weight, final double x, final double y) {
046            this.weight = weight;
047            this.x      = x;
048            this.y      = y;
049        }
050    
051        /**
052         * Gets the weight of the measurement in the fitting process.
053         *
054         * @return the weight of the measurement in the fitting process.
055         */
056        public double getWeight() {
057            return weight;
058        }
059    
060        /**
061         * Gets the abscissa of the point.
062         *
063         * @return the abscissa of the point.
064         */
065        public double getX() {
066            return x;
067        }
068    
069        /**
070         * Gets the observed value of the function at x.
071         *
072         * @return the observed value of the function at x.
073         */
074        public double getY() {
075            return y;
076        }
077    
078    }
079