Class: ScbiNArray

Inherits:
NArray
  • Object
show all
Defined in:
lib/scbi_math/scbi_narray.rb

Instance Method Summary collapse

Instance Method Details

#fat_mode(window_size = 10) ⇒ Object

fat mode calculates mode based on accumulated frequency with a window_size



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/scbi_math/scbi_narray.rb', line 42

def fat_mode(window_size=10)

  fat_modes=[]
  max_fat=0

  self.length.times do |i|
    fat=get_window_value(i)

    fat_modes << fat

    if fat_modes[max_fat] < fat
      max_fat=i
    end

  end
  # puts "algo",max_fat
  return [max_fat,fat_modes[max_fat]]
end

#mad_meanObject

mean absolute deviation



6
7
8
9
10
11
12
# File 'lib/scbi_math/scbi_narray.rb', line 6

def mad_mean
  me = self.mean
  mad = ((self - me ).abs).mean

  return [mad,me]

end

#mad_medianObject

meadian absolute deviation



15
16
17
18
19
20
# File 'lib/scbi_math/scbi_narray.rb', line 15

def mad_median
  me = self.median
  mad = ((self - me).abs).median

  return [mad,me]
end

#stddevObject

returns stddev for length=1



23
24
25
26
27
28
29
30
31
32
# File 'lib/scbi_math/scbi_narray.rb', line 23

def stddev

  if self.length<=1
    stddev=0
  else
    stddev=super()
  end

  return stddev
end

#variance_coefficientObject

coefficient of variance



36
37
38
# File 'lib/scbi_math/scbi_narray.rb', line 36

def variance_coefficient
   return ((stddev/mean)*100)
end