Skip to content

Tidy up Statistics calculations with abstract StatisticsHelper class #436

@andrewbaxter439

Description

@andrewbaxter439

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions