Reference library

A/B testing & experimentation

User bucketing, experiment metrics, statistical comparison, and rollout guardrails.

2 matches
A/B testing & experimentation easy

Bonferroni Correction in Python

Applies the Bonferroni correction to a list of p-values to control the family-wise error rate when performing multiple comparisons.

statistics p-values multiple-comparisons
Python
import numpy as np

def bonferroni_correction(p_values, alpha=0.05):
    """Apply Bonferroni correction to a list of p-values."""
    n = len(p_values)
    corrected_alpha = alpha / n
    significant = [p < corrected_alpha for p in p_values]
    return corrected_alpha, significant

if __name__ == "__main__":
    # Moc…
15 0 Open
A/B testing & experimentation easy

How to Mock an Exposure Event Log Record in Python

Generate a realistic exposure event record with UUID, UTC timestamp, and risk level for testing or experimentation.

mocking events testing
Python
import uuid
from datetime import datetime, timezone


def mock_exposure_event(person_id: str, location: str, duration_minutes: int) -> dict:
    return {
        "event_id": str(uuid.uuid4()),
        "person_id": person_id,
        "location": location,
        "duration_minutes": duration_minutes,
        "timestamp…
16 0 Open

Browse by section

Each section groups closely related Python snippets.

A/B testing & experimentation — Python code examples

What you will find here

This page collects a/b testing & experimentation snippets — short, copy-ready Python you can paste into our free online IDE and run without installing anything. Each sample includes a plain-English explanation and the full source code.

Samples vs tutorials and challenges

Samples are quick reference — one concept per page. For step-by-step teaching, use our Python tutorials. To test yourself, try quizzes or coding challenges. Clean up style with the Python formatter.