kalman_filter 1.0.0 → 1.0.1

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/kalman_filter.rb +34 -0
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 41d63902ccc5b6ca64c0c9087b2603370704b688
4
- data.tar.gz: e40bfa7caf38d1eb8040cabd9868992807a06de5
3
+ metadata.gz: 6c4b3976d3b07286969b8350f3029a4300f77a77
4
+ data.tar.gz: 617798d1c294226485061d108d17dd93c8645d67
5
5
  SHA512:
6
- metadata.gz: 208467abcba8e3b36ea1c0982edac1b4fcccb5d17491b93e9ebe0b527314137519482c463922180b074b14c4bcd1861be26ae0a08b8186faf093880361cf1489
7
- data.tar.gz: ce9bf2e4f39950f14066227ce2cac7a28adb15c426ca9323d241b7a07f392da7ed1604b6a2768d88c095e64f8f34a156794bef01c9f0fe14498426f7488477d9
6
+ metadata.gz: e96ddfd3266cee546820f139a36c1cb859520ea94ffad17df994ecce5fa2d7f35ff4cf658a0a76c995b3b17b4cd9f501a88ca44dcdec247e7e39006e0ca2f475
7
+ data.tar.gz: bb3a7ff982382c2d90bb7c6e863529f7467466acb2a05c769df0d524666431b0f160932d6eb3f6ed6b6d192e8e50c7e9672b095162d51aa0707242fbf7f57ee6
@@ -1,11 +1,39 @@
1
+ # A Ruby implimentation of a Kalman Filter, linear quadratic estimator.
2
+ # Noisy sensor data, approximations in the equations that
3
+ # describe the system evolution, and external factors that are not accounted
4
+ # for all place limits on how well it is possible to determine the system's
5
+ # state. The Kalman filter deals effectively with the uncertainty due to
6
+ # noisy sensor data and to some extent also with random external factors.
7
+ # The Kalman filter produces an estimate of the state of the system as an
8
+ # average of the system's predicted state and of the new measurement using a
9
+ # weighted average. The purpose of the weights is that values with better
10
+ # (i.e., smaller) estimated uncertainty are "trusted" more. The weights
11
+ # are calculated from the covariance, a measure of the estimated uncertainty
12
+ # of the prediction of the system's state. The result of the weighted
13
+ # average is a new state estimate that lies between the predicted and
14
+ # measured state, and has a better estimated uncertainty than either alone.
15
+ # This process is repeated at every time step, with the new estimate and its
16
+ # covariance informing the prediction used in the following iteration. This
17
+ # means that the Kalman filter works recursively and requires only the last
18
+ # "best guess", rather than the entire history, of a system's state to
19
+ # calculate a new state.
20
+ #
21
+ # Author:: Joseph J. Viscomi (mailto:jjviscomi@gmail.com)
22
+ # License:: MIT
23
+
1
24
  class KalmanFilter
2
25
  attr_writer :process_noise, :measurement_noise, :state_vector,
3
26
  :control_vector, :measurement_vector
4
27
 
28
+ # Returns the current value of the KalmanFilter.
5
29
  attr_reader :value
6
30
 
31
+ # Returns the last value supplied to the KalmanFilter.
7
32
  attr_accessor :measurement
8
33
 
34
+ # Creates a new KalmanFilter
35
+ # Params:
36
+ # +options+:: +Object+
9
37
  def initialize(options={})
10
38
  @covariance = nil
11
39
  @value = nil
@@ -16,9 +44,15 @@ class KalmanFilter
16
44
  @measurement_noise = (options[:measurement_noise] || 1.0)
17
45
  @state_vector = (options[:state_vector] || 1.0)
18
46
  @control_vector = (options[:control_vector] || 0.0)
47
+
19
48
  @measurement_vector = (options[:measurement_vector] || 1.0)
20
49
  end
21
50
 
51
+ # Updates the KalmanFilter with a new measurement.
52
+ # Params:
53
+ # +new_measurement+:: +Float+ the measurement to update the filter with
54
+ # +control+:: +Number+ optional control variable that corresponds to control_vector
55
+ # Returns: the updated value of the KalmanFilter
22
56
  def measurement=(new_measurement, control = 0.0)
23
57
  @measurement = new_measurement
24
58
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kalman_filter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joseph Viscomi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-06 00:00:00.000000000 Z
11
+ date: 2016-11-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |-
14
14
  Noisy sensor data, approximations in the equations that
@@ -47,7 +47,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
47
47
  requirements:
48
48
  - - ">="
49
49
  - !ruby/object:Gem::Version
50
- version: '0'
50
+ version: 1.9.3
51
51
  required_rubygems_version: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - ">="