Class: Laboratory::Experiment::AnalysisSummary

Inherits:
Object
  • Object
show all
Defined in:
lib/laboratory/experiment/analysis_summary.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(experiment, event_id) ⇒ AnalysisSummary

Returns a new instance of AnalysisSummary.



6
7
8
9
# File 'lib/laboratory/experiment/analysis_summary.rb', line 6

def initialize(experiment, event_id)
  @experiment = experiment
  @event_id = event_id
end

Instance Attribute Details

#event_idObject (readonly)

Returns the value of attribute event_id.



4
5
6
# File 'lib/laboratory/experiment/analysis_summary.rb', line 4

def event_id
  @event_id
end

#experimentObject (readonly)

Returns the value of attribute experiment.



4
5
6
# File 'lib/laboratory/experiment/analysis_summary.rb', line 4

def experiment
  @experiment
end

Instance Method Details

#confidence_level_in_performance_deltaObject



27
28
29
30
31
32
33
34
# File 'lib/laboratory/experiment/analysis_summary.rb', line 27

def confidence_level_in_performance_delta
  Laboratory::Calculations::ConfidenceLevel.calculate(
    n1: participant_count_for_variant(lowest_performing_variant),
    p1: event_total_count_for_variant(lowest_performing_variant),
    n2: participant_count_for_variant(highest_performing_variant),
    p2: event_total_count_for_variant(highest_performing_variant)
  )
end

#highest_performing_variantObject



11
12
13
# File 'lib/laboratory/experiment/analysis_summary.rb', line 11

def highest_performing_variant
  sorted_variants.first
end

#lowest_performing_variantObject



15
16
17
# File 'lib/laboratory/experiment/analysis_summary.rb', line 15

def lowest_performing_variant
  sorted_variants.last
end

#performance_delta_between_highest_and_lowestObject



19
20
21
22
23
24
25
# File 'lib/laboratory/experiment/analysis_summary.rb', line 19

def performance_delta_between_highest_and_lowest
  numerator =
    (conversion_rate_for_variant(highest_performing_variant) -
      conversion_rate_for_variant(lowest_performing_variant))
  denominator = conversion_rate_for_variant(lowest_performing_variant)
  numerator.fdiv(denominator).round(2)
end