コード例 #1
0
ファイル: distributions.py プロジェクト: Mystfinder/probe-2
    def __init__(self, the_lambda):
        """
           Sets the parameters for the Poisson distribution.
           the_lambda must be > 0
        """
        if the_lambda <= 0:
            raise IncorrectDistributionInicializationError()

        self.the_lambda = the_lambda
        self.mean = the_lambda
        self.variance = the_lambda
        self.median = functions.floor_function(the_lambda+1/3-0.02/the_lambda)
        self.mode = functions.floor_function(the_lambda)
        self.skewness = math.pow(the_lambda, -0.5)
        self.ex_kurtosis = math.pow(the_lambda, -1)
コード例 #2
0
ファイル: distributions.py プロジェクト: Mystfinder/probe-2
    def poisson_cdf(k, the_lambda):
        """
           Gives the value of the Poisson cumulative density function
           for the given k (k can be a whole, nonnrgative nuber)
           and the specified parameter of the Poisson distribution-
           the_lambda must be > 0.
        """
        if the_lambda <= 0:
            raise IncorrectInputError()

        A = math.exp(-the_lambda)
        index = functions.floor_function(k)
        summation = 0
        for i in range(index+1):
            summation += math.pow(the_lambda, i)/functions.factorial(i)
        return A*summation