/** * 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]); } }
/** * 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]); } }
/** * 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]); } }
/** * Calculates the centroid of all given points in a nD space (assumes that * all points have n coordinates). Each coordinate of the centroid is a mean * of all values of the same coordinate of each point. * * @param points all points * @return the centroid of all given points */ public Vector<Double> calculateCentroid( List<Vector<Double>> points ) { List<Mean> coordinateMeans = new ArrayList<Mean>(); for ( int i = 0; i < points.get( 0 ).size(); ++i ) { coordinateMeans.add( new Mean() ); } for ( Vector<Double> point : points ) { for ( int i = 0; i < point.size(); ++i ) { coordinateMeans.get( i ).increment( point.get( i ) ); } } Vector<Double> centroid = new Vector<Double>(); for ( Mean mean : coordinateMeans ) { centroid.add( mean.getResult() ); } return centroid; }
/** * @return Dom string average size (byte). */ public int getMeanStateStringSize() { final Mean mean = new Mean(); for (StateVertex state : getAllStates()) { mean.increment(state.getDomSize()); } return (int) mean.getResult(); }
public double getValueRepresenting(TimeRange range) { Mean mean = new Mean(); for (DataPoint pt : getPoints(range)) { mean.increment(pt.getValue()); } return mean.getResult(); }