Method: Statsample::Test#p_using_cdf

Defined in:
lib/statsample/test.rb

#p_using_cdf(cdf, tails = :both) ⇒ Object

Returns probability of getting a value lower or higher than sample, using cdf and number of tails.

  • :left : For one tail left, return the cdf

  • :right : For one tail right, return 1-cdf

  • :both : For both tails, returns 2*right_tail(cdf.abs)



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/statsample/test.rb', line 21

def p_using_cdf(cdf, tails=:both)
  tails=:both if tails==2 or tails==:two
  tails=:right if tails==1 or tails==:positive
  tails=:left if tails==:negative
  case tails
    when :left then cdf
    when :right then 1-cdf
    when :both 
      if cdf>=0.5
        cdf=1-cdf
      end
      2*cdf
  end
end