---
title: "有哪些方法可以帮助AB测试显著更快一些？"
slug: "20211020-zhihu-answer-2180958313"
url: "https://ranchen.org/content/20211020-zhihu-answer-2180958313"
markdown_url: "https://ranchen.org/content/20211020-zhihu-answer-2180958313.md"
createdAt: "2021-10-20T17:18:18-07:00"
updatedAt: "2021-10-20T17:18:19-07:00"
authors: ["陈然"]
source: "zhihu"
sourceType: "answer"
topics: ["ai"]
tags: []
readingTime: "3 分钟"
sources:
  - platform: "zhihu"
    type: "answer"
    url: "https://www.zhihu.com/question/487925004/answer/2180958313"
---

# 有哪些方法可以帮助AB测试显著更快一些？

方法是有不少的，比较常见的一个方向是做方差缩减（Variance Reduction[1]）。这里分享一篇来自 Netflix KDD 2016 年的文章 [Improving the Sensitivity of Online Controlled Experiments: Case Studies at Netflix](https://link.zhihu.com/?target=https%3A//www.kdd.org/kdd2016/papers/files/adp0945-xieA.pdf)。

## 方差缩减（Variance Reduction）

最常见的AB测试的数据分布比较都是如下图，而不显著的核心原因之一就是方差太大。如果有办法能够降低方差，那实验结果自然更容易显著一些。

![](https://ranchen.org/content-assets/zhihu/answer-2180958313/image-001.jpg)

https://towardsdatascience.com/online-experiments-tricks-variance-reduction-291b6032dcd7

## CUPED（Controlled-experiment using pre-experiment data）

Netflix 的论文中提到了几种方法：Stratified Sampling，Post Stratification，CUPED[2]。在实践中提到 CUPED 的效果最好，所以这里一块看看。

![](https://ranchen.org/content-assets/zhihu/answer-2180958313/image-002.jpg)

https://booking.ai/how-booking-com-increases-the-power-of-online-experiments-with-cuped-995d186fff1d

这种方法实现起来非常容易，首先找一个协变量（Covariate），在下图中，如果我们实验的观测变量是每周酒店订阅（bookings-per-week），那我们的协变量就是用户开始实验前的那周的每周酒店订阅。

![](https://ranchen.org/content-assets/zhihu/answer-2180958313/image-003.jpg)

https://booking.ai/how-booking-com-increases-the-power-of-online-experiments-with-cuped-995d186fff1d

如果我们把对于用户的每个数据的这两个值画在坐标轴上，那么我们会得到一个近似关于中心对称的点集合，毕竟一般试验前数据大的用户，实验中的指标数据也会大。控制组的数据应该几乎完全对称，因为实验几乎没有改变什么。

![](https://ranchen.org/content-assets/zhihu/answer-2180958313/image-004.jpg)

有了这个直觉，我们就可以通过数学表达式把坐标轴进行转换，此时数据对应的方差会比原来小很多。

![](https://ranchen.org/content-assets/zhihu/answer-2180958313/image-005.jpg)

![](https://ranchen.org/content-assets/zhihu/answer-2180958313/image-006.jpg)

https://booking.ai/how-booking-com-increases-the-power-of-online-experiments-with-cuped-995d186fff1d

数学的表达式也很简单：

> CUPED-adjusted metric = metric - (covariate - mean(covariate)) x theta
> theta = covariance(metric, covariate) / variance(covariate)

具体公式和代码实现可以参见 Booking 的博客，几行就能搞定 [How Booking.com increases the power of online experiments with CUPED](https://link.zhihu.com/?target=https%3A//booking.ai/how-booking-com-increases-the-power-of-online-experiments-with-cuped-995d186fff1d)。

## CUPED 的效果

在 Netflix 的实践中，CUPED 的效果非常好，大概可以降低 40% 的方差。这可以极大加快AB的显著。

![](https://ranchen.org/content-assets/zhihu/answer-2180958313/image-007.jpg)

对于这个方向感兴趣的同学还有一篇博客写的更通俗易懂一些，里面有介绍不同的方法和其对应的实现 [Online Experiments Tricks — Variance Reduction](https://link.zhihu.com/?target=https%3A//towardsdatascience.com/online-experiments-tricks-variance-reduction-291b6032dcd7) 。
