Class: DataSumz::Describer
- Inherits:
-
Object
- Object
- DataSumz::Describer
- Defined in:
- lib/datasumz/describer.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#describe ⇒ Object
def compute_mad.
-
#initialize(_data) ⇒ Describer
constructor
A new instance of Describer.
Constructor Details
#initialize(_data) ⇒ Describer
Returns a new instance of Describer.
10 11 12 |
# File 'lib/datasumz/describer.rb', line 10 def initialize(_data) @data = _data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
6 7 8 |
# File 'lib/datasumz/describer.rb', line 6 def data @data end |
Instance Method Details
#describe ⇒ Object
def compute_mad
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/datasumz/describer.rb', line 47 def describe stats = {} stats[:count] = @data.size stats[:mean] = @data.mean stats[:sd] = @data.sd stats[:min] = @data.min stats[:max] = @data.max stats[:median] = @data.median stats[:mad] = compute_mad stats[:iqr] = compute_iqr stats[:cv] = stats[:sd] / stats[:mean].abs stats[:skewness] = compute_skewness stats[:kurtosis] = compute_kurtosis return stats end |