-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
72 additions
and
17 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
.../main/java/net/laprun/sustainability/power/measure/DescriptiveStatisticsMeasureStore.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package net.laprun.sustainability.power.measure; | ||
|
||
import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; | ||
|
||
class DescriptiveStatisticsMeasureStore implements MeasureStore { | ||
private final DescriptiveStatistics[] measures; | ||
private final DescriptiveStatistics total; | ||
|
||
public DescriptiveStatisticsMeasureStore(int componentsNumber, int initialWindow) { | ||
total = new DescriptiveStatistics(initialWindow); | ||
this.measures = new DescriptiveStatistics[componentsNumber]; | ||
for (int i = 0; i < measures.length; i++) { | ||
measures[i] = new DescriptiveStatistics(initialWindow); | ||
} | ||
} | ||
|
||
@Override | ||
public void recordComponentValue(int component, double value) { | ||
measures[component].addValue(value); | ||
} | ||
|
||
@Override | ||
public void recordTotal(double value) { | ||
total.addValue(value); | ||
} | ||
|
||
@Override | ||
public double getMeasuredTotal() { | ||
return total.getSum(); | ||
} | ||
|
||
@Override | ||
public double getComponentStandardDeviation(int component) { | ||
return measures[component].getStandardDeviation(); | ||
} | ||
|
||
@Override | ||
public double getTotalStandardDeviation() { | ||
return total.getStandardDeviation(); | ||
} | ||
|
||
@Override | ||
public double[] getComponentRawValues(int component) { | ||
return measures[component].getValues(); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
measure/src/main/java/net/laprun/sustainability/power/measure/MeasureStore.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package net.laprun.sustainability.power.measure; | ||
|
||
interface MeasureStore { | ||
void recordComponentValue(int component, double value); | ||
|
||
void recordTotal(double value); | ||
|
||
double getMeasuredTotal(); | ||
|
||
double getComponentStandardDeviation(int component); | ||
|
||
double getTotalStandardDeviation(); | ||
|
||
double[] getComponentRawValues(int component); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters