Java Code Examples for org.apache.commons.math3.exception.util.LocalizedFormats#NOT_POSITIVE_NUMBER_OF_SAMPLES

The following examples show how to use org.apache.commons.math3.exception.util.LocalizedFormats#NOT_POSITIVE_NUMBER_OF_SAMPLES . 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: FunctionUtils.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Samples the specified univariate real function on the specified interval.
 * <br/>
 * The interval is divided equally into {@code n} sections and sample points
 * are taken from {@code min} to {@code max - (max - min) / n}; therefore
 * {@code f} is not sampled at the upper bound {@code max}.
 *
 * @param f Function to be sampled
 * @param min Lower bound of the interval (included).
 * @param max Upper bound of the interval (excluded).
 * @param n Number of sample points.
 * @return the array of samples.
 * @throws NumberIsTooLargeException if the lower bound {@code min} is
 * greater than, or equal to the upper bound {@code max}.
 * @throws NotStrictlyPositiveException if the number of sample points
 * {@code n} is negative.
 */
public static double[] sample(UnivariateFunction f, double min, double max, int n)
   throws NumberIsTooLargeException, NotStrictlyPositiveException {

    if (n <= 0) {
        throw new NotStrictlyPositiveException(
                LocalizedFormats.NOT_POSITIVE_NUMBER_OF_SAMPLES,
                Integer.valueOf(n));
    }
    if (min >= max) {
        throw new NumberIsTooLargeException(min, max, false);
    }

    final double[] s = new double[n];
    final double h = (max - min) / n;
    for (int i = 0; i < n; i++) {
        s[i] = f.value(min + i * h);
    }
    return s;
}
 
Example 2
Source File: FunctionUtils.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Samples the specified univariate real function on the specified interval.
 * <br/>
 * The interval is divided equally into {@code n} sections and sample points
 * are taken from {@code min} to {@code max - (max - min) / n}; therefore
 * {@code f} is not sampled at the upper bound {@code max}.
 *
 * @param f Function to be sampled
 * @param min Lower bound of the interval (included).
 * @param max Upper bound of the interval (excluded).
 * @param n Number of sample points.
 * @return the array of samples.
 * @throws NumberIsTooLargeException if the lower bound {@code min} is
 * greater than, or equal to the upper bound {@code max}.
 * @throws NotStrictlyPositiveException if the number of sample points
 * {@code n} is negative.
 */
public static double[] sample(UnivariateFunction f, double min, double max, int n)
   throws NumberIsTooLargeException, NotStrictlyPositiveException {

    if (n <= 0) {
        throw new NotStrictlyPositiveException(
                LocalizedFormats.NOT_POSITIVE_NUMBER_OF_SAMPLES,
                Integer.valueOf(n));
    }
    if (min >= max) {
        throw new NumberIsTooLargeException(min, max, false);
    }

    final double[] s = new double[n];
    final double h = (max - min) / n;
    for (int i = 0; i < n; i++) {
        s[i] = f.value(min + i * h);
    }
    return s;
}
 
Example 3
Source File: FunctionUtils.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Samples the specified univariate real function on the specified interval.
 * <br/>
 * The interval is divided equally into {@code n} sections and sample points
 * are taken from {@code min} to {@code max - (max - min) / n}; therefore
 * {@code f} is not sampled at the upper bound {@code max}.
 *
 * @param f Function to be sampled
 * @param min Lower bound of the interval (included).
 * @param max Upper bound of the interval (excluded).
 * @param n Number of sample points.
 * @return the array of samples.
 * @throws NumberIsTooLargeException if the lower bound {@code min} is
 * greater than, or equal to the upper bound {@code max}.
 * @throws NotStrictlyPositiveException if the number of sample points
 * {@code n} is negative.
 */
public static double[] sample(UnivariateFunction f, double min, double max, int n)
   throws NumberIsTooLargeException, NotStrictlyPositiveException {

    if (n <= 0) {
        throw new NotStrictlyPositiveException(
                LocalizedFormats.NOT_POSITIVE_NUMBER_OF_SAMPLES,
                Integer.valueOf(n));
    }
    if (min >= max) {
        throw new NumberIsTooLargeException(min, max, false);
    }

    final double[] s = new double[n];
    final double h = (max - min) / n;
    for (int i = 0; i < n; i++) {
        s[i] = f.value(min + i * h);
    }
    return s;
}
 
