experiments

Estimate the recommended sample size and running time for an experiment.

Pure statistical calculation — does not read or write any experiment. Pass the metric type, a minimum detectable effect, and either a baseline value or raw baseline statistics. When exposure_rate_per_day is provided, the response also includes the estimated running time in days.

post/api/projects/{project_id}/experiments/calculate_running_time/

Request

  • Base URL: https://us.posthog.com
  • URL: https://us.posthog.com/api/projects/{project_id}/experiments/calculate_running_time/
  • Auth: HTTP bearer

Path parameters

project_idstring required

Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.

Request body

metric_type'funnel' | 'mean_count' | 'mean_sum_or_avg' | 'ratio' | 'retention' required
  • funnel - funnel
  • mean_count - mean_count
  • mean_sum_or_avg - mean_sum_or_avg
  • ratio - ratio
  • retention - retention
minimum_detectable_effectnumber double required

Smallest relative change to detect, as a percentage (e.g. 5 means a 5% lift). Must be > 0.

number_of_variantsinteger

Total number of variants including control (default 2).

exposure_rate_per_daynumber double nullable

Expected exposures per day. When provided, the response includes the recommended running time.

baseline_valuenumber double nullable

Baseline metric value: conversion rate as a fraction 0-1 (funnel), average per user (mean), or the ratio (ratio/retention). Provide this or baseline_stats.

variancenumber double nullable

Pre-computed variance for ratio/retention metrics. Provide this or baseline_stats when metric_type is ratio/retention and baseline_value is given directly.

Response

baseline_valuenumber double nullable required

Baseline metric value used in the calculation (echoed or derived from stats).

variancenumber double nullable required

Variance used in the calculation; null for funnel metrics (implicit in p(1-p)).

recommended_sample_sizeinteger nullable required

Total recommended sample size across all variants. Null if inputs are insufficient.

recommended_running_time_daysinteger nullable required

Estimated days to reach the recommended sample size. Null when exposure_rate_per_day is omitted.

Changes

No recorded changes to this operation across all 1 revision of this API.