Skip to content

Commit

Permalink
Incorporate continuous methods into TrendsQueryRunner
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbachhuber committed Dec 19, 2024
1 parent 78af92d commit 54f989e
Showing 1 changed file with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
calculate_credible_intervals_v2_count,
calculate_probabilities_v2_count,
)
from posthog.hogql_queries.experiments.trends_statistics_v2_continuous import (
are_results_significant_v2_continuous,
calculate_credible_intervals_v2_continuous,
calculate_probabilities_v2_continuous,
)
from posthog.hogql_queries.insights.trends.trends_query_runner import TrendsQueryRunner
from posthog.hogql_queries.query_runner import QueryRunner
from posthog.models.experiment import Experiment
Expand Down Expand Up @@ -316,9 +321,18 @@ def run(query_runner: TrendsQueryRunner, result_key: str, is_parallel: bool):
# Statistical analysis
control_variant, test_variants = self._get_variants_with_base_stats(count_result, exposure_result)
if self.stats_version == 2:
probabilities = calculate_probabilities_v2_count(control_variant, test_variants)
significance_code, p_value = are_results_significant_v2_count(control_variant, test_variants, probabilities)
credible_intervals = calculate_credible_intervals_v2_count([control_variant, *test_variants])
if self.query.count_query.series[0].math:
probabilities = calculate_probabilities_v2_continuous(control_variant, test_variants)
significance_code, p_value = are_results_significant_v2_continuous(
control_variant, test_variants, probabilities
)
credible_intervals = calculate_credible_intervals_v2_continuous([control_variant, *test_variants])
else:
probabilities = calculate_probabilities_v2_count(control_variant, test_variants)
significance_code, p_value = are_results_significant_v2_count(
control_variant, test_variants, probabilities
)
credible_intervals = calculate_credible_intervals_v2_count([control_variant, *test_variants])
else:
probabilities = calculate_probabilities(control_variant, test_variants)
significance_code, p_value = are_results_significant(control_variant, test_variants, probabilities)
Expand Down

0 comments on commit 54f989e

Please sign in to comment.