Class: DataSumz::Describer

Inherits:
Object
  • Object
show all
Defined in:
lib/datasumz/describer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#dataObject (readonly)

Returns the value of attribute data.



6
7
8
# File 'lib/datasumz/describer.rb', line 6

def data
  @data
end

Instance Method Details

#describeObject

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