Class: Modesty::Experiment::Stat

Inherits:
Object
  • Object
show all
Defined in:
lib/modesty/experiment/stats.rb

Direct Known Subclasses

ConversionStat, DistributionStat

Instance Method Summary collapse

Constructor Details

#initialize(exp, name, options = {}, &blk) ⇒ Stat

Returns a new instance of Stat.



70
71
72
73
74
# File 'lib/modesty/experiment/stats.rb', line 70

def initialize(exp, name, options={}, &blk)
  @exp = exp
  @name = name
  @get_data = blk || default_get_data(options[:on])
end

Instance Method Details

#report(*args) ⇒ Object



80
81
82
83
84
85
86
87
88
89
# File 'lib/modesty/experiment/stats.rb', line 80

def report(*args)
  sig = significance(*args)
  sig = "not significant" if sig.nil?
  return <<-report

    === #{title} ===
    #{analysis(*args).inspect}
    Significance: #{sig}
  report
end

#significant?(tolerance = 0.01) ⇒ Boolean

Returns:

  • (Boolean)


91
92
93
94
# File 'lib/modesty/experiment/stats.rb', line 91

def significant?(tolerance=0.01)
  sig = self.significance
  !sig.nil? && sig <= tolerance
end

#titleObject



76
77
78
# File 'lib/modesty/experiment/stats.rb', line 76

def title
  @name.to_s.split(/_/).map(&:capitalize).join(' ')
end