Class: ABVariant

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/a_b/model/a_b_variant.rb

Instance Method Summary collapse

Instance Method Details

#confidenceObject



10
11
12
13
14
15
16
# File 'lib/a_b/model/a_b_variant.rb', line 10

def confidence
  if compute_confidence?
    cumulative_normal_distribution(z_score(self.test.control))
  else
    'n/a'
  end
end

#confidence_ok?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/a_b/model/a_b_variant.rb', line 18

def confidence_ok?
  cumulative_normal_distribution(z_score(self.test.control)) >= 0.95
end

#conversion_rateObject



22
23
24
25
26
27
28
# File 'lib/a_b/model/a_b_variant.rb', line 22

def conversion_rate
  if conversions > 0
    1.0 * conversions / visitors
  else
    0.0
  end
end

#conversion_rate_ok?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/a_b/model/a_b_variant.rb', line 30

def conversion_rate_ok?
  conversion_rate > self.test.control.conversion_rate
end

#pretty_confidenceObject



34
35
36
# File 'lib/a_b/model/a_b_variant.rb', line 34

def pretty_confidence
  pretty confidence
end

#pretty_conversion_rateObject



38
39
40
# File 'lib/a_b/model/a_b_variant.rb', line 38

def pretty_conversion_rate
  pretty conversion_rate
end

#suggested_visitorsObject



42
43
44
45
46
47
48
49
# File 'lib/a_b/model/a_b_variant.rb', line 42

def suggested_visitors
  size = sample_size(self.test.control)
  if conversion_rate == 0 || size < 100
    100
  else
    commafy size
  end
end

#suggested_visitors_ok?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/a_b/model/a_b_variant.rb', line 51

def suggested_visitors_ok?
  visitors > sample_size(self.test.control)
end

#suggested_visitors_with_commasObject



55
56
57
# File 'lib/a_b/model/a_b_variant.rb', line 55

def suggested_visitors_with_commas
  commafy suggested_visitors
end

#visitors_with_commasObject



59
60
61
# File 'lib/a_b/model/a_b_variant.rb', line 59

def visitors_with_commas
  commafy visitors
end