davidrichards-just_enumerable_stats 0.0.19 → 0.0.21
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/VERSION.yml +1 -1
- data/lib/just_enumerable_stats.rb +6 -3
- data/spec/just_enumerable_stats_spec.rb +6 -1
- metadata +2 -2
data/VERSION.yml
CHANGED
@@ -819,13 +819,16 @@ module Enumerable
|
|
819
819
|
safe_alias :_jes_scale_to_sigmoid!
|
820
820
|
|
821
821
|
def _jes_normalize
|
822
|
-
|
822
|
+
min = self._jes_min
|
823
|
+
diff = self._jes_max - min
|
824
|
+
self.map {|e| (e - min) / diff }
|
823
825
|
end
|
824
826
|
safe_alias :_jes_normalize
|
825
827
|
|
826
828
|
def _jes_normalize!
|
827
|
-
|
828
|
-
|
829
|
+
min = self._jes_min
|
830
|
+
diff = self._jes_max - min
|
831
|
+
self.map! {|e| (e - min) / diff }
|
829
832
|
end
|
830
833
|
safe_alias :_jes_normalize!
|
831
834
|
|
@@ -635,10 +635,15 @@ describe "JustEnumerableStats" do
|
|
635
635
|
|
636
636
|
it "should be able to normalize a list" do
|
637
637
|
b = @a.normalize
|
638
|
-
b.should eql([
|
638
|
+
b.should eql([0, 1/2, 1])
|
639
639
|
@a.normalize!
|
640
640
|
@a.should eql(b)
|
641
641
|
end
|
642
|
+
|
643
|
+
it "should normalize a list with repeating values" do
|
644
|
+
a = [1,2,3,2,1]
|
645
|
+
a.normalize.should eql([0, 1/2, 1, 1/2, 0])
|
646
|
+
end
|
642
647
|
|
643
648
|
context "scale_between" do
|
644
649
|
before do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: davidrichards-just_enumerable_stats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Richards
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-09-
|
12
|
+
date: 2009-09-14 00:00:00 -07:00
|
13
13
|
default_executable: jes
|
14
14
|
dependencies: []
|
15
15
|
|