Preregistration
preregistration
Preregistration specifications to prevent retrospective study optimization.
This module provides the PreregistrationCard representation. This card acts as a formalized,
cryptographically signed contract of the experimental parameters, verifying that the actual analysis
adheres strictly to the pre-planned setup (metrics, splits, sample thresholds).
| CLASS | DESCRIPTION |
|---|---|
PreregistrationCard |
Represents an immutable spec card registered prior to running the experiment. |
PreregistrationCard
Represents an immutable spec card registered prior to running the experiment.
A PreregistrationCard bundles the complete configurations of an experiment (such as primary and
secondary metrics, target statistical power, significance thresholds, and sample sizes) and
secures them against post-hoc tampering by computing a SHA-256 signature via the ExperimentRegistry.
Why Pre-registration Matters
In both clinical trials and industrial A/B testing, a common failure mode is post-hoc tampering (p-hacking, retrospective metric selection, or adjusting significance thresholds mid-run). A pre-registered card acts as an immutable ledger. Before final reports are compiled, the system validates the active analysis configuration against this card's signature.
| ATTRIBUTE | DESCRIPTION |
|---|---|
experiment_id |
Unique tracking identifier for the experiment.
TYPE:
|
spec |
Structural dictionary outlining the planned experimental parameters.
TYPE:
|
hash_signature |
Cryptographic SHA-256 hash representing the serialized
TYPE:
|
Examples:
Example
>>> spec = {"metric": "conversion_rate", "alpha": 0.05, "target_n": 10000}
>>> card = PreregistrationCard("EXP-999", spec)
>>> card.hash_signature[:8]
'88e6e885'
>>> card.verify({"metric": "conversion_rate", "alpha": 0.05, "target_n": 10000})
True
>>> card.verify({"metric": "conversion_rate", "alpha": 0.10, "target_n": 10000}) # alpha altered!
False
| PARAMETER | DESCRIPTION |
|---|---|
experiment_id
|
Unique tracking identifier for the experiment.
TYPE:
|
spec
|
Dictionary containing complete design parameters to be registered.
TYPE:
|
| METHOD | DESCRIPTION |
|---|---|
verify |
Verifies if the current spec matches the registered immutable signature. |
to_json |
Serializes the preregistration card parameters and cryptographic signature to JSON. |
Source code in src\xpyrment\plan\preregistration.py
verify
Verifies if the current spec matches the registered immutable signature.
Compares the provided specification dictionary against the original registered spec.
| PARAMETER | DESCRIPTION |
|---|---|
current_spec
|
The operational parameters dictionary currently under execution.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the current specification matches the pre-registered specification exactly, False if there is any mismatch or if the card was not properly recorded.
TYPE:
|
Source code in src\xpyrment\plan\preregistration.py
to_json
Serializes the preregistration card parameters and cryptographic signature to JSON.
| RETURNS | DESCRIPTION |
|---|---|
str
|
Indented, human-readable JSON string representing the card metadata.
TYPE:
|