本文整理汇总了Java中org.apache.commons.math3.exception.NumberIsTooSmallException类的典型用法代码示例。如果您正苦于以下问题:Java NumberIsTooSmallException类的具体用法?Java NumberIsTooSmallException怎么用?Java NumberIsTooSmallException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NumberIsTooSmallException类属于org.apache.commons.math3.exception包,在下文中一共展示了NumberIsTooSmallException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ParameterGuesser
import org.apache.commons.math3.exception.NumberIsTooSmallException; //导入依赖的package包/类
/**
* Constructs instance with the specified observed points.
*
* @param observations Observed points from which to guess the
* parameters of the Gaussian.
* @throws NullArgumentException if {@code observations} is
* {@code null}.
* @throws NumberIsTooSmallException if there are less than 3
* observations.
*/
public ParameterGuesser(Collection<WeightedObservedPoint> observations) {
if (observations == null) {
throw new NullArgumentException(LocalizedFormats.INPUT_ARRAY);
}
if (observations.size() < 3) {
throw new NumberIsTooSmallException(observations.size(), 3, true);
}
final List<WeightedObservedPoint> sorted = sortObservations(observations);
final double[] params = basicGuess(sorted.toArray(new WeightedObservedPoint[0]));
norm = params[0];
mean = params[1];
sigma = params[2];
}
示例2: logDensity
import org.apache.commons.math3.exception.NumberIsTooSmallException; //导入依赖的package包/类
/** {@inheritDoc} **/
@Override
public double logDensity(double x) {
recomputeZ();
if (x < 0 || x > 1) {
return Double.NEGATIVE_INFINITY;
} else if (x == 0) {
if (alpha < 1) {
throw new NumberIsTooSmallException(LocalizedFormats.CANNOT_COMPUTE_BETA_DENSITY_AT_0_FOR_SOME_ALPHA, alpha, 1, false);
}
return Double.NEGATIVE_INFINITY;
} else if (x == 1) {
if (beta < 1) {
throw new NumberIsTooSmallException(LocalizedFormats.CANNOT_COMPUTE_BETA_DENSITY_AT_1_FOR_SOME_BETA, beta, 1, false);
}
return Double.NEGATIVE_INFINITY;
} else {
double logX = FastMath.log(x);
double log1mX = FastMath.log1p(-x);
return (alpha - 1) * logX + (beta - 1) * log1mX - z;
}
}
示例3: checkSubMatrixIndex
import org.apache.commons.math3.exception.NumberIsTooSmallException; //导入依赖的package包/类
/**
* Check if submatrix ranges indices are valid.
* Rows and columns are indicated counting from 0 to {@code n - 1}.
*
* @param m Matrix.
* @param startRow Initial row index.
* @param endRow Final row index.
* @param startColumn Initial column index.
* @param endColumn Final column index.
* @throws OutOfRangeException if the indices are invalid.
* @throws NumberIsTooSmallException if {@code endRow < startRow} or
* {@code endColumn < startColumn}.
*/
public static void checkSubMatrixIndex(final AnyMatrix m,
final int startRow, final int endRow,
final int startColumn, final int endColumn)
throws NumberIsTooSmallException, OutOfRangeException {
checkRowIndex(m, startRow);
checkRowIndex(m, endRow);
if (endRow < startRow) {
throw new NumberIsTooSmallException(LocalizedFormats.INITIAL_ROW_AFTER_FINAL_ROW,
endRow, startRow, false);
}
checkColumnIndex(m, startColumn);
checkColumnIndex(m, endColumn);
if (endColumn < startColumn) {
throw new NumberIsTooSmallException(LocalizedFormats.INITIAL_COLUMN_AFTER_FINAL_COLUMN,
endColumn, startColumn, false);
}
}
示例4: sanityChecks
import org.apache.commons.math3.exception.NumberIsTooSmallException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected void sanityChecks(final FieldODEState<T> eqn, final T t)
throws DimensionMismatchException, NumberIsTooSmallException {
super.sanityChecks(eqn, t);
mainSetDimension = eqn.getStateDimension();
if (vecAbsoluteTolerance != null && vecAbsoluteTolerance.length != mainSetDimension) {
throw new DimensionMismatchException(mainSetDimension, vecAbsoluteTolerance.length);
}
if (vecRelativeTolerance != null && vecRelativeTolerance.length != mainSetDimension) {
throw new DimensionMismatchException(mainSetDimension, vecRelativeTolerance.length);
}
}
示例5: filterStep
import org.apache.commons.math3.exception.NumberIsTooSmallException; //导入依赖的package包/类
/** Filter the integration step.
* @param h signed step
* @param forward forward integration indicator
* @param acceptSmall if true, steps smaller than the minimal value
* are silently increased up to this value, if false such small
* steps generate an exception
* @return a bounded integration step (h if no bound is reach, or a bounded value)
* @exception NumberIsTooSmallException if the step is too small and acceptSmall is false
*/
protected T filterStep(final T h, final boolean forward, final boolean acceptSmall)
throws NumberIsTooSmallException {
T filteredH = h;
if (h.abs().subtract(minStep).getReal() < 0) {
if (acceptSmall) {
filteredH = forward ? minStep : minStep.negate();
} else {
throw new NumberIsTooSmallException(LocalizedFormats.MINIMAL_STEPSIZE_REACHED_DURING_INTEGRATION,
h.abs().getReal(), minStep.getReal(), true);
}
}
if (filteredH.subtract(maxStep).getReal() > 0) {
filteredH = maxStep;
} else if (filteredH.add(maxStep).getReal() < 0) {
filteredH = maxStep.negate();
}
return filteredH;
}
示例6: filterStep
import org.apache.commons.math3.exception.NumberIsTooSmallException; //导入依赖的package包/类
/** Filter the integration step.
* @param h signed step
* @param forward forward integration indicator
* @param acceptSmall if true, steps smaller than the minimal value
* are silently increased up to this value, if false such small
* steps generate an exception
* @return a bounded integration step (h if no bound is reach, or a bounded value)
* @exception NumberIsTooSmallException if the step is too small and acceptSmall is false
*/
protected double filterStep(final double h, final boolean forward, final boolean acceptSmall)
throws NumberIsTooSmallException {
double filteredH = h;
if (FastMath.abs(h) < minStep) {
if (acceptSmall) {
filteredH = forward ? minStep : -minStep;
} else {
throw new NumberIsTooSmallException(LocalizedFormats.MINIMAL_STEPSIZE_REACHED_DURING_INTEGRATION,
FastMath.abs(h), minStep, true);
}
}
if (filteredH > maxStep) {
filteredH = maxStep;
} else if (filteredH < -maxStep) {
filteredH = -maxStep;
}
return filteredH;
}
示例7: checkSubMatrixIndex
import org.apache.commons.math3.exception.NumberIsTooSmallException; //导入依赖的package包/类
/**
* Check if submatrix ranges indices are valid.
* Rows and columns are indicated counting from 0 to n-1.
*
* @param startRow Initial row index.
* @param endRow Final row index.
* @param startColumn Initial column index.
* @param endColumn Final column index.
* @throws OutOfRangeException if the indices are not valid.
* @throws NumberIsTooSmallException if {@code endRow < startRow} or
* {@code endColumn < startColumn}.
*/
protected void checkSubMatrixIndex(final int startRow, final int endRow,
final int startColumn, final int endColumn) {
checkRowIndex(startRow);
checkRowIndex(endRow);
if (endRow < startRow) {
throw new NumberIsTooSmallException(LocalizedFormats.INITIAL_ROW_AFTER_FINAL_ROW,
endRow, startRow, true);
}
checkColumnIndex(startColumn);
checkColumnIndex(endColumn);
if (endColumn < startColumn) {
throw new NumberIsTooSmallException(LocalizedFormats.INITIAL_COLUMN_AFTER_FINAL_COLUMN,
endColumn, startColumn, true);
}
}
示例8: FieldBracketingNthOrderBrentSolver
import org.apache.commons.math3.exception.NumberIsTooSmallException; //导入依赖的package包/类
/**
* Construct a solver.
*
* @param relativeAccuracy Relative accuracy.
* @param absoluteAccuracy Absolute accuracy.
* @param functionValueAccuracy Function value accuracy.
* @param maximalOrder maximal order.
* @exception NumberIsTooSmallException if maximal order is lower than 2
*/
public FieldBracketingNthOrderBrentSolver(final T relativeAccuracy,
final T absoluteAccuracy,
final T functionValueAccuracy,
final int maximalOrder)
throws NumberIsTooSmallException {
if (maximalOrder < 2) {
throw new NumberIsTooSmallException(maximalOrder, 2, true);
}
this.field = relativeAccuracy.getField();
this.maximalOrder = maximalOrder;
this.absoluteAccuracy = absoluteAccuracy;
this.relativeAccuracy = relativeAccuracy;
this.functionValueAccuracy = functionValueAccuracy;
this.evaluations = IntegerSequence.Incrementor.create();
}
示例9: PowellOptimizer
import org.apache.commons.math3.exception.NumberIsTooSmallException; //导入依赖的package包/类
/**
* This constructor allows to specify a user-defined convergence checker,
* in addition to the parameters that control the default convergence
* checking procedure and the line search tolerances.
*
* @param rel Relative threshold for this optimizer.
* @param abs Absolute threshold for this optimizer.
* @param lineRel Relative threshold for the internal line search optimizer.
* @param lineAbs Absolute threshold for the internal line search optimizer.
* @param checker Convergence checker.
* @throws NotStrictlyPositiveException if {@code abs <= 0}.
* @throws NumberIsTooSmallException if {@code rel < 2 * Math.ulp(1d)}.
*/
public PowellOptimizer(double rel,
double abs,
double lineRel,
double lineAbs,
ConvergenceChecker<PointValuePair> checker) {
super(checker);
if (rel < MIN_RELATIVE_TOLERANCE) {
throw new NumberIsTooSmallException(rel, MIN_RELATIVE_TOLERANCE, true);
}
if (abs <= 0) {
throw new NotStrictlyPositiveException(abs);
}
relativeThreshold = rel;
absoluteThreshold = abs;
// Create the line search optimizer.
line = new LineSearch(this,
lineRel,
lineAbs,
1d);
}
示例10: walkInRowOrder
import org.apache.commons.math3.exception.NumberIsTooSmallException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public double walkInRowOrder(final RealMatrixPreservingVisitor visitor,
final int startRow, final int endRow,
final int startColumn, final int endColumn)
throws OutOfRangeException, NumberIsTooSmallException {
MatrixUtils.checkSubMatrixIndex(this, startRow, endRow, startColumn, endColumn);
visitor.start(getRowDimension(), getColumnDimension(),
startRow, endRow, startColumn, endColumn);
for (int i = startRow; i <= endRow; ++i) {
final double[] rowI = data[i];
for (int j = startColumn; j <= endColumn; ++j) {
visitor.visit(i, j, rowI[j]);
}
}
return visitor.end();
}
示例11: interpolate
import org.apache.commons.math3.exception.NumberIsTooSmallException; //导入依赖的package包/类
/**
* Compute an interpolating function for the dataset.
*
* @param x Interpolating points array.
* @param y Interpolating values array.
* @return a function which interpolates the dataset.
* @throws DimensionMismatchException if the array lengths are different.
* @throws NumberIsTooSmallException if the number of points is less than 2.
* @throws NonMonotonicSequenceException if {@code x} is not sorted in
* strictly increasing order.
*/
public PolynomialFunctionNewtonForm interpolate(double x[], double y[])
throws DimensionMismatchException,
NumberIsTooSmallException,
NonMonotonicSequenceException {
/**
* a[] and c[] are defined in the general formula of Newton form:
* p(x) = a[0] + a[1](x-c[0]) + a[2](x-c[0])(x-c[1]) + ... +
* a[n](x-c[0])(x-c[1])...(x-c[n-1])
*/
PolynomialFunctionLagrangeForm.verifyInterpolationArray(x, y, true);
/**
* When used for interpolation, the Newton form formula becomes
* p(x) = f[x0] + f[x0,x1](x-x0) + f[x0,x1,x2](x-x0)(x-x1) + ... +
* f[x0,x1,...,x[n-1]](x-x0)(x-x1)...(x-x[n-2])
* Therefore, a[k] = f[x0,x1,...,xk], c[k] = x[k].
* <p>
* Note x[], y[], a[] have the same length but c[]'s size is one less.</p>
*/
final double[] c = new double[x.length-1];
System.arraycopy(x, 0, c, 0, c.length);
final double[] a = computeDividedDifference(x, y);
return new PolynomialFunctionNewtonForm(a, c);
}
示例12: walkInRowOrder
import org.apache.commons.math3.exception.NumberIsTooSmallException; //导入依赖的package包/类
/** {@inheritDoc} */
public T walkInRowOrder(final FieldMatrixChangingVisitor<T> visitor,
final int startRow, final int endRow,
final int startColumn, final int endColumn)
throws NumberIsTooSmallException, OutOfRangeException {
checkSubMatrixIndex(startRow, endRow, startColumn, endColumn);
visitor.start(getRowDimension(), getColumnDimension(),
startRow, endRow, startColumn, endColumn);
for (int row = startRow; row <= endRow; ++row) {
for (int column = startColumn; column <= endColumn; ++column) {
final T oldValue = getEntry(row, column);
final T newValue = visitor.visit(row, column, oldValue);
setEntry(row, column, newValue);
}
}
return visitor.end();
}
示例13: walkInColumnOrder
import org.apache.commons.math3.exception.NumberIsTooSmallException; //导入依赖的package包/类
/** {@inheritDoc} */
public T walkInColumnOrder(final FieldMatrixChangingVisitor<T> visitor,
final int startRow, final int endRow,
final int startColumn, final int endColumn)
throws NumberIsTooSmallException, OutOfRangeException {
checkSubMatrixIndex(startRow, endRow, startColumn, endColumn);
visitor.start(getRowDimension(), getColumnDimension(),
startRow, endRow, startColumn, endColumn);
for (int column = startColumn; column <= endColumn; ++column) {
for (int row = startRow; row <= endRow; ++row) {
final T oldValue = getEntry(row, column);
final T newValue = visitor.visit(row, column, oldValue);
setEntry(row, column, newValue);
}
}
return visitor.end();
}
示例14: walkInColumnOrder
import org.apache.commons.math3.exception.NumberIsTooSmallException; //导入依赖的package包/类
/** {@inheritDoc} */
public double walkInColumnOrder(final RealMatrixChangingVisitor visitor,
final int startRow, final int endRow,
final int startColumn, final int endColumn)
throws OutOfRangeException, NumberIsTooSmallException {
MatrixUtils.checkSubMatrixIndex(this, startRow, endRow, startColumn, endColumn);
visitor.start(getRowDimension(), getColumnDimension(),
startRow, endRow, startColumn, endColumn);
for (int column = startColumn; column <= endColumn; ++column) {
for (int row = startRow; row <= endRow; ++row) {
final double oldValue = getEntry(row, column);
final double newValue = visitor.visit(row, column, oldValue);
setEntry(row, column, newValue);
}
}
return visitor.end();
}
示例15: PolynomialSplineFunction
import org.apache.commons.math3.exception.NumberIsTooSmallException; //导入依赖的package包/类
/**
* Construct a polynomial spline function with the given segment delimiters
* and interpolating polynomials.
* The constructor copies both arrays and assigns the copies to the knots
* and polynomials properties, respectively.
*
* @param knots Spline segment interval delimiters.
* @param polynomials Polynomial functions that make up the spline.
* @throws NullArgumentException if either of the input arrays is {@code null}.
* @throws NumberIsTooSmallException if knots has length less than 2.
* @throws DimensionMismatchException if {@code polynomials.length != knots.length - 1}.
* @throws NonMonotonicSequenceException if the {@code knots} array is not strictly increasing.
*
*/
public PolynomialSplineFunction(double knots[], PolynomialFunction polynomials[])
throws NullArgumentException, NumberIsTooSmallException,
DimensionMismatchException, NonMonotonicSequenceException{
if (knots == null ||
polynomials == null) {
throw new NullArgumentException();
}
if (knots.length < 2) {
throw new NumberIsTooSmallException(LocalizedFormats.NOT_ENOUGH_POINTS_IN_SPLINE_PARTITION,
2, knots.length, false);
}
if (knots.length - 1 != polynomials.length) {
throw new DimensionMismatchException(polynomials.length, knots.length);
}
MathArrays.checkOrder(knots);
this.n = knots.length -1;
this.knots = new double[n + 1];
System.arraycopy(knots, 0, this.knots, 0, n + 1);
this.polynomials = new PolynomialFunction[n];
System.arraycopy(polynomials, 0, this.polynomials, 0, n);
}