<s> from __future__ import print_function , division <EOL> from sympy . stats . drv import SingleDiscreteDistribution , SingleDiscretePSpace <EOL> from sympy import factorial , exp , S , sympify <EOL> from sympy . stats . rv import _value_check <EOL> __all__ = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> def rv ( symbol , cls , * args ) : <EOL> args = list ( map ( sympify , args ) ) <EOL> dist = cls ( * args ) <EOL> dist . check ( * args ) <EOL> return SingleDiscretePSpace ( symbol , dist ) . value <EOL> class PoissonDistribution ( SingleDiscreteDistribution ) : <EOL> _argnames = ( '<STR_LIT>' , ) <EOL> set = S . Naturals0 <EOL> @ staticmethod <EOL> def check ( lamda ) : <EOL> _value_check ( lamda > <NUM_LIT:0> , "<STR_LIT>" ) <EOL> def pdf ( self , k ) : <EOL> return self . lamda ** k / factorial ( k ) * exp ( - self . lamda ) <EOL> def Poisson ( name , lamda ) : <EOL> r"""<STR_LIT>""" <EOL> return rv ( name , PoissonDistribution , lamda ) <EOL> class GeometricDistribution ( SingleDiscreteDistribution ) : <EOL> _argnames = ( '<STR_LIT:p>' , ) <EOL> set = S . Naturals <EOL> @ staticmethod <EOL> def check ( p ) : <EOL> _value_check ( <NUM_LIT:0> < p and p <= <NUM_LIT:1> , "<STR_LIT>" ) <EOL> def pdf ( self , k ) : <EOL> return ( <NUM_LIT:1> - self . p ) ** ( k - <NUM_LIT:1> ) * self . p <EOL> def Geometric ( name , p ) : <EOL> r"""<STR_LIT>""" <EOL> return rv ( name , GeometricDistribution , p ) </s>
