/** * Get the number of vectors in the sample. * @return number of vectors in the sample */ public long getN() { return (means.length == 0) ? 0 : means[0].getN(); }
/** Constructs a VectorialMean. * @param dimension vectors dimension */ public VectorialMean(int dimension) { means = new Mean[dimension]; for (int i = 0; i < dimension; ++i) { means[i] = new Mean(); } }
/** * Returns the weighted arithmetic mean of the entries in the input array. * <p> * Throws <code>IllegalArgumentException</code> if either array is null.</p> * <p> * See {@link Mean} for details on the computing algorithm. The two-pass algorithm * described above is used here, with weights applied in computing both the original * estimate and the correction factor.</p> * <p> * Throws <code>IllegalArgumentException</code> if any of the following are true: * <ul><li>the values array is null</li> * <li>the weights array is null</li> * <li>the weights array does not have the same length as the values array</li> * <li>the weights array contains one or more infinite values</li> * <li>the weights array contains one or more NaN values</li> * <li>the weights array contains negative values</li> * </ul></p> * * @param values the input array * @param weights the weights array * @return the mean of the values or Double.NaN if length = 0 * @throws IllegalArgumentException if the parameters are not valid * @since 2.1 */ public double evaluate(final double[] values, final double[] weights) { return evaluate(values, weights, 0, values.length); }
/** * Get the mean vector. * @return mean vector */ public double[] getResult() { double[] result = new double[means.length]; for (int i = 0; i < result.length; ++i) { result[i] = means[i].getResult(); } return result; }
/** * Add a new vector to the sample. * @param v vector to add * @exception DimensionMismatchException if the vector does not have the right dimension */ public void increment(double[] v) throws DimensionMismatchException { if (v.length != means.length) { throw new DimensionMismatchException(v.length, means.length); } for (int i = 0; i < v.length; ++i) { means[i].increment(v[i]); } }
if (test(values, begin, length)) { Sum sum = new Sum(); double sampleSize = (double) length;
/** Constructs a VectorialMean. * @param dimension vectors dimension */ public VectorialMean(int dimension) { means = new Mean[dimension]; for (int i = 0; i < dimension; ++i) { means[i] = new Mean(); } }
/** * Returns the weighted arithmetic mean of the entries in the input array. * <p> * Throws <code>IllegalArgumentException</code> if either array is null.</p> * <p> * See {@link Mean} for details on the computing algorithm. The two-pass algorithm * described above is used here, with weights applied in computing both the original * estimate and the correction factor.</p> * <p> * Throws <code>IllegalArgumentException</code> if any of the following are true: * <ul><li>the values array is null</li> * <li>the weights array is null</li> * <li>the weights array does not have the same length as the values array</li> * <li>the weights array contains one or more infinite values</li> * <li>the weights array contains one or more NaN values</li> * <li>the weights array contains negative values</li> * </ul></p> * * @param values the input array * @param weights the weights array * @return the mean of the values or Double.NaN if length = 0 * @throws IllegalArgumentException if the parameters are not valid * @since 2.1 */ public double evaluate(final double[] values, final double[] weights) { return evaluate(values, weights, 0, values.length); }
/** * Get the mean vector. * @return mean vector */ public double[] getResult() { double[] result = new double[means.length]; for (int i = 0; i < result.length; ++i) { result[i] = means[i].getResult(); } return result; }
/** * Add a new vector to the sample. * @param v vector to add * @exception DimensionMismatchException if the vector does not have the right dimension */ public void increment(double[] v) throws DimensionMismatchException { if (v.length != means.length) { throw new DimensionMismatchException(v.length, means.length); } for (int i = 0; i < v.length; ++i) { means[i].increment(v[i]); } }
if (test(values, begin, length)) { Sum sum = new Sum(); double sampleSize = length;
/** Constructs a VectorialMean. * @param dimension vectors dimension */ public VectorialMean(int dimension) { means = new Mean[dimension]; for (int i = 0; i < dimension; ++i) { means[i] = new Mean(); } }