Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(experiments): running time calculator for continuous #29316

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

jurajmajerik
Copy link
Contributor

@jurajmajerik jurajmajerik commented Feb 27, 2025

Changes

Implement sample size / running time calculation for continuous metrics.

Cross-checked with: https://docs.google.com/spreadsheets/d/11alyC8n7uqewZFLKfV4UAbW-0zH__EdV_Hrk2OQ4140/edit?gid=2067479228#gid=2067479228

image

How did you test this code?

  • Added a logic test

@jurajmajerik jurajmajerik requested a review from a team February 27, 2025 16:53
@jurajmajerik jurajmajerik marked this pull request as draft February 27, 2025 17:03
@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

6 snapshot changes in total. 0 added, 6 modified, 0 deleted:

  • chromium: 0 added, 6 modified, 0 deleted (diff for shard 3)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@jurajmajerik jurajmajerik marked this pull request as ready for review February 28, 2025 10:40
@jurajmajerik jurajmajerik requested review from a team and removed request for a team February 28, 2025 10:40
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

Added support for continuous metrics in the experiment running time calculator, enabling users to estimate experiment duration for property-based metrics alongside count metrics.

  • Added variance calculation for continuous metrics using VARIANCE_SCALING_FACTOR_CONTINUOUS * averagePropertyValuePerUser ** 2 in /frontend/src/scenes/experiments/RunningTimeCalculator/runningTimeCalculatorLogic.tsx
  • Modified query building to fetch property sum data for continuous metrics with PropertyMathType.Sum
  • Updated UI in RunningTimeCalculatorModal.tsx to conditionally display property value metrics for continuous experiments
  • Added comprehensive test coverage in runningTimeCalculatorLogic.test.ts that validates calculations against reference spreadsheet values

3 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +97 to +98
math_property: metric.metric_config.math_property,
math_property_type: TaxonomicFilterGroupType.NumericalEventProperties,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider adding a null check for metric.metric_config.math_property as it's used directly without verification.

Copy link
Contributor

github-actions bot commented Feb 28, 2025

Size Change: 0 B

Total Size: 9.73 MB

ℹ️ View Unchanged
Filename Size
frontend/dist/toolbar.js 9.73 MB

compressed-size-action

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

10 snapshot changes in total. 0 added, 10 modified, 0 deleted:

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

2 snapshot changes in total. 0 added, 2 modified, 0 deleted:

  • chromium: 0 added, 2 modified, 0 deleted (diff for shard 1)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

2 snapshot changes in total. 0 added, 2 modified, 0 deleted:

  • chromium: 0 added, 2 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.


return ((16 * variance) / ((minimumDetectableEffect / 100) * standardDeviation) ** 2) * numberOfVariants
return ((16 * variance) / (minimumDetectableEffectDecimal * standardDeviation) ** 2) * numberOfVariants
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

variance = standardDeviation ** 2, so effectively this cancels out in this calculation.
So it simplifies to (16 / MDE ** 2) * numberOfVariants. So variance has no effect on the calculation.

Is that intentional?

I think it would be good with some comments in this function as well to explain how it works. F.ex, where does 16 come from?

~{humanFriendlyNumber(averagePropertyValuePerUser, 0)}
</div>
</div>
)}
<div>
<div className="card-secondary">Estimated variance</div>
<div className="font-semibold">~{humanFriendlyNumber(variance, 0)}</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think maybe it's more meaningful to show standard deviation to the user, as it has a much more intuitive meaning

@andehen
Copy link
Contributor

andehen commented Feb 28, 2025

Really like the new calculator! 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants