mixle.data.exchangeability module¶
Exchangeability diagnostics for fitted and synthetic-data workflows.
Fitting one distribution to a dataset, or synthesizing “more rows like these”, assumes that row order does not carry information. When the data has a trend or a regime shift, that assumption is false and a pooled marginal model can misrepresent the process.
exchangeability_check() tests the assumption with numeric probes: a
permutation test for rank correlation between value and row position, plus a
first-half/second-half location-shift test. The aggregate label is one of:
exchangeable: no order signal found at the tested level;trend: value co-moves with position;shift: the halves differ in location.
mixle.inference.create() and mixle.inference.synthesize() record
the verdict in provenance so downstream consumers can see when pooling deserves
review.
- class ExchangeabilityReport(label, fields=<factory>)[source]
Bases:
objectThe verdict per numeric field, plus the aggregate label the preconditions record.
- label: str
- property exchangeable: bool
- exchangeability_check(data, *, alpha=0.01, n_perm=200, seed=0)[source]
Test whether row ORDER carries information (see module docstring). Small n -> exchangeable (no power).
alphais deliberately strict (0.01): the check should flag clear violations, not manufacture warnings from noise. Non-numeric-only data passes vacuously (order tests need a numeric surface).