mirror of
https://github.com/apache/commons-math.git
synced 2025-02-06 18:18:56 +00:00
Tab and trailing space removal
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1060125 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b11082e6d2
commit
1148874baa
@ -424,46 +424,46 @@ public final class StatUtilsTest extends TestCase {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Run the test with the values 50 and 100 and assume standardized values
|
||||
*/
|
||||
/**
|
||||
* Run the test with the values 50 and 100 and assume standardized values
|
||||
*/
|
||||
|
||||
public void testNormalize1() {
|
||||
double sample[] = { 50, 100 };
|
||||
double expectedSample[] = { -25 / Math.sqrt(1250), 25 / Math.sqrt(1250) };
|
||||
double[] out = StatUtils.normalize(sample);
|
||||
for (int i = 0; i < out.length; i++) {
|
||||
assertEquals(out[i], expectedSample[i]);
|
||||
}
|
||||
public void testNormalize1() {
|
||||
double sample[] = { 50, 100 };
|
||||
double expectedSample[] = { -25 / Math.sqrt(1250), 25 / Math.sqrt(1250) };
|
||||
double[] out = StatUtils.normalize(sample);
|
||||
for (int i = 0; i < out.length; i++) {
|
||||
assertEquals(out[i], expectedSample[i]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Run with 77 random values, assuming that the outcome has a mean of 0 and a standard deviation of 1 with a
|
||||
* precision of 1E-10.
|
||||
*/
|
||||
/**
|
||||
* Run with 77 random values, assuming that the outcome has a mean of 0 and a standard deviation of 1 with a
|
||||
* precision of 1E-10.
|
||||
*/
|
||||
|
||||
public void testNormalize2() {
|
||||
// create an sample with 77 values
|
||||
int length = 77;
|
||||
double sample[] = new double[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
sample[i] = Math.random();
|
||||
}
|
||||
// normalize this sample
|
||||
double standardizedSample[] = StatUtils.normalize(sample);
|
||||
public void testNormalize2() {
|
||||
// create an sample with 77 values
|
||||
int length = 77;
|
||||
double sample[] = new double[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
sample[i] = Math.random();
|
||||
}
|
||||
// normalize this sample
|
||||
double standardizedSample[] = StatUtils.normalize(sample);
|
||||
|
||||
DescriptiveStatistics stats = new DescriptiveStatistics();
|
||||
// Add the data from the array
|
||||
for (int i = 0; i < length; i++) {
|
||||
stats.addValue(standardizedSample[i]);
|
||||
}
|
||||
// the calculations do have a limited precision
|
||||
double distance = 1E-10;
|
||||
// check the mean an standard deviation
|
||||
assertEquals(0.0, stats.getMean(), distance);
|
||||
assertEquals(1.0, stats.getStandardDeviation(), distance);
|
||||
DescriptiveStatistics stats = new DescriptiveStatistics();
|
||||
// Add the data from the array
|
||||
for (int i = 0; i < length; i++) {
|
||||
stats.addValue(standardizedSample[i]);
|
||||
}
|
||||
// the calculations do have a limited precision
|
||||
double distance = 1E-10;
|
||||
// check the mean an standard deviation
|
||||
assertEquals(0.0, stats.getMean(), distance);
|
||||
assertEquals(1.0, stats.getStandardDeviation(), distance);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user