本文整理汇总了Java中org.apache.commons.math3.exception.util.LocalizedFormats.INSUFFICIENT_OBSERVED_POINTS_IN_SAMPLE属性的典型用法代码示例。如果您正苦于以下问题:Java LocalizedFormats.INSUFFICIENT_OBSERVED_POINTS_IN_SAMPLE属性的具体用法?Java LocalizedFormats.INSUFFICIENT_OBSERVED_POINTS_IN_SAMPLE怎么用?Java LocalizedFormats.INSUFFICIENT_OBSERVED_POINTS_IN_SAMPLE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.commons.math3.exception.util.LocalizedFormats
的用法示例。
在下文中一共展示了LocalizedFormats.INSUFFICIENT_OBSERVED_POINTS_IN_SAMPLE属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ParameterGuesser
/**
* Simple constructor.
*
* @param observations Sampled observations.
* @throws NumberIsTooSmallException if the sample is too short.
* @throws ZeroException if the abscissa range is zero.
* @throws MathIllegalStateException when the guessing procedure cannot
* produce sensible results.
*/
public ParameterGuesser(Collection<WeightedObservedPoint> observations) {
if (observations.size() < 4) {
throw new NumberIsTooSmallException(LocalizedFormats.INSUFFICIENT_OBSERVED_POINTS_IN_SAMPLE,
observations.size(), 4, true);
}
final WeightedObservedPoint[] sorted
= sortObservations(observations).toArray(new WeightedObservedPoint[0]);
final double aOmega[] = guessAOmega(sorted);
a = aOmega[0];
omega = aOmega[1];
phi = guessPhi(sorted);
}
示例2: createMarkerArray
/**
* Creates a marker array using initial five elements and a quantile
*
* @param initialFive list of initial five elements
* @param p the pth quantile
* @return Marker array
*/
private static Marker[] createMarkerArray(
final List<Double> initialFive, final double p) {
final int countObserved =
initialFive == null ? -1 : initialFive.size();
if (countObserved < PSQUARE_CONSTANT) {
throw new InsufficientDataException(
LocalizedFormats.INSUFFICIENT_OBSERVED_POINTS_IN_SAMPLE,
countObserved, PSQUARE_CONSTANT);
}
Collections.sort(initialFive);
return new Marker[] {
new Marker(),// Null Marker
new Marker(initialFive.get(0), 1, 0, 1),
new Marker(initialFive.get(1), 1 + 2 * p, p / 2, 2),
new Marker(initialFive.get(2), 1 + 4 * p, p, 3),
new Marker(initialFive.get(3), 3 + 2 * p, (1 + p) / 2, 4),
new Marker(initialFive.get(4), 5, 1, 5) };
}
示例3: covariance
/**
* Computes the covariance between the two arrays.
*
* <p>Array lengths must match and the common length must be at least 2.</p>
*
* @param xArray first data array
* @param yArray second data array
* @param biasCorrected if true, returned value will be bias-corrected
* @return returns the covariance for the two arrays
* @throws MathIllegalArgumentException if the arrays lengths do not match or
* there is insufficient data
*/
public double covariance(final double[] xArray, final double[] yArray, boolean biasCorrected)
throws MathIllegalArgumentException {
Mean mean = new Mean();
double result = 0d;
int length = xArray.length;
if (length != yArray.length) {
throw new MathIllegalArgumentException(
LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE, length, yArray.length);
} else if (length < 2) {
throw new MathIllegalArgumentException(
LocalizedFormats.INSUFFICIENT_OBSERVED_POINTS_IN_SAMPLE, length, 2);
} else {
double xMean = mean.evaluate(xArray);
double yMean = mean.evaluate(yArray);
for (int i = 0; i < length; i++) {
double xDev = xArray[i] - xMean;
double yDev = yArray[i] - yMean;
result += (xDev * yDev - result) / (i + 1);
}
}
return biasCorrected ? result * ((double) length / (double)(length - 1)) : result;
}
示例4: ParameterGuesser
/**
* Simple constructor.
*
* @param observations Sampled observations.
* @throws NumberIsTooSmallException if the sample is too short.
* @throws ZeroException if the abscissa range is zero.
* @throws MathIllegalStateException when the guessing procedure cannot
* produce sensible results.
*/
public ParameterGuesser(WeightedObservedPoint[] observations) {
if (observations.length < 4) {
throw new NumberIsTooSmallException(LocalizedFormats.INSUFFICIENT_OBSERVED_POINTS_IN_SAMPLE,
observations.length, 4, true);
}
final WeightedObservedPoint[] sorted = sortObservations(observations);
final double aOmega[] = guessAOmega(sorted);
a = aOmega[0];
omega = aOmega[1];
phi = guessPhi(sorted);
}
示例5: checkArray
/**
* Verifies that {@code array} has length at least 2.
*
* @param array array to test
* @throws NullArgumentException if array is null
* @throws InsufficientDataException if array is too short
*/
private void checkArray(double[] array) {
if (array == null) {
throw new NullArgumentException(LocalizedFormats.NULL_NOT_ALLOWED);
}
if (array.length < 2) {
throw new InsufficientDataException(LocalizedFormats.INSUFFICIENT_OBSERVED_POINTS_IN_SAMPLE, array.length,
2);
}
}
示例6: newSampleData
/**
* <p>Loads model x and y sample data from a flat input array, overriding any previous sample.
* </p>
* <p>Assumes that rows are concatenated with y values first in each row. For example, an input
* <code>data</code> array containing the sequence of values (1, 2, 3, 4, 5, 6, 7, 8, 9) with
* <code>nobs = 3</code> and <code>nvars = 2</code> creates a regression dataset with two
* independent variables, as below:
* <pre>
* y x[0] x[1]
* --------------
* 1 2 3
* 4 5 6
* 7 8 9
* </pre>
* </p>
* <p>Note that there is no need to add an initial unitary column (column of 1's) when
* specifying a model including an intercept term. If {@link #isNoIntercept()} is <code>true</code>,
* the X matrix will be created without an initial column of "1"s; otherwise this column will
* be added.
* </p>
* <p>Throws IllegalArgumentException if any of the following preconditions fail:
* <ul><li><code>data</code> cannot be null</li>
* <li><code>data.length = nobs * (nvars + 1)</li>
* <li><code>nobs > nvars</code></li></ul>
* </p>
*
* @param data input data array
* @param nobs number of observations (rows)
* @param nvars number of independent variables (columns, not counting y)
* @throws NullArgumentException if the data array is null
* @throws DimensionMismatchException if the length of the data array is not equal
* to <code>nobs * (nvars + 1)</code>
* @throws InsufficientDataException if <code>nobs</code> is less than
* <code>nvars + 1</code>
*/
public void newSampleData(double[] data, int nobs, int nvars) {
if (data == null) {
throw new NullArgumentException();
}
if (data.length != nobs * (nvars + 1)) {
throw new DimensionMismatchException(data.length, nobs * (nvars + 1));
}
if (nobs <= nvars) {
throw new InsufficientDataException(LocalizedFormats.INSUFFICIENT_OBSERVED_POINTS_IN_SAMPLE, nobs, nvars + 1);
}
double[] y = new double[nobs];
final int cols = noIntercept ? nvars: nvars + 1;
double[][] x = new double[nobs][cols];
int pointer = 0;
for (int i = 0; i < nobs; i++) {
y[i] = data[pointer++];
if (!noIntercept) {
x[i][0] = 1.0d;
}
for (int j = noIntercept ? 0 : 1; j < cols; j++) {
x[i][j] = data[pointer++];
}
}
this.xMatrix = new Array2DRowRealMatrix(x);
this.yVector = new ArrayRealVector(y);
}