causalis.shared.srm.NumberNumber
None
Python Docs
causalis
Package entry
causalisRoot package overview and namespace mapNamespaces
causalis.shared.srmSubmodule causalis.shared.srm with no child pages and 12 documented members.
Classes
Jump directly into the documented classes for this page.
Functions
Jump directly into the documented functions for this page.
Data
Jump directly into the documented data for this page.
causalis.shared.srm.NumberNone
causalis.shared.srm.SRMResultResult of a Sample Ratio Mismatch (SRM) check.
Attributes
The calculated chi-square statistic.
The p-value of the test, rounded to 5 decimals.
Expected counts for each variant.
Observed counts for each variant.
Significance level used for the check.
True if an SRM was detected (chi-square p-value < alpha), False otherwise.
Warning message if the test assumptions might be violated (e.g., small expected counts).
causalis.shared.srm.SRMResult.chi2None
causalis.shared.srm.SRMResult.p_valueNone
causalis.shared.srm.SRMResult.expectedNone
causalis.shared.srm.SRMResult.observedNone
causalis.shared.srm.SRMResult.alphaNone
causalis.shared.srm.SRMResult.is_srmNone
causalis.shared.srm.SRMResult.warningNone
causalis.shared.srm.SRMResult.__repr__causalis.shared.srm.check_srmCheck Sample Ratio Mismatch (SRM) for an RCT via a chi-square goodness-of-fit test.
Parameters
Observed variant assignments. If iterable or Series, elements are labels per unit (user_id, session_id, etc.). If CausalData is provided, the treatment column is used. If a mapping is provided, it is treated as {variant: observed_count} with non-negative integer counts.
Mapping {variant: p} describing intended allocation as probabilities.
Significance level. Use strict values like 1e-3 or 1e-4 in production.
If any expected count < min_expected, a warning is attached.
- True: fail if observed variants differ from target keys. - False: drop unknown variants and test only on declared ones.
Returns
The result of the SRM check.
Raises
If inputs are invalid or empty. ImportError If scipy is required but not installed.
Notes
Target allocation probabilities must sum to 1 within numerical tolerance.
is_srm is computed using the unrounded p-value; the returned
p_value is rounded to 5 decimals.
Missing assignments are dropped and reported via warning.
Requires SciPy for p-value computation.
Examples
Canonical target
causalis.shared.srm.check_srm
Sections
causalis.shared.srm.__all__[‘SRMResult’, ‘check_srm’]