Method: RubyStatistics::Distribution::Poisson#cumulative_function
- Defined in:
- lib/ruby-statistics/distribution/poisson.rb
#cumulative_function(k) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ruby-statistics/distribution/poisson.rb', line 24 def cumulative_function(k) return if k < 0 || expected_number_of_occurrences < 0 k = k.to_i upper = Math.lower_incomplete_gamma_function((k + 1).floor, expected_number_of_occurrences) lower = Math.factorial(k.floor) # We need the right tail, i.e.: The upper incomplete gamma function. This can be # achieved by doing a substraction between 1 and the lower incomplete gamma function. 1 - (upper/lower.to_r) end |