updated example code for BAEL-1425 (#4424)
This commit is contained in:
parent
0a3d212a2a
commit
749611e314
@ -47,26 +47,28 @@ public class Histogram {
|
|||||||
|
|
||||||
private Map processRawData() {
|
private Map processRawData() {
|
||||||
|
|
||||||
List<Integer> datasetList = Arrays.asList(36, 25, 38, 46, 55, 68, 72, 55, 36, 38, 67, 45, 22, 48, 91, 46, 52, 61, 58, 55);
|
List<Integer> datasetList = Arrays.asList(
|
||||||
|
36, 25, 38, 46, 55, 68, 72,
|
||||||
|
55, 36, 38, 67, 45, 22, 48,
|
||||||
|
91, 46, 52, 61, 58, 55);
|
||||||
Frequency frequency = new Frequency();
|
Frequency frequency = new Frequency();
|
||||||
datasetList.forEach(d -> frequency.addValue(Double.parseDouble(d.toString())));
|
datasetList.forEach(d -> frequency.addValue(Double.parseDouble(d.toString())));
|
||||||
|
|
||||||
List processed = new ArrayList();
|
datasetList.stream()
|
||||||
datasetList.forEach(d -> {
|
.map(d -> Double.parseDouble(d.toString()))
|
||||||
double observation = Double.parseDouble(d.toString());
|
.distinct()
|
||||||
|
.forEach(observation -> {
|
||||||
if(processed.contains(observation))
|
|
||||||
return;
|
|
||||||
|
|
||||||
long observationFrequency = frequency.getCount(observation);
|
long observationFrequency = frequency.getCount(observation);
|
||||||
int upperBoundary = (observation > classWidth) ? Math.multiplyExact( (int) Math.ceil(observation / classWidth), classWidth) : classWidth;
|
int upperBoundary = (observation > classWidth)
|
||||||
int lowerBoundary = (upperBoundary > classWidth) ? Math.subtractExact(upperBoundary, classWidth) : 0;
|
? Math.multiplyExact( (int) Math.ceil(observation / classWidth), classWidth)
|
||||||
|
: classWidth;
|
||||||
|
int lowerBoundary = (upperBoundary > classWidth)
|
||||||
|
? Math.subtractExact(upperBoundary, classWidth)
|
||||||
|
: 0;
|
||||||
String bin = lowerBoundary + "-" + upperBoundary;
|
String bin = lowerBoundary + "-" + upperBoundary;
|
||||||
|
|
||||||
updateDistributionMap(lowerBoundary, bin, observationFrequency);
|
updateDistributionMap(lowerBoundary, bin, observationFrequency);
|
||||||
|
|
||||||
processed.add(observation);
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return distributionMap;
|
return distributionMap;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user