Class: Quantile::Quantile
- Inherits:
-
Object
- Object
- Quantile::Quantile
- Defined in:
- lib/quantile/quantile.rb
Overview
Instance Attribute Summary collapse
-
#inaccuracy ⇒ Object
readonly
Returns the value of attribute inaccuracy.
-
#quantile ⇒ Object
readonly
Returns the value of attribute quantile.
Instance Method Summary collapse
- #delta(rank, n) ⇒ Object
-
#initialize(quantile, inaccuracy) ⇒ Quantile
constructor
Create a known quantile estimator invariant.
Constructor Details
#initialize(quantile, inaccuracy) ⇒ Quantile
Create a known quantile estimator invariant.
37 38 39 40 41 42 43 |
# File 'lib/quantile/quantile.rb', line 37 def initialize(quantile, inaccuracy) @quantile = quantile @inaccuracy = inaccuracy @coefficient_i = (2.0 * inaccuracy) / (1.0 - quantile) @coefficient_ii = 2.0 * inaccuracy / quantile end |
Instance Attribute Details
#inaccuracy ⇒ Object (readonly)
Returns the value of attribute inaccuracy.
22 23 24 |
# File 'lib/quantile/quantile.rb', line 22 def inaccuracy @inaccuracy end |
#quantile ⇒ Object (readonly)
Returns the value of attribute quantile.
21 22 23 |
# File 'lib/quantile/quantile.rb', line 21 def quantile @quantile end |
Instance Method Details
#delta(rank, n) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/quantile/quantile.rb', line 45 def delta(rank, n) if rank <= (@quantile * n).floor return @coefficient_i * (n - rank) end return @coefficient_ii * rank end |