Example 4
Source File: FunctionUtils.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Samples the specified univariate real function on the specified interval.
 * <br/>
 * The interval is divided equally into {@code n} sections and sample points
 * are taken from {@code min} to {@code max - (max - min) / n}; therefore
 * {@code f} is not sampled at the upper bound {@code max}.
 *
 * @param f Function to be sampled
 * @param min Lower bound of the interval (included).
 * @param max Upper bound of the interval (excluded).
 * @param n Number of sample points.
 * @return the array of samples.
 * @throws NumberIsTooLargeException if the lower bound {@code min} is
 * greater than, or equal to the upper bound {@code max}.
 * @throws NotStrictlyPositiveException if the number of sample points
 * {@code n} is negative.
 */
public static double[] sample(UnivariateFunction f, double min, double max, int n)
   throws NumberIsTooLargeException, NotStrictlyPositiveException {

    if (n <= 0) {
        throw new NotStrictlyPositiveException(
                LocalizedFormats.NOT_POSITIVE_NUMBER_OF_SAMPLES,
                Integer.valueOf(n));
    }
    if (min >= max) {
        throw new NumberIsTooLargeException(min, max, false);
    }

    final double[] s = new double[n];
    final double h = (max - min) / n;
    for (int i = 0; i < n; i++) {
        s[i] = f.value(min + i * h);
    }
    return s;
}
 
Example 5
Source File: Nopol2017_0064_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * Samples the specified univariate real function on the specified interval.
 * <br/>
 * The interval is divided equally into {@code n} sections and sample points
 * are taken from {@code min} to {@code max - (max - min) / n}; therefore
 * {@code f} is not sampled at the upper bound {@code max}.
 *
 * @param f Function to be sampled
 * @param min Lower bound of the interval (included).
 * @param max Upper bound of the interval (excluded).
 * @param n Number of sample points.
 * @return the array of samples.
 * @throws NumberIsTooLargeException if the lower bound {@code min} is
 * greater than, or equal to the upper bound {@code max}.
 * @throws NotStrictlyPositiveException if the number of sample points
 * {@code n} is negative.
 */
public static double[] sample(UnivariateFunction f,
                              double min, double max, int n) {

    if (n <= 0) {
        throw new NotStrictlyPositiveException(
                LocalizedFormats.NOT_POSITIVE_NUMBER_OF_SAMPLES,
                Integer.valueOf(n));
    }
    if (min >= max) {
        throw new NumberIsTooLargeException(min, max, false);
    }

    final double[] s = new double[n];
    final double h = (max - min) / n;
    for (int i = 0; i < n; i++) {
        s[i] = f.value(min + i * h);
    }
    return s;
}
 
Example 6
Source File: FunctionUtils.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Samples the specified univariate real function on the specified interval.
 * <br/>
 * The interval is divided equally into {@code n} sections and sample points
 * are taken from {@code min} to {@code max - (max - min) / n}; therefore
 * {@code f} is not sampled at the upper bound {@code max}.
 *
 * @param f Function to be sampled
 * @param min Lower bound of the interval (included).
 * @param max Upper bound of the interval (excluded).
 * @param n Number of sample points.
 * @return the array of samples.
 * @throws NumberIsTooLargeException if the lower bound {@code min} is
 * greater than, or equal to the upper bound {@code max}.
 * @throws NotStrictlyPositiveException if the number of sample points
 * {@code n} is negative.
 */
public static double[] sample(UnivariateFunction f,
                              double min, double max, int n) {

    if (n <= 0) {
        throw new NotStrictlyPositiveException(
                LocalizedFormats.NOT_POSITIVE_NUMBER_OF_SAMPLES,
                Integer.valueOf(n));
    }
    if (min >= max) {
        throw new NumberIsTooLargeException(min, max, false);
    }

    final double[] s = new double[n];
    final double h = (max - min) / n;
    for (int i = 0; i < n; i++) {
        s[i] = f.value(min + i * h);
    }
    return s;
}
 
