Module: Statsample::Util

Defined in:
lib/statsample.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.nice(s, e) ⇒ Object

:nodoc:



238
239
240
241
242
243
244
245
246
247
248
249
# File 'lib/statsample.rb', line 238

def self.nice(s, e) # :nodoc:
  reverse = e < s
  min = reverse ? e : s
  max = reverse ? s : e
  span = max - min
  return [s, e] if span == 0 || (span.respond_to?(:infinite?) && span.infinite?)

  step = 10**((Math.log(span).quo(Math.log(10))).round - 1).to_f
  out = [(min.quo(step)).floor * step, (max.quo(step)).ceil * step]
  out.reverse! if reverse
  out
end

Instance Method Details

#normal_order_statistic_medians(i, n) ⇒ Object



227
228
229
230
231
232
233
234
235
236
# File 'lib/statsample.rb', line 227

def normal_order_statistic_medians(i, n)
  if i == 1
    u = 1.0 - normal_order_statistic_medians(n, n)
  elsif i == n
    u = 0.5**(1 / n.to_f)
  else
    u = (i - 0.3175) / (n + 0.365)
  end
  u
end