digiproc 0.2.2 → 0.2.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c9c8f01ef0e56ad304bbb90500c0ab281830ab6bd910a0e273321a82b5010833
4
- data.tar.gz: 5f735eceae2fa7befd2bc8d336392854684c439c6b6e8960f060d990cd9d3cdb
3
+ metadata.gz: 98ad341617d6bad6da8c0ae3df8e7945ba5fa0c36bdd32105cf534c2c38d7c46
4
+ data.tar.gz: 80aef379ca9404a7d933ddf60c2bdc0505cca846f9f77113fbedd873f8d6daad
5
5
  SHA512:
6
- metadata.gz: 7c696eb3ec8e8af5c69f266260da6a93364870b41662bbc1872f6e6def0a4a55fb7ae196a3ee914d09a6550e04cd99bcf0c8f7d328614d2059e6aab65c40b15f
7
- data.tar.gz: 44872c96607bab2b4ef37581e695c24a94790b722712278b9c36b56f90ed781a1ba026b5058f5e17c7aa32b050c7854a7134614007b1cae1b8abb1881ff0784f
6
+ metadata.gz: 9cc7c2af6116b87b1e4d986353c49cd1f3870bae200ab145f398d803156f41aebf6306648dda04e6e85362c80cbd1a8e9b5fb106b5b357f91b882b740fdf86eb
7
+ data.tar.gz: e361ae5dc52504398a1beb2699ab681b4bbe6cf109a8f93a427753069ceac3fe78ac6465c06f1bb6669e18fb94bc4cdda823beeb4e7add671f4ea3a60d4fe63c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- digiproc (0.2.2)
4
+ digiproc (0.2.3)
5
5
  bundler
6
6
  gruff (~> 0.7.0)
7
7
 
@@ -46,4 +46,4 @@ DEPENDENCIES
46
46
  rspec (~> 3.0)
47
47
 
48
48
  BUNDLED WITH
49
- 2.0.1
49
+ 2.0.2
@@ -1,6 +1,6 @@
1
1
 
2
2
  require "bundler/setup"
3
-
3
+ require 'BigDecimal'
4
4
  require 'gruff'
5
5
 
6
6
  require 'matrix'
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Digiproc
3
- VERSION = "0.2.2"
3
+ VERSION = "0.2.3"
4
4
  end
5
5
 
6
6
 
@@ -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.to_f
17
- @k = k.to_f
18
- @p = p.to_f
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.to_f * (Digiproc::Functions.fact(self.n - k)))
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.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-06-10 00:00:00.000000000 Z
11
+ date: 2019-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler