use of it.angelic.mpw.model.jsonpojos.blocks.Matured in project MPW by shineangelic.
the class BlocksActivity method doApacheMath.
private SummaryStatistics doApacheMath(List<Matured> maturi) {
ArrayList<Matured> revElements = new ArrayList<>(maturi);
Collections.reverse(revElements);
long[] intervals = new long[maturi.size()];
Date prevDate = revElements.get(0).getTimestamp();
int i = 0;
// parto da 1 a calcolare il 1o intervallo
for (int t = 1; t < revElements.size(); t++) {
Date curDate = revElements.get(t).getTimestamp();
intervals[i++] = curDate.getTime() - prevDate.getTime();
prevDate = curDate;
}
// a oggi, calcolo ultimo intervallo aperto
intervals[maturi.size() - 1] = (new Date().getTime() - revElements.get(maturi.size() - 1).getTimestamp().getTime());
// Get a DescriptiveStatistics instance
SummaryStatistics stats = new SummaryStatistics();
// Add the data from the array
for (long interval : intervals) {
stats.addValue(interval);
}
return stats;
}
use of it.angelic.mpw.model.jsonpojos.blocks.Matured in project MPW by shineangelic.
the class Utils method getPoolBlockAvgReward.
private static double getPoolBlockAvgReward(List<Matured> matured) {
if (matured == null || matured.size() < 1)
return 0;
double summer = 0;
int cnt = 0;
// Add the data from the array
for (Matured m : matured) {
// sort of 'works, dunno why' thing
summer += Double.valueOf(m.getReward()) / 1000000000d;
cnt++;
}
return summer / cnt;
}
Aggregations