本文整理汇总了Java中org.apache.commons.math3.exception.NotStrictlyPositiveException类的典型用法代码示例。如果您正苦于以下问题:Java NotStrictlyPositiveException类的具体用法?Java NotStrictlyPositiveException怎么用?Java NotStrictlyPositiveException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NotStrictlyPositiveException类属于org.apache.commons.math3.exception包,在下文中一共展示了NotStrictlyPositiveException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MultivariateNormalMixtureExpectationMaximization
import org.apache.commons.math3.exception.NotStrictlyPositiveException; //导入依赖的package包/类
/**
* Creates an object to fit a multivariate normal mixture model to data.
*
* @param data Data to use in fitting procedure
* @throws NotStrictlyPositiveException if data has no rows
* @throws DimensionMismatchException if rows of data have different numbers
* of columns
* @throws NumberIsTooSmallException if the number of columns in the data is
* less than 2
*/
public MultivariateNormalMixtureExpectationMaximization(double[][] data)
throws NotStrictlyPositiveException,
DimensionMismatchException,
NumberIsTooSmallException {
if (data.length < 1) {
throw new NotStrictlyPositiveException(data.length);
}
this.data = new double[data.length][data[0].length];
for (int i = 0; i < data.length; i++) {
if (data[i].length != data[0].length) {
// Jagged arrays not allowed
throw new DimensionMismatchException(data[i].length,
data[0].length);
}
if (data[i].length < 2) {
throw new NumberIsTooSmallException(LocalizedFormats.NUMBER_TOO_SMALL,
data[i].length, 2, true);
}
this.data[i] = MathArrays.copyOf(data[i], data[i].length);
}
}
示例2: MultidimensionalCounter
import org.apache.commons.math3.exception.NotStrictlyPositiveException; //导入依赖的package包/类
/**
* Create a counter.
*
* @param size Counter sizes (number of slots in each dimension).
* @throws NotStrictlyPositiveException if one of the sizes is
* negative or zero.
*/
public MultidimensionalCounter(int ... size) {
dimension = size.length;
this.size = MathArrays.copyOf(size);
uniCounterOffset = new int[dimension];
last = dimension - 1;
int tS = size[last];
for (int i = 0; i < last; i++) {
int count = 1;
for (int j = i + 1; j < dimension; j++) {
count *= size[j];
}
uniCounterOffset[i] = count;
tS *= size[i];
}
uniCounterOffset[last] = 0;
if (tS <= 0) {
throw new NotStrictlyPositiveException(tS);
}
totalSize = tS;
}
示例3: FDistribution
import org.apache.commons.math3.exception.NotStrictlyPositiveException; //导入依赖的package包/类
/**
* Creates an F distribution.
*
* @param rng Random number generator.
* @param numeratorDegreesOfFreedom Numerator degrees of freedom.
* @param denominatorDegreesOfFreedom Denominator degrees of freedom.
* @param inverseCumAccuracy the maximum absolute error in inverse
* cumulative probability estimates.
* @throws NotStrictlyPositiveException if {@code numeratorDegreesOfFreedom <= 0} or
* {@code denominatorDegreesOfFreedom <= 0}.
* @since 3.1
*/
public FDistribution(RandomGenerator rng,
double numeratorDegreesOfFreedom,
double denominatorDegreesOfFreedom,
double inverseCumAccuracy)
throws NotStrictlyPositiveException {
super(rng);
if (numeratorDegreesOfFreedom <= 0) {
throw new NotStrictlyPositiveException(LocalizedFormats.DEGREES_OF_FREEDOM,
numeratorDegreesOfFreedom);
}
if (denominatorDegreesOfFreedom <= 0) {
throw new NotStrictlyPositiveException(LocalizedFormats.DEGREES_OF_FREEDOM,
denominatorDegreesOfFreedom);
}
this.numeratorDegreesOfFreedom = numeratorDegreesOfFreedom;
this.denominatorDegreesOfFreedom = denominatorDegreesOfFreedom;
solverAbsoluteAccuracy = inverseCumAccuracy;
}
示例4: sample
import org.apache.commons.math3.exception.NotStrictlyPositiveException; //导入依赖的package包/类
/**
* Generate a random sample from the distribution.
*
* @param sampleSize the number of random values to generate.
* @return an array representing the random sample.
* @throws NotStrictlyPositiveException if {@code sampleSize} is not
* positive.
*/
public Object[] sample(int sampleSize) throws NotStrictlyPositiveException {
if (sampleSize <= 0) {
throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES,
sampleSize);
}
final Object[] out = new Object[sampleSize];
for (int i = 0; i < sampleSize; i++) {
out[i] = sample();
}
return out;
}
示例5: Logistic
import org.apache.commons.math3.exception.NotStrictlyPositiveException; //导入依赖的package包/类
/**
* @param k If {@code b > 0}, value of the function for x going towards +∞.
* If {@code b < 0}, value of the function for x going towards -∞.
* @param m Abscissa of maximum growth.
* @param b Growth rate.
* @param q Parameter that affects the position of the curve along the
* ordinate axis.
* @param a If {@code b > 0}, value of the function for x going towards -∞.
* If {@code b < 0}, value of the function for x going towards +∞.
* @param n Parameter that affects near which asymptote the maximum
* growth occurs.
* @throws NotStrictlyPositiveException if {@code n <= 0}.
*/
public Logistic(double k,
double m,
double b,
double q,
double a,
double n)
throws NotStrictlyPositiveException {
if (n <= 0) {
throw new NotStrictlyPositiveException(n);
}
this.k = k;
this.m = m;
this.b = b;
this.q = q;
this.a = a;
oneOverN = 1 / n;
}
示例6: nextPermutation
import org.apache.commons.math3.exception.NotStrictlyPositiveException; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* This method calls {@link MathArrays#shuffle(int[],RandomGenerator)
* MathArrays.shuffle} in order to create a random shuffle of the set
* of natural numbers {@code { 0, 1, ..., n - 1 }}.
*
* @throws NumberIsTooLargeException if {@code k > n}.
* @throws NotStrictlyPositiveException if {@code k <= 0}.
*/
public int[] nextPermutation(int n, int k)
throws NumberIsTooLargeException, NotStrictlyPositiveException {
if (k > n) {
throw new NumberIsTooLargeException(LocalizedFormats.PERMUTATION_EXCEEDS_N,
k, n, true);
}
if (k <= 0) {
throw new NotStrictlyPositiveException(LocalizedFormats.PERMUTATION_SIZE,
k);
}
int[] index = MathArrays.natural(n);
MathArrays.shuffle(index, getRandomGenerator());
// Return a new array containing the first "k" entries of "index".
return MathArrays.copyOf(index, k);
}
示例7: ResizableDoubleArray
import org.apache.commons.math3.exception.NotStrictlyPositiveException; //导入依赖的package包/类
/**
* Creates an instance with the specified properties.
* <br/>
* Throws MathIllegalArgumentException if the following conditions are
* not met:
* <ul>
* <li>{@code initialCapacity > 0}</li>
* <li>{@code expansionFactor > 1}</li>
* <li>{@code contractionCriterion >= expansionFactor}</li>
* </ul>
*
* @param initialCapacity Initial size of the internal storage array.
* @param expansionFactor The array will be expanded based on this
* parameter.
* @param contractionCriterion Contraction criteria.
* @param expansionMode Expansion mode.
* @param data Initial contents of the array.
* @throws MathIllegalArgumentException if the parameters are not valid.
*/
public ResizableDoubleArray(int initialCapacity,
double expansionFactor,
double contractionCriterion,
ExpansionMode expansionMode,
double ... data)
throws MathIllegalArgumentException {
if (initialCapacity <= 0) {
throw new NotStrictlyPositiveException(LocalizedFormats.INITIAL_CAPACITY_NOT_POSITIVE,
initialCapacity);
}
checkContractExpand(contractionCriterion, expansionFactor);
this.expansionFactor = expansionFactor;
this.contractionCriterion = contractionCriterion;
this.expansionMode = expansionMode;
internalArray = new double[initialCapacity];
numElements = 0;
startIndex = 0;
if (data != null && data.length > 0) {
addElements(data);
}
}
示例8: ZipfDistribution
import org.apache.commons.math3.exception.NotStrictlyPositiveException; //导入依赖的package包/类
/**
* Creates a Zipf distribution.
*
* @param rng Random number generator.
* @param numberOfElements Number of elements.
* @param exponent Exponent.
* @exception NotStrictlyPositiveException if {@code numberOfElements <= 0}
* or {@code exponent <= 0}.
* @since 3.1
*/
public ZipfDistribution(RandomGenerator rng,
int numberOfElements,
double exponent)
throws NotStrictlyPositiveException {
super(rng);
if (numberOfElements <= 0) {
throw new NotStrictlyPositiveException(LocalizedFormats.DIMENSION,
numberOfElements);
}
if (exponent <= 0) {
throw new NotStrictlyPositiveException(LocalizedFormats.EXPONENT,
exponent);
}
this.numberOfElements = numberOfElements;
this.exponent = exponent;
}
示例9: PoissonDistribution
import org.apache.commons.math3.exception.NotStrictlyPositiveException; //导入依赖的package包/类
/**
* Creates a new Poisson distribution with specified mean, convergence
* criterion and maximum number of iterations.
*
* @param rng Random number generator.
* @param p Poisson mean.
* @param epsilon Convergence criterion for cumulative probabilities.
* @param maxIterations the maximum number of iterations for cumulative
* probabilities.
* @throws NotStrictlyPositiveException if {@code p <= 0}.
* @since 3.1
*/
public PoissonDistribution(RandomGenerator rng,
double p,
double epsilon,
int maxIterations)
throws NotStrictlyPositiveException {
super(rng);
if (p <= 0) {
throw new NotStrictlyPositiveException(LocalizedFormats.MEAN, p);
}
mean = p;
this.epsilon = epsilon;
this.maxIterations = maxIterations;
// Use the same RNG instance as the parent class.
normal = new NormalDistribution(rng, p, FastMath.sqrt(p),
NormalDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
exponential = new ExponentialDistribution(rng, 1,
ExponentialDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
}
示例10: Logistic
import org.apache.commons.math3.exception.NotStrictlyPositiveException; //导入依赖的package包/类
/**
* @param k If {@code b > 0}, value of the function for x going towards +∞.
* If {@code b < 0}, value of the function for x going towards -∞.
* @param m Abscissa of maximum growth.
* @param b Growth rate.
* @param q Parameter that affects the position of the curve along the
* ordinate axis.
* @param a If {@code b > 0}, value of the function for x going towards -∞.
* If {@code b < 0}, value of the function for x going towards +∞.
* @param n Parameter that affects near which asymptote the maximum
* growth occurs.
* @throws NotStrictlyPositiveException if {@code n <= 0}.
*/
public Logistic(double k,
double m,
double b,
double q,
double a,
double n) {
if (n <= 0) {
throw new NotStrictlyPositiveException(n);
}
this.k = k;
this.m = m;
this.b = b;
this.q = q;
this.a = a;
oneOverN = 1 / n;
}
示例11: WeibullDistribution
import org.apache.commons.math3.exception.NotStrictlyPositiveException; //导入依赖的package包/类
/**
* Creates a Weibull distribution.
*
* @param rng Random number generator.
* @param alpha Shape parameter.
* @param beta Scale parameter.
* @param inverseCumAccuracy Maximum absolute error in inverse
* cumulative probability estimates
* (defaults to {@link #DEFAULT_INVERSE_ABSOLUTE_ACCURACY}).
* @throws NotStrictlyPositiveException if {@code alpha <= 0} or {@code beta <= 0}.
* @since 3.1
*/
public WeibullDistribution(RandomGenerator rng,
double alpha,
double beta,
double inverseCumAccuracy)
throws NotStrictlyPositiveException {
super(rng);
if (alpha <= 0) {
throw new NotStrictlyPositiveException(LocalizedFormats.SHAPE,
alpha);
}
if (beta <= 0) {
throw new NotStrictlyPositiveException(LocalizedFormats.SCALE,
beta);
}
scale = beta;
shape = alpha;
solverAbsoluteAccuracy = inverseCumAccuracy;
}
示例12: nextSample
import org.apache.commons.math3.exception.NotStrictlyPositiveException; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* This method calls {@link #nextPermutation(int,int) nextPermutation(c.size(), k)}
* in order to sample the collection.
*/
public Object[] nextSample(Collection<?> c, int k) throws NumberIsTooLargeException, NotStrictlyPositiveException {
int len = c.size();
if (k > len) {
throw new NumberIsTooLargeException(LocalizedFormats.SAMPLE_SIZE_EXCEEDS_COLLECTION_SIZE,
k, len, true);
}
if (k <= 0) {
throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES, k);
}
Object[] objects = c.toArray();
int[] index = nextPermutation(len, k);
Object[] result = new Object[k];
for (int i = 0; i < k; i++) {
result[i] = objects[index[i]];
}
return result;
}
示例13: ExponentialDecayFunction
import org.apache.commons.math3.exception.NotStrictlyPositiveException; //导入依赖的package包/类
/**
* Creates an instance. It will be such that
* <ul>
* <li>{@code a = initValue}</li>
* <li>{@code b = -numCall / ln(valueAtNumCall / initValue)}</li>
* </ul>
*
* @param initValue Initial value, i.e. {@link #value(long) value(0)}.
* @param valueAtNumCall Value of the function at {@code numCall}.
* @param numCall Argument for which the function returns
* {@code valueAtNumCall}.
* @throws NotStrictlyPositiveException if {@code initValue <= 0}.
* @throws NotStrictlyPositiveException if {@code valueAtNumCall <= 0}.
* @throws NumberIsTooLargeException if {@code valueAtNumCall >= initValue}.
* @throws NotStrictlyPositiveException if {@code numCall <= 0}.
*/
public ExponentialDecayFunction(double initValue,
double valueAtNumCall,
long numCall) {
if (initValue <= 0) {
throw new NotStrictlyPositiveException(initValue);
}
if (valueAtNumCall <= 0) {
throw new NotStrictlyPositiveException(valueAtNumCall);
}
if (valueAtNumCall >= initValue) {
throw new NumberIsTooLargeException(valueAtNumCall, initValue, false);
}
if (numCall <= 0) {
throw new NotStrictlyPositiveException(numCall);
}
a = initValue;
oneOverB = -FastMath.log(valueAtNumCall / initValue) / numCall;
}
示例14: sample
import org.apache.commons.math3.exception.NotStrictlyPositiveException; //导入依赖的package包/类
/**
* 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;
}
示例15: UnivariateMultiStartOptimizer
import org.apache.commons.math3.exception.NotStrictlyPositiveException; //导入依赖的package包/类
/**
* Create a multi-start optimizer from a single-start optimizer.
*
* @param optimizer Single-start optimizer to wrap.
* @param starts Number of starts to perform. If {@code starts == 1},
* the {@code optimize} methods will return the same solution as
* {@code optimizer} would.
* @param generator Random generator to use for restarts.
* @throws NullArgumentException if {@code optimizer} or {@code generator}
* is {@code null}.
* @throws NotStrictlyPositiveException if {@code starts < 1}.
*/
public UnivariateMultiStartOptimizer(final BaseUnivariateOptimizer<FUNC> optimizer,
final int starts,
final RandomGenerator generator) {
if (optimizer == null ||
generator == null) {
throw new NullArgumentException();
}
if (starts < 1) {
throw new NotStrictlyPositiveException(starts);
}
this.optimizer = optimizer;
this.starts = starts;
this.generator = generator;
}