chris_lib 1.1.11 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 79c4ea547446df8d0379c747cdfc49c2d75a6dbca69c030fbb184addc55a35f8
4
- data.tar.gz: 964c3612a94592578ca8c5620e235f32990616fac42d26f6e5c030983b6dbd98
3
+ metadata.gz: 55f439aa3d9c69f76fe0d8e71ca2792d54a86371403c24e48a8b364216f3d1f3
4
+ data.tar.gz: aa416d12ca0916cf34d54985ad185e1bf4a49ed39befbc39b146f4c9002f1494
5
5
  SHA512:
6
- metadata.gz: f7fa67040270e0404053b52235d126e308429ab264a7d87cae17e594f80953419e971cb30443384f88ebee3d8193fd39d83ec47dca36aa883d6c86fe46162b07
7
- data.tar.gz: c2efb641ba2af31d692f3ebdef4ae6cc19c308f99ac7abc0d870d3e25365225ce4b7c7934d4a45ec550bf955beb84a8ec5a16b15a7c9d82677a54ccf3d7bed15
6
+ metadata.gz: b08c41d77e18cd3cb849f65feab716370cf0a1d5ac91bdd9a0292c82fe76e0abfa18d352ac3222472b37584fb7fc1e2d25d8e5c37f5468f08b31a562f11cee53
7
+ data.tar.gz: 17fffc4641e04f756ea8444fcc9e2234d83dc8f46c7c8c56a87fd70d73f320947e5ec1c65645ebb2e739a01736893038e2d453a0c76d41f5ad7274e8a953187f
@@ -3,7 +3,7 @@ Integer.class_eval do
3
3
  def factorial
4
4
  n = self
5
5
  if n > 20
6
- fail 'Number too large'
6
+ raise 'Number too large'
7
7
  else
8
8
  (1..n).inject {|prod, i| prod * i}
9
9
  end
@@ -34,15 +34,13 @@ end
34
34
  Array.class_eval do
35
35
  # mean of array
36
36
  def mean
37
- # s=c(7.08195525827783, 10.831582068121444, 9.288611270369554, 9.054684238411918, 12.268532229606647)
38
- # returns 9.705073
39
- fail 'Length must be greater than 0.' if length < 1
37
+ raise 'Length must be greater than 0.' if length < 1
40
38
  sum.to_f / length
41
39
  end
42
40
 
43
41
  # unbiased sample variance of array
44
42
  def var
45
- fail 'Length must be greater than 1' if length < 2
43
+ raise 'Length must be greater than 1' if length < 2
46
44
  mu = mean
47
45
  map { |v| (v**2 - mu**2) }.sum.to_f / (length - 1)
48
46
  end
@@ -69,12 +67,6 @@ Array.class_eval do
69
67
  end
70
68
  end
71
69
 
72
- def histogram
73
- k = Hash.new(0)
74
- self.each { |x| k[x] += 1 }
75
- k
76
- end
77
-
78
70
  # deep dup, takes about 20 microseconds for scores arrays
79
71
  # https://www.thoughtco.com/making-deep-copies-in-ruby-2907749
80
72
  def deep_dup
@@ -136,7 +128,7 @@ module ChrisMath
136
128
 
137
129
  def std(values)
138
130
  n = values.length
139
- fail 'n = #{n} but must be greater than 1' if n < 2
131
+ raise 'n = #{n} but must be greater than 1' if n < 2
140
132
  m = mean(values)
141
133
  sum = values.inject { |s,v| s + (v**2 - m**2)}
142
134
  sqrt(sum.to_f/(n - 1))
@@ -153,7 +145,7 @@ module ChrisMath
153
145
  end
154
146
  sum
155
147
  else
156
- fail 'Error, #{r} must be >= 0 and <= #{n}'
148
+ raise 'Error, #{r} must be >= 0 and <= #{n}'
157
149
  end
158
150
  end
159
151
 
@@ -1,3 +1,3 @@
1
1
  module ChrisLib
2
- VERSION = "1.1.11"
2
+ VERSION = "2.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chris_lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.11
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-31 00:00:00.000000000 Z
11
+ date: 2021-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv