Estimate the sample size and duration of an A/B test

Given the traffic percentage and the expected effect size, this endpoint estimates the sample size and duration of an A/B test based on historical traffic.

Usage

Required ACL: analytics
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import algoliasearch.api.AbtestingClient
import algoliasearch.config.*

val client = AbtestingClient(
  appId = "ALGOLIA_APPLICATION_ID",
  apiKey = "ALGOLIA_API_KEY",
  region = Option("ALGOLIA_APPLICATION_REGION")
)

val response = client.estimateABTest(
  estimateABTestRequest = EstimateABTestRequest(
    configuration = EstimateConfiguration(
      emptySearch = Some(
        EmptySearch(
          exclude = Some(true)
        )
      ),
      minimumDetectableEffect = MinimumDetectableEffect(
        size = 0.03,
        metric = EffectMetric.withName("conversionRate")
      )
    ),
    variants = Seq(
      AbTestsVariant(
        index = "AB_TEST_1",
        trafficPercentage = 50
      ),
      AbTestsVariant(
        index = "AB_TEST_2",
        trafficPercentage = 50
      )
    )
  )
)
Did you find this page helpful?