Example 7
Source File: FunctionUtils.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Samples the specified univariate real function on the specified interval.
 * <br/>
 * The interval is divided equally into {@code n} sections and sample points
 * are taken from {@code min} to {@code max - (max - min) / n}; therefore
 * {@code f} is not sampled at the upper bound {@code max}.
 *
 * @param f Function to be sampled
 * @param min Lower bound of the interval (included).
 * @param max Upper bound of the interval (excluded).
 * @param n Number of sample points.
 * @return the array of samples.
 * @throws NumberIsTooLargeException if the lower bound {@code min} is
 * greater than, or equal to the upper bound {@code max}.
 * @throws NotStrictlyPositiveException if the number of sample points
 * {@code n} is negative.
 */
public static double[] sample(UnivariateFunction f, double min, double max, int n)
   throws NumberIsTooLargeException, NotStrictlyPositiveException {

    if (n <= 0) {
        throw new NotStrictlyPositiveException(
                LocalizedFormats.NOT_POSITIVE_NUMBER_OF_SAMPLES,
                Integer.valueOf(n));
    }
    if (min >= max) {
        throw new NumberIsTooLargeException(min, max, false);
    }

    final double[] s = new double[n];
    final double h = (max - min) / n;
    for (int i = 0; i < n; i++) {
        s[i] = f.value(min + i * h);
    }
    return s;
}
 
Example 8
Source File: Nopol2017_0064_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Samples the specified univariate real function on the specified interval.
 * <br/>
 * The interval is divided equally into {@code n} sections and sample points
 * are taken from {@code min} to {@code max - (max - min) / n}; therefore
 * {@code f} is not sampled at the upper bound {@code max}.
 *
 * @param f Function to be sampled
 * @param min Lower bound of the interval (included).
 * @param max Upper bound of the interval (excluded).
 * @param n Number of sample points.
 * @return the array of samples.
 * @throws NumberIsTooLargeException if the lower bound {@code min} is
 * greater than, or equal to the upper bound {@code max}.
 * @throws NotStrictlyPositiveException if the number of sample points
 * {@code n} is negative.
 */
public static double[] sample(UnivariateFunction f,
                              double min, double max, int n) {

    if (n <= 0) {
        throw new NotStrictlyPositiveException(
                LocalizedFormats.NOT_POSITIVE_NUMBER_OF_SAMPLES,
                Integer.valueOf(n));
    }
    if (min >= max) {
        throw new NumberIsTooLargeException(min, max, false);
    }

    final double[] s = new double[n];
    final double h = (max - min) / n;
    for (int i = 0; i < n; i++) {
        s[i] = f.value(min + i * h);
    }
    return s;
}
 
Example 9
Source File: KolmogorovSmirnovDistribution.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param n Number of observations
 * @throws NotStrictlyPositiveException if {@code n <= 0}
 */
public KolmogorovSmirnovDistribution(int n)
    throws NotStrictlyPositiveException {
    if (n <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.NOT_POSITIVE_NUMBER_OF_SAMPLES, n);
    }

    this.n = n;
}
 
Example 10
Source File: KolmogorovSmirnovDistribution.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param n Number of observations
 * @throws NotStrictlyPositiveException if {@code n <= 0}
 */
public KolmogorovSmirnovDistribution(int n)
    throws NotStrictlyPositiveException {
    if (n <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.NOT_POSITIVE_NUMBER_OF_SAMPLES, n);
    }

    this.n = n;
}
 
Example 11
Source File: KolmogorovSmirnovDistribution.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param n Number of observations
 * @throws NotStrictlyPositiveException if {@code n <= 0}
 */
public KolmogorovSmirnovDistribution(int n)
    throws NotStrictlyPositiveException {
    if (n <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.NOT_POSITIVE_NUMBER_OF_SAMPLES, n);
    }

    this.n = n;
}
 
Example 12
Source File: KolmogorovSmirnovDistribution.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param n Number of observations
 * @throws NotStrictlyPositiveException if {@code n <= 0}
 */
public KolmogorovSmirnovDistribution(int n)
    throws NotStrictlyPositiveException {
    if (n <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.NOT_POSITIVE_NUMBER_OF_SAMPLES, n);
    }

    this.n = n;
}
 
