Java Code Examples for org.apache.commons.math.exception.util.LocalizedFormats#INPUT_ARRAY

The following examples show how to use org.apache.commons.math.exception.util.LocalizedFormats#INPUT_ARRAY . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Math_58_GaussianFitter_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Constructs instance with the specified observed points.
 *
 * @param observations observed points upon which should base guess
 */
public ParameterGuesser(WeightedObservedPoint[] observations) {
    if (observations == null) {
        throw new NullArgumentException(LocalizedFormats.INPUT_ARRAY);
    }
    if (observations.length < 3) {
        throw new NumberIsTooSmallException(observations.length, 3, true);
    }
    this.observations = observations.clone();
}
 
Example 2
Source File: GaussianParametersGuesser.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs instance with the specified observed points.
 *
 * @param observations observed points upon which should base guess
 */
public GaussianParametersGuesser(WeightedObservedPoint[] observations) {
    if (observations == null) {
        throw new NullArgumentException(LocalizedFormats.INPUT_ARRAY);
    }
    if (observations.length < 3) {
        throw new NumberIsTooSmallException(observations.length, 3, true);
    }
    this.observations = observations.clone();
}
 
Example 3
Source File: Arja_0037_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Constructs instance with the specified observed points.
 *
 * @param observations observed points upon which should base guess
 */
public ParameterGuesser(WeightedObservedPoint[] observations) {
    if (observations == null) {
        throw new NullArgumentException(LocalizedFormats.INPUT_ARRAY);
    }
    if (observations.length < 3) {
        throw new NumberIsTooSmallException(observations.length, 3, true);
    }
    this.observations = observations.clone();
}
 
Example 4
Source File: Arja_0037_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Constructs instance with the specified observed points.
 *
 * @param observations observed points upon which should base guess
 */
public ParameterGuesser(WeightedObservedPoint[] observations) {
    if (observations == null) {
        throw new NullArgumentException(LocalizedFormats.INPUT_ARRAY);
    }
    if (observations.length < 3) {
        throw new NumberIsTooSmallException(observations.length, 3, true);
    }
    this.observations = observations.clone();
}
 
Example 5
Source File: AbstractUnivariateStatistic.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This method is used by <code>evaluate(double[], double[], int, int)</code> methods
 * to verify that the begin and length parameters designate a subarray of positive length
 * and the weights are all non-negative, non-NaN, finite, and not all zero.
 * <p>
 * <ul>
 * <li>returns <code>true</code> iff the parameters designate a subarray of
 * non-negative length and the weights array contains legitimate values.</li>
 * <li>throws <code>IllegalArgumentException</code> if any of the following are true:
 * <ul><li>the values array is null</li>
 *     <li>the weights array is null</li>
 *     <li>the weights array does not have the same length as the values array</li>
 *     <li>the weights array contains one or more infinite values</li>
 *     <li>the weights array contains one or more NaN values</li>
 *     <li>the weights array contains negative values</li>
 *     <li>the start and length arguments do not determine a valid array</li></ul>
 * </li>
 * <li>returns <code>false</li> if the array is non-null, but
 * <code>length</code> is 0 unless <code>allowEmpty</code> is <code>true</code>.
 * </ul></p>
 *
 * @param values the input array.
 * @param weights the weights array.
 * @param begin index of the first array element to include.
 * @param length the number of elements to include.
 * @param allowEmpty if {@code true} than allow zero length arrays to pass.
 * @return {@code true} if the parameters are valid.
 * @throws IllegalArgumentException if the indices are invalid or the array
 * is {@code null}.
 * @since 3.0
 */
protected boolean test(final double[] values, final double[] weights, final int begin, final int length, final boolean allowEmpty){

    if (weights == null) {
        throw new NullArgumentException(LocalizedFormats.INPUT_ARRAY);
    }

    if (weights.length != values.length) {
        throw new DimensionMismatchException(weights.length, values.length);
    }

    boolean containsPositiveWeight = false;
    for (int i = begin; i < begin + length; i++) {
        if (Double.isNaN(weights[i])) {
            throw new MathIllegalArgumentException(LocalizedFormats.NAN_ELEMENT_AT_INDEX, i);
        }
        if (Double.isInfinite(weights[i])) {
            throw new MathIllegalArgumentException(LocalizedFormats.INFINITE_ARRAY_ELEMENT, weights[i], i);
        }
        if (weights[i] < 0) {
            throw new MathIllegalArgumentException(LocalizedFormats.NEGATIVE_ELEMENT_AT_INDEX, i, weights[i]);
        }
        if (!containsPositiveWeight && weights[i] > 0.0) {
            containsPositiveWeight = true;
        }
    }

    if (!containsPositiveWeight) {
        throw new MathIllegalArgumentException(LocalizedFormats.WEIGHT_AT_LEAST_ONE_NON_ZERO);
    }

    return test(values, begin, length, allowEmpty);
}
 
