byar 0.1.0 → 0.1.1

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.
Files changed (2) hide show
  1. data/lib/byar.rb +12 -8
  2. metadata +1 -1
data/lib/byar.rb CHANGED
@@ -19,8 +19,6 @@ class Byar
19
19
  #
20
20
  Z_VALUE = 1.96
21
21
 
22
- attr_writer :z_value
23
-
24
22
  ##
25
23
  # Create new Byar approximation calculator for +obs+ observed cases
26
24
  def initialize(obs)
@@ -49,16 +47,16 @@ class Byar
49
47
 
50
48
  ##
51
49
  # Calculate lower boundary for observed cases
52
- def self.lower_bound(obs)
50
+ def self.lower_bound(obs, z_value = Z_VALUE)
53
51
  return 0 if obs == 0
54
- obs * (1 - 1.quo(9 * obs) - Z_VALUE.quo(3 * Math.sqrt(obs))) ** 3
52
+ obs * (1 - 1.quo(9 * obs) - z_value.quo(3 * Math.sqrt(obs))) ** 3
55
53
  end
56
54
 
57
55
  ##
58
56
  # Calculate upper boundary for observed cases
59
- def self.upper_bound(obs)
57
+ def self.upper_bound(obs, z_value = Z_VALUE)
60
58
  obs = obs + 1
61
- obs * (1 - 1.quo(9 * obs) + Z_VALUE.quo(3 * Math.sqrt(obs))) ** 3
59
+ obs * (1 - 1.quo(9 * obs) + z_value.quo(3 * Math.sqrt(obs))) ** 3
62
60
  end
63
61
 
64
62
  def self.z_value=(value)
@@ -84,13 +82,13 @@ class Byar
84
82
  ##
85
83
  # Give lower boundary for observed value
86
84
  def lower_bound
87
- self.class.lower_bound(@obs)
85
+ self.class.lower_bound(@obs, z_value)
88
86
  end
89
87
 
90
88
  ##
91
89
  # Give upper boundary for observed value
92
90
  def upper_bound
93
- self.class.upper_bound(@obs)
91
+ self.class.upper_bound(@obs, z_value)
94
92
  end
95
93
 
96
94
  ##
@@ -99,4 +97,10 @@ class Byar
99
97
  @z_value ||= self.class.z_value
100
98
  end
101
99
 
100
+ ##
101
+ # Set custom Z value for this Byar instance
102
+ def z_value=(value)
103
+ @z_value = value
104
+ end
105
+
102
106
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: byar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: