算法艺术创作
algorithmic-art
通过代码和可调参数创作生成艺术与交互式视觉效果。
product-ab-testing【设计与创意】Use this skill when designing and analyzing A/B tests: hypothesis formation, experiment design, statistical analysis, and decision framework. This skill enforces: hypothesis structure, sample size calculation, statistical significance, AA test validation. Do NOT use for: multivariate testing, bandit algorithms, personalization engines, survey analysi…
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Designs and analyzes A/B tests with rigorous hypothesis formation, experiment design, statistical frameworks, and decision criteria.
Exact user phrases: A/B test, split test, experiment, hypothesis testing, statistical significance, sample size, AA test, multivariate test, bandit, sequential testing.
Experiment design document with hypothesis, sample size calculation, statistical framework, analysis plan, and decision criteria.
## A/B Test Design
### Hypothesis
If {change} then {metric} will {direction} by {effect} because {rationale}
### Variants
Control: {current state}
Treatment: {change description}
### Statistical Framework
α = {0.05}, β = {0.20}, Power = {0.80}, MDE = {X%}
Sample Size: {N per variant}, Duration: {days}
Test Type: {two-tailed / one-tailed}
Correction: {Bonferroni / none}
### AA Test Validation
Result: {passed/failed} | p-value: {value} | Uniformity: {passed/failed}
### Results
Primary: {estimate} [{CI}] p={value} | {significant/not significant}
Guardrails: {all passed / any failed — detail}
Segments: {notable segment differences}
### Decision
{implement / roll back / iterate} | Confidence: {level}
No preamble. No postamble. No explanations.
7000 tokens
Structure hypothesis as If/Then/Because. If {change}, then {metric} will {direction} by {effect size}, because {mechanism}. Define null hypothesis H0 (no effect, μ_treatment = μ_control) and alternative hypothesis Ha (effect exists, μ_treatment ≠ μ_control or directional).
Identify primary metric — one decision metric that determines the experiment outcome. Must be measurable, reliable, and sensitive to the change. Define secondary metrics (additional metrics of interest for understanding mechanism) and guardrail metrics (must not degrade — overall CSAT, revenue, retention, support volume).
Ensure hypothesis is falsifiable: the experiment can prove it wrong. Ground the hypothesis in user research, data analysis, or established principles — not intuition alone. Document the rationale with supporting evidence.
Define variants: control (current experience) and treatment(s) (proposed change). Limit the number of treatments to avoid sample size inflation and multiple comparison problems. For multiple treatments, apply Bonferroni correction or use a control-to-treatment allocation ratio that preserves power.
Choose randomization unit: user-level for UX changes where user experience must be consistent, session-level for funnel or flow changes where each visit is independent, event-level for algorithmic changes that affect individual page loads. The unit of randomization must match the unit of analysis.
Calculate required sample size: use α=0.05, β=0.20 (power=0.80), and MDE based on business impact and traffic constraints. Use online calculators or power analysis libraries. Account for multiple variants with corrections.
Set minimum experiment duration: at least one full business cycle (typically 7 days) to capture day-of-week effects. Avoid ending experiments on holidays or during unusual periods. Calculate duration as max(sample size / daily traffic, one business cycle).
Consider allocation ratios: 50/50 for most experiments, 90/10 for high-risk changes to limit exposure, 80/10/10 for two treatments with equal power.
Configure significance level α=0.05 (5% false positive risk). For high-stakes decisions (revenue, retention, safety), use α=0.01. For exploratory tests, α=0.10 may be acceptable.
Set statistical power β=0.20 (80% chance to detect the specified MDE if it exists). Higher power (90%) for critical experiments where missing a real effect is costly.
Determine MDE based on business impact: what effect size would make implementation worthwhile? Smaller MDE requires larger sample sizes. Balance statistical requirements with traffic and time constraints.
Use two-tailed test by default (tests for both positive and negative effects). One-tailed test only when there is strong prior evidence that the effect can only go in one direction and the opposite direction is not actionable.
Apply sequential testing (group sequential design) for continuous monitoring with pre-specified interim analysis points. Use alpha spending functions to maintain overall error rate. Do not use traditional p-value monitoring without correction.
Run AA test before any treatment experiment. Split traffic equally between two identical variants (both receive control experience). Verify no statistically significant difference between the two groups.
Check that p-value distribution is uniform across many AA tests: run repeated AA tests and verify that p-values follow a uniform distribution (5% should be below 0.05). Confirm the experimentation system is not biased — consistent assignment, no data leakage, proper randomization.
Document AA test results: p-value, effect size, confidence interval, any metrics with significant differences. If AA test fails, investigate the root cause: randomization bug, data pipeline issue, sample ratio mismatch, instrumentation error. Fix before proceeding.
Randomize users with consistent assignment (user ID hashing, cookie-based assignment, or deterministic function). Ensure assignment is stable — user stays in same variant for the experiment duration.
Monitor guardrail metrics daily. Automated alerts for significant negative impact on guardrails. Do not stop experiment early based on primary metric peeking — only stop early for guardrail violations or futility (pre-specified stopping rules).
Run analysis at predetermined end time. Do not extend the experiment after peeking at results. If results are inconclusive, plan a follow-up experiment with larger sample size or different design.
Check assumptions: normality (use CLT for large samples, non-parametric tests for small), equal variance (use Welch's t-test if violated), independence (account for user clustering, repeated measures), no sample ratio mismatch (check expected vs. observed sample sizes per variant).
Calculate p-value (probability of observing data as extreme as seen, assuming H0 is true). Calculate confidence interval (range of plausible effect sizes consistent with data). Report both.
Segment results by device, source, plan, region, and other pre-specified segments. Apply correction for multiple segment comparisons. Interpret segment results cautiously — smaller sample sizes per segment reduce power and increase false positive risk.
Implement if p<α and effect size exceeds MDE, and no guardrail metric degraded. Confidence is high when results are statistically significant at p<0.01, practically significant (effect > 2x MDE), consistent across segments, and robust to sensitivity analysis.
Roll back if any guardrail metric shows statistically significant degradation. Even if primary metric improves, guardrail violations may cause net negative impact. Investigate root cause before re-testing.
Iterate if results are inconclusive: p>α but direction is promising (effect in expected direction but not significant). Consider extending the experiment (only if pre-specified), increasing sample size, or refining the treatment.
Consider secondary metrics and segment analysis in decision. A negative effect on a secondary metric may offset primary metric improvement. A positive effect concentrated in one segment may inform targeted rollout.
Document learnings: hypothesis, design, results, decision, and what was learned about user behavior. Share with the team. Include analysis code for reproducibility.
Standard approach for A/B testing. Null hypothesis significance testing (NHST) with p-values and confidence intervals. Pros: widely understood, computationally simple, well-established conventions. Cons: p-values are easily misinterpreted, no direct statement about probability of hypotheses being true, problematic with continuous monitoring.
Key elements: pre-specified α and β, MDE-based sample size calculation, two-tailed tests by default, p-value threshold for significance, confidence intervals for effect size estimates. Report both statistical significance and practical significance.
Alternative approach that estimates the probability distribution of the effect size. Produces directly interpretable statements: "There is a 95% probability that the treatment improves conversion by 2-5%."
Key elements: prior distribution (informative or uninformative), likelihood function (based on observed data), posterior distribution (updated belief), credible intervals (Bayesian analog of confidence intervals), probability of superiority (Pr(treatment > control)), expected loss.
Pros: interpretable results, natural handling of sequential monitoring, incorporates prior information, no p-value misinterpretation. Cons: requires specifying prior (subjective), computationally more intensive, less widely understood in organizations.
Multiple interim analyses with pre-specified stopping rules that maintain overall error rate. Use alpha spending functions (Pocock, O'Brien-Fleming, Haybittle-Peto) to distribute α across analyses.
Stopping rules: early stop for superiority (treatment clearly better), early stop for futility (treatment clearly not better), early stop for harm (guardrail violation). Pre-specify all stopping rules before experiment launch.
Bonferroni correction: divide α by number of comparisons. Simplest and most conservative. Use for 2-5 comparisons where false positives are costly.
Benjamini-Hochberg (FDR control): control false discovery rate rather than familywise error rate. Less conservative. Use for many comparisons where some false positives are acceptable. Common for segment analysis.
Closed testing procedure: hierarchical testing where overall null must be rejected before testing sub-hypotheses. Powerful for multiple treatment vs. control comparisons.
Split traffic between two identical variants. Verify no statistically significant difference. Key validation of experiment infrastructure. Run before first experiment on a platform, after significant infrastructure changes, and quarterly for ongoing validation.
Expected behavior: p-values follow uniform distribution. Effect sizes are centered at zero with variance proportional to sample size. Sample ratio is approximately 50/50 (or the specified ratio). Any deviation indicates infrastructure issues.
Checking p-values repeatedly during the experiment and stopping when significance is reached. Dramatically inflates false positive rate. A p-value of 0.05 means 5% false positive rate at a single look. With daily peeking, the effective false positive rate can reach 30-50%. Mitigation: pre-specify experiment duration. Use sequential testing if interim looks are needed. Never stop an experiment early based on primary metric results.
Observed sample sizes in variants deviate significantly from expected ratios. Indicates randomization failure, data pipeline issues, or assignment bugs. SRM invalidates experiment results because the groups may not be comparable. Mitigation: check SRM before analyzing results. Use chi-squared test for expected vs. observed ratios. Investigate and fix root cause before proceeding.
Running many analyses (multiple metrics, multiple segments, multiple looks) without adjusting significance thresholds. Inflates false positive rate — with 20 independent metrics, at least one will show p<0.05 by chance. Mitigation: designate a single primary metric. Apply correction for secondary and segment analyses. Pre-specify all analyses before launch.
Users respond positively to a change simply because it is new. Effect diminishes over time as novelty wears off. Can lead to implementing changes that have no long-term benefit. Mitigation: run experiments long enough for novelty to wear off (minimum 2 weeks for significant UX changes). Compare early-period vs. late-period effect. Use holdout groups for long-term measurement.
Existing users prefer the familiar experience and react negatively to change even if the new experience is objectively better. New users who have no baseline show the true treatment effect. Mitigation: segment results by new vs. existing users. Run experiments long enough for existing users to adapt. Consider gradual rollouts for existing users.
Analyzing results and then deciding which segments "count" based on the results. Data dredging. Invalidates statistical inference. Mitigation: pre-specify all segments and inclusion/exclusion criteria before experiment launch.
Implementing changes that are statistically significant but practically meaningless. A 0.1% conversion improvement may be statistically significant with large sample sizes but not worth implementation cost. Mitigation: set MDE before the experiment based on business impact. Do not implement effects smaller than MDE regardless of p-value.
Aggregate results show one direction but segment results show the opposite. Caused by uneven segment distribution across variants. Mitigation: check segment balance across variants. Pre-specify stratification variables. Analyze results with and without stratification.
Hypothesis: If we {change} for {target segment} at {location}, then {primary metric} will {increase/decrease} by {effect size} because {rationale}.
H0: μ_treatment = μ_control (no effect)
Ha: μ_treatment ≠ μ_control (two-tailed)
Supporting Evidence: {user research, analytics data, case studies}
## Experiment: {Name}
### Hypothesis
{hypothesis statement}
### Variants
Control: {description}
Treatment: {description}
### Metrics
Primary: {metric} — {definition and measurement details}
Secondary: {metrics} — {definitions}
Guardrails: {metrics} — {definitions}
### Design
Randomization Unit: {user / session / event}
Allocation: {ratio per variant}
Target Population: {inclusion and exclusion criteria}
Segments: {pre-specified segment analyses}
### Statistical Parameters
α = {value}
β = {value}
Power = {value}
MDE = {value} ({absolute or relative})
Expected Baseline = {value}
Expected Variance = {value}
Minimum Sample Size = {N per variant}
Expected Duration = {days}
### Stopping Rules
Early stop for superiority: {rule}
Early stop for futility: {rule}
Early stop for harm: {rule}
### Risks
{risks and mitigations}
Parameters:
- Baseline conversion rate: {p}
- Minimum detectable effect: {MDE absolute or relative}
- Significance level (α): {0.05}
- Statistical power (1-β): {0.80}
- Test type: {two-tailed}
- Number of variants: {k}
Output:
- Sample size per variant: {n}
- Total sample size: {N = n × k}
- Minimum duration: {N / daily traffic} days
- With 1 business cycle minimum: {max(N/daily traffic, 7)} days
## AA Test Report
### Configuration
Start date: {date}
End date: {date}
Sample size per variant: {n}
Metrics tested: {list}
### Results
| Metric | Control Mean | Variant Mean | Difference | CI | p-value |
|--------|-------------|-------------|------------|-----|---------|
| {m1} | {v1} | {v2} | {d} | {ci}| {p} |
| {m2} | {v1} | {v2} | {d} | {ci}| {p} |
SRM check: χ² = {value}, p = {value} — {passed/failed}
P-value distribution check: {uniform/non-uniform}
### Verdict
{passed / failed — investigation needed}
## Experiment Results
### Overview
Experiment: {name}
Duration: {start} to {end}
Sample size: {control N} / {treatment N}
### Primary Metric
Result: {estimate} [{CI}] p = {value}
Significance: {p < α / p > α}
Practical significance: {effect > MDE / effect < MDE}
### Secondary Metrics
| Metric | Estimate | CI | p-value | Significant? |
|--------|---------|-----|---------|-------------|
| {m1} | {e} | {ci}| {p} | {yes/no} |
### Guardrail Metrics
| Metric | Estimate | CI | p-value | Degraded? |
|--------|---------|-----|---------|----------|
| {m1} | {e} | {ci}| {p} | {yes/no} |
### Segment Analysis
| Segment | Control | Treatment | Diff | CI | p-value |
|---------|---------|----------|------|-----|---------|
| {s1} | {v1} | {v2} | {d} | {ci}| {p} |
### Decision
{implement / roll back / iterate}
Rationale: {reasoning}
Date: {date}
Experiment: {name}
Hypothesis: {hypothesis}
Result: {implemented / rolled back / inconclusive}
What we learned: {key insights about user behavior}
What surprised us: {unexpected findings}
What we would do differently: {improvements for next experiment}
Next steps: {follow-up experiments, implementation plan}
A B2B SaaS company tested monthly vs. annual pricing emphasis on their pricing page. Hypothesis: emphasizing annual pricing (featuring annual first, showing savings) would increase annual subscription rate without reducing overall conversion.
Design: Control — monthly and annual presented equally. Treatment — annual plan featured first with savings callout, monthly below fold. Primary metric: annual subscription rate. Secondary: overall conversion rate, average revenue per conversion. Guardrails: page conversion rate, bounce rate.
Result: annual subscription rate increased 34% (p<0.001). Overall conversion rate unchanged (p=0.32). Average revenue per conversion increased 22%. Guardrails all passed. Decision: implement. Additional revenue: $1.4M annually.
Key learning: users respond to anchoring — presenting the higher-value option first shifts preference. No negative impact on overall conversion suggests annual is not perceived as worse, just needs visibility.
E-commerce app tested single-page vs. multi-step mobile checkout. Hypothesis: single-page checkout reduces friction on mobile and increases completion rate by reducing page loads and visual breaks.
Design: Control — current 3-step checkout (cart → shipping → payment → review). Treatment — single-page checkout with accordion sections. Primary metric: checkout completion rate. Secondary: time to complete, error rate. Guardrails: average order value, return rate.
Result: single-page increased completion rate 18% (p=0.003). Time to complete decreased 31%. Error rate decreased 22%. No change in AOV or return rate. Decision: implement.
Segment analysis: effect was concentrated on mobile users (24% improvement) vs. tablet users (5%, not significant). New users benefited more (27%) than returning users (12%).
SaaS product tested onboarding email sequence timing. Hypothesis: delaying the second onboarding email from 24 hours to 72 hours after signup reduces early unsubscribes without reducing activation rate.
Design: Control — emails at Day 0, 1, 3, 7. Treatment — emails at Day 0, 3, 7, 14. Primary metric: 30-day activation rate. Secondary: email unsubscribe rate, feature discovery rate. Guardrails: support ticket volume.
Result: treatment group had 29% lower unsubscribe rate (p=0.008). 30-day activation rate was unchanged (p=0.41). Feature discovery shifted later but total adoption at 30 days was similar. Support tickets unchanged. Decision: implement.
Key learning: users need time to explore before receiving feature emails. Fewer, better-timed emails improve engagement without harming activation.
Productivity app tested placement of a new collaboration feature. Hypothesis: placing the collaboration button in the main toolbar (always visible) instead of the share menu (2 clicks away) increases collaboration feature adoption.
Design: Control — collaboration button in share menu. Treatment — collaboration button in main toolbar. Primary metric: weekly collaboration feature users. Secondary: collaboration actions per user, feature discovery rate. Guardrails: main UI engagement metrics, error rate.
Result: weekly collaboration users increased 41% (p<0.001). Actions per user increased 23%. No guardrail degradation. Decision: implement.
Segment analysis: effect was driven by new users (67% increase) more than existing users (18%). Existing users had established habits — the toolbar placement was less noticeable.
An experimentation platform failed its AA test: one variant showed 3.2% conversion vs. 3.8% in the other (p=0.04). Investigation revealed a client-side caching issue: users assigned to Variant B received cached control content 15% of the time, diluting the observed effect.
Fix: invalidated caches on experiment launch, added cache-busting parameters, and implemented server-side assignment verification. AA test passed on re-run. This case demonstrates why AA tests must precede every significant experiment.
For product analytics event tracking to inform metrics, hand off to product-analytics. For user research insights to inform hypotheses, hand off to product-user-research. For customer journey touchpoints to test, hand off to product-customer-journey. For growth metric experiment design, hand off to product-growth-engineering.
` interface EventObserver { onEvent(event: T): Promise; }
class EventBus { private observers: Set<EventObserver> = new Set(); subscribe(observer: EventObserver): void { this.observers.add(observer); } unsubscribe(observer: EventObserver): void { this.observers.delete(observer); } async emit(event: T): Promise { const results = Array.from(this.observers).map(o => o.onEvent(event)); await Promise.allSettled(results); } } `
config: defaults: timeout: 30s retryCount: 3 overrides: production: timeout: 60s retryCount: 5 development: timeout: 300s retryCount: 1
| Metric | Threshold | Severity | Action |
|---|---|---|---|
| Error rate | > 1% over 5min | Critical | Page on-call |
| p99 latency | > 2s over 5min | Warning | Investigate |
| Throughput drop | > 50% over 1min | Critical | Check upstream |
| Queue depth | > 1000 over 1min | Warning | Scale consumers |
| Disk usage | > 85% | Warning | Clean or expand |
| Memory usage | > 90% heap | Critical | Restart or scale |
| Anti-Pattern | Symptom | Root Cause | Solution |
|---|---|---|---|
| Premature optimization | Complex code for no measured benefit | Guessing instead of profiling | Measure first, optimize based on data |
| Copy-paste reuse | Duplicate code across codebase | Lack of abstraction | Extract shared logic into libraries |
| Gold-plating | Features with no current requirement | Over-engineering | YAGNI — build what's needed now |
| Magical thinking | Assumptions without validation | Skipping error handling | Handle all failure modes explicitly |
Cache hierarchy: L1 (in-memory local) → L2 (distributed Redis/Memcached) → L3 (CDN/Edge). Cache invalidation: TTL-based (simple, stale), event-based (complex, fresh), write-through (consistent, higher write latency), write-behind (fast writes, eventual consistency).