-
Notifications
You must be signed in to change notification settings - Fork 35
Tidy up Statistics calculations with abstract StatisticsHelper class #436
Copy link
Copy link
Open
Description
As a suggested refactoring, having a new abstract class inherited by all Statistics calculators could assist in collating repeated steps in a tidy way.
I've experimented with this in https://github.com/centreformicrosimulation/SimPaths/blob/feature/193-update-labour-supply-estimates-with-uc-flag/src/main/java/simpaths/data/statistics/StatisticsHelper.java but this may need review and formal restructuring to be included in main branches.
This feasibly allows calculation of routine sets of statistics in a tidy manner, e.g.:
// mcs score
CrossSection.Double personsMCS = new CrossSection.Double(model.getPersons(), Person.DoublesVariables.Dhe_mcs);
personsMCS.setFilter(filter);
// Calculate and set mean in one line
setDhe_mcs_mean(calculateMean(personsMCS));
// Calculate and set percentiles and medians in one line
calculateAndSetPercentiles(personsMCS, this::setDhe_mcs_p_10, this::setDhe_mcs_p_25, this::setDhe_mcs_median, this::setDhe_mcs_p_75, this::setDhe_mcs_p_90);
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels