digiproc 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/config/environment.rb +1 -1
- data/lib/digiproc/version.rb +1 -1
- data/lib/probability/binomial_distribution.rb +8 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98ad341617d6bad6da8c0ae3df8e7945ba5fa0c36bdd32105cf534c2c38d7c46
|
4
|
+
data.tar.gz: 80aef379ca9404a7d933ddf60c2bdc0505cca846f9f77113fbedd873f8d6daad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cc7c2af6116b87b1e4d986353c49cd1f3870bae200ab145f398d803156f41aebf6306648dda04e6e85362c80cbd1a8e9b5fb106b5b357f91b882b740fdf86eb
|
7
|
+
data.tar.gz: e361ae5dc52504398a1beb2699ab681b4bbe6cf109a8f93a427753069ceac3fe78ac6465c06f1bb6669e18fb94bc4cdda823beeb4e7add671f4ea3a60d4fe63c
|
data/Gemfile.lock
CHANGED
data/config/environment.rb
CHANGED
data/lib/digiproc/version.rb
CHANGED
@@ -13,9 +13,9 @@ class Digiproc::Probability::TheoreticalBinomialDistribution
|
|
13
13
|
# k:: [Integer] (optional at initialization) Number of successes
|
14
14
|
# p:: [Numeric] Probability of success
|
15
15
|
def initialize(n: ,k: nil , p: )
|
16
|
-
@n = n
|
17
|
-
@k = k
|
18
|
-
@p = p
|
16
|
+
@n = n
|
17
|
+
@k = k
|
18
|
+
@p = p
|
19
19
|
end
|
20
20
|
|
21
21
|
##
|
@@ -66,17 +66,18 @@ class Digiproc::Probability::TheoreticalBinomialDistribution
|
|
66
66
|
karr.each do |k_val|
|
67
67
|
sum += self.coefficient(k_val) * ((self.p) ** (k_val)) * (1 - self.p) ** (n - k_val)
|
68
68
|
end
|
69
|
-
sum
|
69
|
+
sum.to_f
|
70
70
|
end
|
71
71
|
|
72
72
|
##
|
73
73
|
# Returns the binomial equation coefficient for a given number of wins, ie returns n! / (k! * (n - k)!)
|
74
74
|
# Can take an argument of `k`, which defaults to `self.k`
|
75
|
+
# Returns a BigDecimal
|
75
76
|
## bd.coefficient(4) # => 210.0
|
76
77
|
def coefficient(k = self.k)
|
77
|
-
n_fact = Digiproc::Functions.fact(self.n)
|
78
|
-
k_fact = Digiproc::Functions.fact(k)
|
79
|
-
n_fact / (k_fact
|
78
|
+
n_fact = BigDecimal(Digiproc::Functions.fact(self.n))
|
79
|
+
k_fact = BigDecimal(Digiproc::Functions.fact(k))
|
80
|
+
n_fact / (k_fact * BigDecimal((Digiproc::Functions.fact(self.n - k))))
|
80
81
|
end
|
81
82
|
|
82
83
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: digiproc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- micahshute
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|