}
private void checkSequence(final GenericRiskStatistics stat, final String name, int dimension) {
final GenericSequenceStatistics ss = new GenericSequenceStatistics(dimension);
/*@Size*/ int i;
for (i = 0; i<data.size(); i++) {
Array temp = new Array(dimension);
temp.fill(data.get(i));
ss.add(temp, weights.get(i));
}
Array calculated;
/*@Real*/ double expected, tolerance;
if (ss.samples() != data.size())
fail("SequenceStatistics<" + name + ">: "
+ "wrong number of samples\n"
+ " calculated: " + ss.samples() + "\n"
+ " expected: " + data.size());
expected = weights.accumulate(0.0);
if (ss.weightSum() != expected)
fail("SequenceStatistics<" + name + ">: "
+ "wrong sum of weights\n"
+ " calculated: " + ss.weightSum() + "\n"
+ " expected: " + expected);
expected = data.min();
calculated = ss.min();
for (i=0; i<dimension; i++) {
if (calculated.get(i) != expected)
fail("SequenceStatistics<" + name + ">: "
+ (i+1) + " dimension: "
+ "wrong minimum value\n"
+ " calculated: " + calculated.get(i) + "\n"
+ " expected: " + expected);
}
expected = data.max();
calculated = ss.max();
for (i=0; i<dimension; i++) {
if (calculated.get(i) != expected)
fail("SequenceStatistics<" + name + ">: "
+ (i+1) + " dimension: "
+ "wrong maximun value\n"
+ " calculated: " + calculated.get(i) + "\n"
+ " expected: " + expected);
}
expected = 4.3;
tolerance = 1.0e-9;
calculated = ss.mean();
for (i=0; i<dimension; i++) {
if (Math.abs(calculated.get(i)-expected) > tolerance)
fail("SequenceStatistics<" + name + ">: "
+ (i+1) + " dimension: "
+ "wrong mean value\n"
+ " calculated: " + calculated.get(i) + "\n"
+ " expected: " + expected);
}
expected = 2.23333333333;
calculated = ss.variance();
for (i=0; i<dimension; i++) {
if (Math.abs(calculated.get(i)-expected) > tolerance)
fail("SequenceStatistics<" + name + ">: "
+ (i+1) + " dimension: "
+ "wrong variance\n"
+ " calculated: " + calculated.get(i) + "\n"
+ " expected: " + expected);
}
expected = 1.4944341181;
calculated = ss.standardDeviation();
for (i=0; i<dimension; i++) {
if (Math.abs(calculated.get(i)-expected) > tolerance)
fail("SequenceStatistics<" + name + ">: "
+ (i+1) + " dimension: "
+ "wrong standard deviation\n"
+ " calculated: " + calculated.get(i) + "\n"
+ " expected: " + expected);
}
expected = 0.359543071407;
calculated = ss.skewness();
for (i=0; i<dimension; i++) {
if (Math.abs(calculated.get(i)-expected) > tolerance)
fail("SequenceStatistics<" + name + ">: "
+ (i+1) + " dimension: "
+ "wrong skewness\n"
+ " calculated: " + calculated.get(i) + "\n"
+ " expected: " + expected);
}
expected = -0.151799637209;
calculated = ss.kurtosis();
for (i=0; i<dimension; i++) {
if (Math.abs(calculated.get(i)-expected) > tolerance)
fail("SequenceStatistics<" + name + ">: "
+ (i+1) + " dimension: "
+ "wrong kurtosis\n"