Skip to content

refactor npc and experiment; re-implement randomize_in_strata() and randomize_group(); add randomizer for paired data #224

@pbstark

Description

@pbstark

Move the two randomize functions and the Experiment class into experiment.py

Make randomize_group() and randomize_in_strata() class methods for Experiment.

Currently, randomize_in_strata() and randomize_group use cryptorandom.random_sample() as if it returns a random permutation, which it does not for some settings. Either change to using cryptorandom.random_permutation() or--preferably--draw random samples of the appropriate sizes and allocate them, to reduce the demands on the PRNG. These could be re-written to use cryptorandom.sample.random_allocation() instead. They will need to take advantage of the Experiment object's information about group sizes, stratum sizes, etc.

Add a new randomization function for paired observations, , e.g., for the before/after paired two-sample problem.
The randomizer should, for each pair, randomly assign one set of data to each of the two groups, independently across pairs.

If the data are scalars for each pair and the test statistic involves the difference, this amounts to randomizing the sign of the difference, but this is more general because each element of a pair can carry a vector of data.

Add unit tests for this functionality.

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