Example 6
Source File: GaussianFitter.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs instance with the specified observed points.
 *
 * @param observations observed points upon which should base guess
 */
public ParameterGuesser(WeightedObservedPoint[] observations) {
    if (observations == null) {
        throw new NullArgumentException(LocalizedFormats.INPUT_ARRAY);
    }
    if (observations.length < 3) {
        throw new NumberIsTooSmallException(observations.length, 3, true);
    }
    this.observations = observations.clone();
}
 
Example 7
Source File: AbstractUnivariateStatistic.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This method is used by <code>evaluate(double[], double[], int, int)</code> methods
 * to verify that the begin and length parameters designate a subarray of positive length
 * and the weights are all non-negative, non-NaN, finite, and not all zero.
 * <p>
 * <ul>
 * <li>returns <code>true</code> iff the parameters designate a subarray of
 * non-negative length and the weights array contains legitimate values.</li>
 * <li>throws <code>IllegalArgumentException</code> if any of the following are true:
 * <ul><li>the values array is null</li>
 *     <li>the weights array is null</li>
 *     <li>the weights array does not have the same length as the values array</li>
 *     <li>the weights array contains one or more infinite values</li>
 *     <li>the weights array contains one or more NaN values</li>
 *     <li>the weights array contains negative values</li>
 *     <li>the start and length arguments do not determine a valid array</li></ul>
 * </li>
 * <li>returns <code>false</li> if the array is non-null, but
 * <code>length</code> is 0 unless <code>allowEmpty</code> is <code>true</code>.
 * </ul></p>
 *
 * @param values the input array.
 * @param weights the weights array.
 * @param begin index of the first array element to include.
 * @param length the number of elements to include.
 * @param allowEmpty if {@code true} than allow zero length arrays to pass.
 * @return {@code true} if the parameters are valid.
 * @throws IllegalArgumentException if the indices are invalid or the array
 * is {@code null}.
 * @since 3.0
 */
protected boolean test(final double[] values, final double[] weights, final int begin, final int length, final boolean allowEmpty){

    if (weights == null) {
        throw new NullArgumentException(LocalizedFormats.INPUT_ARRAY);
    }

    if (weights.length != values.length) {
        throw new DimensionMismatchException(weights.length, values.length);
    }

    boolean containsPositiveWeight = false;
    for (int i = begin; i < begin + length; i++) {
        if (Double.isNaN(weights[i])) {
            throw new MathIllegalArgumentException(LocalizedFormats.NAN_ELEMENT_AT_INDEX, i);
        }
        if (Double.isInfinite(weights[i])) {
            throw new MathIllegalArgumentException(LocalizedFormats.INFINITE_ARRAY_ELEMENT, weights[i], i);
        }
        if (weights[i] < 0) {
            throw new MathIllegalArgumentException(LocalizedFormats.NEGATIVE_ELEMENT_AT_INDEX, i, weights[i]);
        }
        if (!containsPositiveWeight && weights[i] > 0.0) {
            containsPositiveWeight = true;
        }
    }

    if (!containsPositiveWeight) {
        throw new MathIllegalArgumentException(LocalizedFormats.WEIGHT_AT_LEAST_ONE_NON_ZERO);
    }

    return test(values, begin, length, allowEmpty);
}
 
Example 8
Source File: GaussianFitter.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs instance with the specified observed points.
 *
 * @param observations observed points upon which should base guess
 */
public ParameterGuesser(WeightedObservedPoint[] observations) {
    if (observations == null) {
        throw new NullArgumentException(LocalizedFormats.INPUT_ARRAY);
    }
    if (observations.length < 3) {
        throw new NumberIsTooSmallException(observations.length, 3, true);
    }
    this.observations = observations.clone();
}
 
Example 9
Source File: Elixir_0029_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Constructs instance with the specified observed points.
 *
 * @param observations observed points upon which should base guess
 */
public ParameterGuesser(WeightedObservedPoint[] observations) {
    if (observations == null) {
        throw new NullArgumentException(LocalizedFormats.INPUT_ARRAY);
    }
    if (observations.length < 3) {
        throw new NumberIsTooSmallException(observations.length, 3, true);
    }
    this.observations = observations.clone();
}
 