Example 13
Source File: KolmogorovSmirnovDistribution.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param n Number of observations
 * @throws NotStrictlyPositiveException if {@code n <= 0}
 */
public KolmogorovSmirnovDistribution(int n)
    throws NotStrictlyPositiveException {
    if (n <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.NOT_POSITIVE_NUMBER_OF_SAMPLES, n);
    }

    this.n = n;
}
 
Example 14
Source File: KolmogorovSmirnovDistribution.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param n Number of observations
 * @throws NotStrictlyPositiveException if {@code n <= 0}
 */
public KolmogorovSmirnovDistribution(int n)
    throws NotStrictlyPositiveException {
    if (n <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.NOT_POSITIVE_NUMBER_OF_SAMPLES, n);
    }

    this.n = n;
}
 
Example 15
Source File: KolmogorovSmirnovDistribution.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param n Number of observations
 * @throws NotStrictlyPositiveException if {@code n <= 0}
 */
public KolmogorovSmirnovDistribution(int n)
    throws NotStrictlyPositiveException {
    if (n <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.NOT_POSITIVE_NUMBER_OF_SAMPLES, n);
    }

    this.n = n;
}
 
Example 16
Source File: KolmogorovSmirnovDistribution.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param n Number of observations
 * @throws NotStrictlyPositiveException if {@code n <= 0}
 */
public KolmogorovSmirnovDistribution(int n)
    throws NotStrictlyPositiveException {
    if (n <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.NOT_POSITIVE_NUMBER_OF_SAMPLES, n);
    }

    this.n = n;
}
 
Example 17
Source File: FunctionUtils.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * <p>
 * Samples the specified univariate real function on the specified interval.
 * </p>
 * <p>
 * The interval is divided equally into {@code n} sections and sample points
 * are taken from {@code min} to {@code max - (max - min) / n}; therefore
 * {@code f} is not sampled at the upper bound {@code max}.
 * </p>
 *
 * @param f the function to be sampled
 * @param min the (inclusive) lower bound of the interval
 * @param max the (exclusive) upper bound of the interval
 * @param n the number of sample points
 * @return the array of samples
 * @throws NumberIsTooLargeException if the lower bound {@code min} is
 * greater than, or equal to the upper bound {@code max}
 * @throws NotStrictlyPositiveException if the number of sample points
 * {@code n} is negative
 */
public static double[] sample(UnivariateFunction f,
                              double min, double max, int n) {

    if (n <= 0) {
        throw new NotStrictlyPositiveException(
                LocalizedFormats.NOT_POSITIVE_NUMBER_OF_SAMPLES,
                Integer.valueOf(n));
    }
    if (min >= max) {
        throw new NumberIsTooLargeException(min, max, false);
    }

    final double[] s = new double[n];
    final double h = (max - min) / n;
    for (int i = 0; i < n; i++) {
        s[i] = f.value(min + i * h);
    }
    return s;
}
 
Example 18
Source File: FunctionUtils.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * <p>
 * Samples the specified univariate real function on the specified interval.
 * </p>
 * <p>
 * The interval is divided equally into {@code n} sections and sample points
 * are taken from {@code min} to {@code max - (max - min) / n}; therefore
 * {@code f} is not sampled at the upper bound {@code max}.
 * </p>
 *
 * @param f the function to be sampled
 * @param min the (inclusive) lower bound of the interval
 * @param max the (exclusive) upper bound of the interval
 * @param n the number of sample points
 * @return the array of samples
 * @throws NumberIsTooLargeException if the lower bound {@code min} is
 * greater than, or equal to the upper bound {@code max}
 * @throws NotStrictlyPositiveException if the number of sample points
 * {@code n} is negative
 */
public static double[] sample(UnivariateFunction f,
        double min, double max, int n) {

    if (n <= 0) {
        throw new NotStrictlyPositiveException(
                LocalizedFormats.NOT_POSITIVE_NUMBER_OF_SAMPLES,
                Integer.valueOf(n));
    }
    if (min >= max) {
        throw new NumberIsTooLargeException(min, max, false);
    }

    double[] s = new double[n];
    double h = (max - min) / n;
    for (int i = 0; i < n; i++) {
        s[i] = f.value(min + i * h);
    }
    return s;
}