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 */
017package org.apache.commons.math4.legacy.stat.descriptive;
018
019import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
020
021/**
022 * Weighted evaluation for statistics.
023 *
024 * @since 2.1
025 */
026public interface WeightedEvaluation {
027
028    /**
029     * Returns the result of evaluating the statistic over the input array,
030     * using the supplied weights.
031     *
032     * @param values input array
033     * @param weights array of weights
034     * @return the value of the weighted statistic applied to the input array
035     * @throws MathIllegalArgumentException if either array is null, lengths
036     * do not match, weights contain NaN, negative or infinite values, or
037     * weights does not include at least on positive value
038     */
039    double evaluate(double[] values, double[] weights) throws MathIllegalArgumentException;
040
041    /**
042     * Returns the result of evaluating the statistic over the specified entries
043     * in the input array, using corresponding entries in the supplied weights array.
044     *
045     * @param values the input array
046     * @param weights array of weights
047     * @param begin the index of the first element to include
048     * @param length the number of elements to include
049     * @return the value of the weighted statistic applied to the included array entries
050     * @throws MathIllegalArgumentException if either array is null, lengths
051     * do not match, indices are invalid, weights contain NaN, negative or
052     * infinite values, or weights does not include at least on positive value
053     */
054    double evaluate(double[] values, double[] weights, int begin, int length)
055    throws MathIllegalArgumentException;
056}