Example 10
Source File: AbstractUnivariateStatistic.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This method is used by <code>evaluate(double[], int, int)</code> methods
 * to verify that the input parameters designate a subarray of positive length.
 * <p>
 * <ul>
 * <li>returns <code>true</code> iff the parameters designate a subarray of
 * non-negative length</li>
 * <li>throws <code>IllegalArgumentException</code> if the array is null or
 * or the indices are invalid</li>
 * <li>returns <code>false</li> if the array is non-null, but
 * <code>length</code> is 0 unless <code>allowEmpty</code> is <code>true</code>
 * </ul></p>
 *
 * @param values the input array
 * @param begin index of the first array element to include
 * @param length the number of elements to include
 * @param allowEmpty if <code>true</code> then zero length arrays are allowed
 * @return true if the parameters are valid
 * @throws IllegalArgumentException if the indices are invalid or the array is null
 * @since 3.0
 */
protected boolean test(final double[] values, final int begin, final int length, final boolean allowEmpty){

    if (values == null) {
        throw new NullArgumentException(LocalizedFormats.INPUT_ARRAY);
    }

    if (begin < 0) {
        throw new NotPositiveException(LocalizedFormats.START_POSITION, begin);
    }

    if (length < 0) {
        throw new NotPositiveException(LocalizedFormats.LENGTH, length);
    }

    if (begin + length > values.length) {
        throw new NumberIsTooLargeException(LocalizedFormats.SUBARRAY_ENDS_AFTER_ARRAY_END,
                                            begin + length, values.length, true);
    }

    if (length == 0 && !allowEmpty) {
        return false;
    }

    return true;

}
 
