darkhelmet-darkext 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/darkext/statistics.rb +16 -7
  2. metadata +1 -1
@@ -38,16 +38,25 @@ class Array
38
38
  map.keys.select { |x| map[x] == max }
39
39
  end
40
40
 
41
- # Finds the variance of the array
42
- def variance(dof = self.size)
43
- self.sum_of_squares.to_f / dof.to_f
41
+ # Population variance
42
+ def pvariance
43
+ self.sum_of_squares.to_f / self.size.to_f
44
44
  end
45
45
 
46
- # Finds the standard deviation of the array
47
- def deviation(dof = self.size)
48
- self.variance(dof).abs.sqrt
46
+ # Sample variance
47
+ def svariance
48
+ self.sum_of_squares.to_f / (self.size - 1).to_f
49
+ end
50
+
51
+ # Population standard deviation
52
+ def pdeviation
53
+ self.pvariance.abs.sqrt
54
+ end
55
+
56
+ # Sample standard deviation
57
+ def sdeviation
58
+ self.svariance.abs.sqrt
49
59
  end
50
- alias :stddev :deviation
51
60
 
52
61
  # Randomly samples n elements
53
62
  def sample(n = 1)
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.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Huckstep