Class: Prubybility::Geometric

Inherits:
NegativeBinomial show all
Defined in:
lib/prubybility/geometric.rb

Overview

A representation of the Geometric probability distribution.

See README for example usages.

Instance Attribute Summary

Attributes inherited from NegativeBinomial

#expected_value, #k, #theta, #variance

Instance Method Summary collapse

Methods included from Combinations

choose

Constructor Details

#initialize(theta) ⇒ Geometric

Returns a new instance of Geometric.



8
9
10
# File 'lib/prubybility/geometric.rb', line 8

def initialize(theta)
  super(1, theta)
end

Instance Method Details

#p(var) ⇒ Object



12
13
14
15
16
# File 'lib/prubybility/geometric.rb', line 12

def p(var)
  # return if var < 1 && !var.is_a? Integer

  (theta) * (1 - theta)**(var - 1)
end