本文整理汇总了Java中org.apache.commons.math3.exception.util.LocalizedFormats.NOT_POSITIVE_NUMBER_OF_SAMPLES属性的典型用法代码示例。如果您正苦于以下问题:Java LocalizedFormats.NOT_POSITIVE_NUMBER_OF_SAMPLES属性的具体用法?Java LocalizedFormats.NOT_POSITIVE_NUMBER_OF_SAMPLES怎么用?Java LocalizedFormats.NOT_POSITIVE_NUMBER_OF_SAMPLES使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.commons.math3.exception.util.LocalizedFormats
的用法示例。
在下文中一共展示了LocalizedFormats.NOT_POSITIVE_NUMBER_OF_SAMPLES属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sample
/**
* Samples the specified univariate real function on the specified interval.
* <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 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;
}
示例2: KolmogorovSmirnovDistribution
/**
* @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;
}
示例3: sample
/**
* <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;
}