darkhelmet-darkext 0.5.1 → 0.5.2

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/README.rdoc CHANGED
@@ -1,4 +1,4 @@
1
- = darkext[http://github.com/darkhelmet/darkext/]
1
+ = darkext
2
2
 
3
3
  == DESCRIPTION:
4
4
 
@@ -16,6 +16,12 @@ class Numeric
16
16
  Math.sqrt(self)
17
17
  end
18
18
 
19
+ # Do some other roots
20
+ def root(n = 2)
21
+ return self.sqrt if n == 2
22
+ self ** (1 / n.to_f)
23
+ end
24
+
19
25
  # Finds the log base e of the number
20
26
  def ln
21
27
  Math::log(self)
@@ -26,3 +32,12 @@ class Numeric
26
32
  Math::log10(self)
27
33
  end
28
34
  end
35
+
36
+ class Float
37
+ EPISILON = 1e-6
38
+
39
+ # Equals for floats with tolerance
40
+ def equals?(x, tolerance = EPISOLON)
41
+ (self - x).abs < tolerance
42
+ end
43
+ end
@@ -12,6 +12,16 @@ class Array
12
12
  alias :average :mean
13
13
  alias :ave :mean
14
14
 
15
+ def harmonic_mean
16
+ self.size.to_f / self.map { |i| 1 / i.to_f }.sum
17
+ end
18
+ alias :h_mean :harmonic_mean
19
+
20
+ def geometric_mean
21
+ self.product.root(self.size)
22
+ end
23
+ alias :g_mean :geometric_mean
24
+
15
25
  # Finds the median of the array
16
26
  def median
17
27
  return nil if self.size.zero?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: darkhelmet-darkext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Huckstep
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-19 00:00:00 -08:00
12
+ date: 2009-01-12 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -19,7 +19,7 @@ dependencies:
19
19
  requirements:
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 1.2.1
22
+ version: 1.2.3
23
23
  version:
24
24
  - !ruby/object:Gem::Dependency
25
25
  name: hoe