# A numeric range has a high, low, mean, root-mean-square, standard deviation, and the count of how many samples it contains. : Range « Collections Data Structure « Java

A numeric range has a high, low, mean, root-mean-square, standard deviation, and the count of how many samples it contains.

```

/*
* Encog(tm) Core v3.0 - Java Version
* http://www.heatonresearch.com/encog/

* Copyright 2008-2011 Heaton Research, Inc.
*
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
*
*/

import java.util.List;

/**
* A numeric range has a high, low, mean, root-mean-square, standard deviation,
* and the count of how many samples it contains.
*
*/
public class NumericRange {
/**
* Display to five decimal places.
*/
public static final int FIVE = 5;

/**
* The high number in the range.
*/
private final double high;

/**
* The low number in the range.
*/
private final double low;

/**
* The mean value.
*/
private final double mean;

/**
* The root mean square of the range.
*/
private final double rms;

/**
* The standard deviation of the range.
*/
private final double standardDeviation;

/**
* The number of values in this range.
*/
private final int samples;

/**
* Create a numeric range from a list of values.
*
* @param values
*            The values to calculate for.
*/
public NumericRange(final List<Double> values) {

double assignedHigh = 0;
double assignedLow = 0;
double total = 0;
double rmsTotal = 0;

// get the mean and other 1-pass values.

for (final double d : values) {
assignedHigh = Math.max(assignedHigh, d);
assignedLow = Math.min(assignedLow, d);
total += d;
rmsTotal += d * d;
}

this.samples = values.size();
this.high = assignedHigh;
this.low = assignedLow;
this.mean = total / this.samples;
this.rms = Math.sqrt(rmsTotal / this.samples);

// now get the standard deviation
double devTotal = 0;

for (final double d : values) {
devTotal += Math.pow(d - this.mean, 2);
}
this.standardDeviation = Math.sqrt(devTotal / this.samples);
}

/**
* @return The high number in the range.
*/
public final double getHigh() {
return this.high;
}

/**
* @return The low number in the range.
*/
public final double getLow() {
return this.low;
}

/**
* @return The mean in the range.
*/
public final double getMean() {
return this.mean;
}

/**
* @return The root mean square of the range.
*/
public final double getRms() {
return this.rms;
}

/**
* @return The number of samples in the range.
*/
public final int getSamples() {
return this.samples;
}

/**
* @return The standard deviation of the range.
*/
public final double getStandardDeviation() {
return this.standardDeviation;
}

}

```

### Related examples in the same category

 1 Represents a sequence of integer values, either ascending or descending. 2 This constructs an Iterator over each day in a date range defined by a focus date and range style. 3 Finds the value in the range (start,limit) of the largest element (rank) where the count of all smaller elements in that range is less than or equals target. 4 IntRange represents an inclusive range of ints. 5 LongRange represents an inclusive range of longs. 6 Byte Range 7 NumberRange represents an inclusive range of java.lang.Number objects of the same type. 8 Represents a range of Number objects. 9 A range of integers. 10 Value Range generic structure 11 Long Range 12 Class for storing start and end integer offsets. 13 Integer Sequence Generator 14 A numerical interval