Example 11
Source File: AbstractStorelessUnivariateStatistic.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * This default implementation just calls {@link #increment} in a loop over
 * the input array.
 * <p>
 * Throws IllegalArgumentException if the input values array is null.</p>
 *
 * @param values values to add
 * @throws IllegalArgumentException if values is null
 * @see org.apache.commons.math.stat.descriptive.StorelessUnivariateStatistic#incrementAll(double[])
 */
public void incrementAll(double[] values) {
    if (values == null) {
        throw new NullArgumentException(LocalizedFormats.INPUT_ARRAY);
    }
    incrementAll(values, 0, values.length);
}
 
Example 12
Source File: Cardumen_00112_t.java    From coming with MIT License 3 votes vote down vote up
/**
 * Returns the variance of the entries in the input array, or
 * <code>Double.NaN</code> if the array is empty.
 * <p>
 * See {@link Variance} for details on the computing algorithm.</p>
 * <p>
 * Returns 0 for a single-value (i.e. length = 1) sample.</p>
 * <p>
 * Throws <code>IllegalArgumentException</code> if the array is null.</p>
 * <p>
 * Does not change the internal state of the statistic.</p>
 *
 * @param values the input array
 * @return the variance of the values or Double.NaN if length = 0
 * @throws IllegalArgumentException if the array is null
 */
@Override
public double evaluate(final double[] values) {
    if (values == null) {
        throw new NullArgumentException(LocalizedFormats.INPUT_ARRAY);
    }
    return evaluate(values, 0, values.length);
}
 
Example 13
Source File: ParametricGaussianFunction.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Validates parameters to ensure they are appropriate for the evaluation of
 * the <code>value</code> and <code>gradient</code> methods.
 *
 * @param parameters values of <tt>a</tt>, <tt>b</tt>, <tt>c</tt>, and
 *        <tt>d</tt>
 *
 * @throws IllegalArgumentException if <code>parameters</code> is
 *         <code>null</code> or if <code>parameters</code> does not have
 *         length == 4
 * @throws FunctionEvaluationException if <code>parameters[3]</code>
 *         (<tt>d</tt>) is 0
 */
private void validateParameters(double[] parameters) throws FunctionEvaluationException {
    if (parameters == null) {
        throw new NullArgumentException(LocalizedFormats.INPUT_ARRAY);
    }
    if (parameters.length != 4) {
        throw new DimensionMismatchException(4, parameters.length);
    }
    if (parameters[3] == 0.0) {
        throw new ZeroException();
    }
}
 
Example 14
Source File: AbstractStorelessUnivariateStatistic.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * This default implementation calls {@link #clear}, then invokes
 * {@link #increment} in a loop over the the input array, and then uses
 * {@link #getResult} to compute the return value.
 * <p>
 * Note that this implementation changes the internal state of the
 * statistic.  Its side effects are the same as invoking {@link #clear} and
 * then {@link #incrementAll(double[])}.</p>
 * <p>
 * Implementations may override this method with a more efficient and
 * possibly more accurate implementation that works directly with the
 * input array.</p>
 * <p>
 * If the array is null, an IllegalArgumentException is thrown.</p>
 * @param values input array
 * @return the value of the statistic applied to the input array
 * @see org.apache.commons.math.stat.descriptive.UnivariateStatistic#evaluate(double[])
 */
@Override
public double evaluate(final double[] values) {
    if (values == null) {
        throw new NullArgumentException(LocalizedFormats.INPUT_ARRAY);
    }
    return evaluate(values, 0, values.length);
}
 
Example 15
Source File: SemiVariance.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * This method calculates {@link SemiVariance} for the entire array against the mean, using
 * instance properties varianceDirection and biasCorrection.
 *
 * @param values the input array
 * @return the SemiVariance
 * @throws IllegalArgumentException if values is null
 *
 */
@Override
public double evaluate(final double[] values) {
    if (values == null) {
        throw new NullArgumentException(LocalizedFormats.INPUT_ARRAY);
     }
    return evaluate(values, 0, values.length);
}
 
Example 16
Source File: Cardumen_0043_t.java    From coming with MIT License 3 votes vote down vote up
/**
 * Returns the variance of the entries in the input array, or
 * <code>Double.NaN</code> if the array is empty.
 * <p>
 * See {@link Variance} for details on the computing algorithm.</p>
 * <p>
 * Returns 0 for a single-value (i.e. length = 1) sample.</p>
 * <p>
 * Throws <code>IllegalArgumentException</code> if the array is null.</p>
 * <p>
 * Does not change the internal state of the statistic.</p>
 *
 * @param values the input array
 * @return the variance of the values or Double.NaN if length = 0
 * @throws IllegalArgumentException if the array is null
 */
@Override
public double evaluate(final double[] values) {
    if (values == null) {
        throw new NullArgumentException(LocalizedFormats.INPUT_ARRAY);
    }
    return evaluate(values, 0, values.length);
}
 
Example 17
Source File: AbstractStorelessUnivariateStatistic.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * This default implementation just calls {@link #increment} in a loop over
 * the input array.
 * <p>
 * Throws IllegalArgumentException if the input values array is null.</p>
 *
 * @param values values to add
 * @throws IllegalArgumentException if values is null
 * @see org.apache.commons.math.stat.descriptive.StorelessUnivariateStatistic#incrementAll(double[])
 */
public void incrementAll(double[] values) {
    if (values == null) {
        throw new NullArgumentException(LocalizedFormats.INPUT_ARRAY);
    }
    incrementAll(values, 0, values.length);
}
 
Example 18
Source File: Cardumen_00217_s.java    From coming with MIT License 3 votes vote down vote up
/**
 * Returns the variance of the entries in the input array, or
 * <code>Double.NaN</code> if the array is empty.
 * <p>
 * See {@link Variance} for details on the computing algorithm.</p>
 * <p>
 * Returns 0 for a single-value (i.e. length = 1) sample.</p>
 * <p>
 * Throws <code>IllegalArgumentException</code> if the array is null.</p>
 * <p>
 * Does not change the internal state of the statistic.</p>
 *
 * @param values the input array
 * @return the variance of the values or Double.NaN if length = 0
 * @throws IllegalArgumentException if the array is null
 */
@Override
public double evaluate(final double[] values) {
    if (values == null) {
        throw new NullArgumentException(LocalizedFormats.INPUT_ARRAY);
    }
    return evaluate(values, 0, values.length);
}
 
Example 19
Source File: 1_Variance.java    From SimFix with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns the variance of the entries in the input array, or
 * <code>Double.NaN</code> if the array is empty.
 * <p>
 * See {@link Variance} for details on the computing algorithm.</p>
 * <p>
 * Returns 0 for a single-value (i.e. length = 1) sample.</p>
 * <p>
 * Throws <code>IllegalArgumentException</code> if the array is null.</p>
 * <p>
 * Does not change the internal state of the statistic.</p>
 *
 * @param values the input array
 * @return the variance of the values or Double.NaN if length = 0
 * @throws IllegalArgumentException if the array is null
 */
@Override
public double evaluate(final double[] values) {
    if (values == null) {
        throw new NullArgumentException(LocalizedFormats.INPUT_ARRAY);
    }
    return evaluate(values, 0, values.length);
}
 
Example 20
Source File: 1_Variance.java    From SimFix with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns the variance of the entries in the input array, or
 * <code>Double.NaN</code> if the array is empty.
 * <p>
 * See {@link Variance} for details on the computing algorithm.</p>
 * <p>
 * Returns 0 for a single-value (i.e. length = 1) sample.</p>
 * <p>
 * Throws <code>IllegalArgumentException</code> if the array is null.</p>
 * <p>
 * Does not change the internal state of the statistic.</p>
 *
 * @param values the input array
 * @return the variance of the values or Double.NaN if length = 0
 * @throws IllegalArgumentException if the array is null
 */
@Override
public double evaluate(final double[] values) {
    if (values == null) {
        throw new NullArgumentException(LocalizedFormats.INPUT_ARRAY);
    }
    return evaluate(values, 0, values.length);
}