analytica 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.txt CHANGED
@@ -1,5 +1,13 @@
1
1
  === 0.0.5 / 2010-08-03
2
2
 
3
+ * 3 enhancements
4
+
5
+ * Cleaned up some of the computation implementation
6
+ * Analytica::DataSet can now has a default constructor (empty DataSet)
7
+ * alias_method is now being correctly used
8
+
9
+ === 0.0.5 / 2010-08-03
10
+
3
11
  * 1 major enhancement
4
12
 
5
13
  * Birthday!
data/lib/analytica.rb CHANGED
@@ -4,7 +4,7 @@ require File.join(File.dirname(__FILE__), 'analytica_comp')
4
4
  require File.join(File.dirname(__FILE__), 'analytica_viz')
5
5
 
6
6
  module Analytica
7
- VERSION = '0.0.5'
7
+ VERSION = '0.0.6'
8
8
 
9
9
  include Strict
10
10
 
@@ -12,7 +12,7 @@ module Analytica
12
12
  include Computation
13
13
  include Visualization
14
14
 
15
- def initialize(datapoints)
15
+ def initialize(datapoints=[])
16
16
  enforce!(:numeric_array, datapoints)
17
17
 
18
18
  super datapoints
@@ -12,10 +12,6 @@ module Computation
12
12
  sum.to_f / size
13
13
  end
14
14
 
15
- def lma(params)
16
- linear_moving_average(params)
17
- end
18
-
19
15
  def linear_moving_average(params)
20
16
  enforce_map!({
21
17
  :bias => [:last, :first],
@@ -31,7 +27,7 @@ module Computation
31
27
  raise "Bias not legally set!"
32
28
  end
33
29
 
34
- raise "too few samples available to calculate lma at given :samples input" if params[:samples] > size
30
+ params[:samples] = [params[:samples], data.size]
35
31
 
36
32
  n = params[:samples] + 1
37
33
  numerator = 0.0
@@ -47,9 +43,7 @@ module Computation
47
43
  numerator / denominator
48
44
  end
49
45
 
50
- def ema(params)
51
- exponential_moving_average(params)
52
- end
46
+ alias_method :lma, :linear_moving_average
53
47
 
54
48
  def exponential_moving_average(params)
55
49
  enforce_map!({
@@ -57,6 +51,8 @@ module Computation
57
51
  :decay_bias => [:latest, :oldest],
58
52
  :decay_coefficent => :float}, params)
59
53
 
54
+ raise "ema not yet implemented!"
55
+
60
56
  if params[:decay_bias] == :latest
61
57
  data = self
62
58
  else
@@ -65,10 +61,8 @@ module Computation
65
61
  0.0
66
62
  end
67
63
 
68
- def dydx(n=1)
69
- piecewise_derivative(n)
70
- end
71
-
64
+ alias_method :ema, :exponential_moving_average
65
+
72
66
  def piecewise_derivative(n=1)
73
67
  enforce!(:natural_number, n)
74
68
 
@@ -91,6 +85,8 @@ module Computation
91
85
  DataSet.new(d)
92
86
  end
93
87
 
88
+ alias_method :dydx, :piecewise_derivative
89
+
94
90
  def savitzky_golay(n=1)
95
91
  enforce!(:natural_number, n)
96
92
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: analytica
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Raeez Lorgat