Skip to content

reddavis/Normalizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Normalizer

Normalizer is a tool for normalizing your data.

Installation

gem sources -a http://gemcutter.org
sudo gem install normalizer

Usage

To normalize data that you already have the min/max of:

a = Normalizer.new(:min => [0], :max => [10])
a.normalize([5])
  #=> [0.5]

b = Normalizer.new(:min => [0, 0], :max => [10, 10])
b.normalize([5, 5])
  #=> [0.5, 0.5]

To find the min/max of your current data:

data = [[0, 1, 2, 3, 4], [10, 11, 12, 13, 14]]
Normalizer.find_min_and_max(data)
  #=> [[0, 1, 2, 3, 4], [10, 11, 12, 13, 14]]

You can also use a buffer on the max/min by setting a buffer in standard deviations:

data = [[0, 0, 0, 0, 0], [10, 10, 10, 10, 10]]
Normalizer.find_min_and_max(data, :std => 3)
  #=> [[-21.2132034355964, -21.2132034355964, -21.2132034355964, -21.2132034355964, -21.2132034355964], [31.2132034355964, 31.2132034355964, 31.2132034355964, 31.2132034355964, 31.2132034355964]]

On a project I’m currently working on I need to know whether data has gone past the max/min amount:

a = Normalizer.new(:min => [0], :max => [10])
a.normalize([50])
a.breaks_boundary?
  #=> true

Thanks

David Richards (blog.tegugears.com/)

Copyright © 2009 Red Davis. See LICENSE for details.

About

Tool for normalizing data

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages