# Path: simplestatistics/statistics/factorial.py
# def factorial(x):
#     """
#     The factorial_ (denoted :math:`n!`) is the product of all positive
#     integers less than or equal to a positive integer (:math:`n`).
# 
#     .. _factorial: https://en.wikipedia.org/wiki/Factorial
# 
#     Equation:
#         .. math::
#             n! = \\prod_{k=1}^n k
# 
#     Args:
#         x: A numeric built-in object, or a list of numeric built-in objects for :math:`n`
# 
#     Returns:
#         A numerical (int) object.
# 
#     Examples:
# 
#         >>> factorial(5)
#         120
#         >>> factorial(1)
#         1
#         >>> factorial(20)
#         2432902008176640000
#         >>> factorial([1, 5, 20])
#         [1, 120, 2432902008176640000]
# 
#         >>> factorial(-2)
#         Traceback (most recent call last):
#             ...
#         ValueError: factorial() expects a positive integer.
#         >>> factorial(4.5)
#         Traceback (most recent call last):
#             ...
#         TypeError: factorial() expects a positive integer or list of positive integers.
#         >>> factorial([2, 3, 'a'])
#         Traceback (most recent call last):
#             ...
#         ValueError: Perhaps you provided a list that contains non-integers.
#     """
# 
#     if type(x) is int:
#         if x < 0:
#             raise ValueError('factorial() expects a positive integer.')
# 
#         return(obtain_factorial(x))
#     elif type(x) is list:
#         try:
#             products = []
#             for element in x:
#                 products.append(obtain_factorial(element))
# 
#             return(products)
#         except:
#             raise ValueError('Perhaps you provided a list that contains non-integers.')
#     else:
#         raise TypeError('factorial() expects a positive integer or list of positive integers.')


import math # to use math.e to get Euler's number
from .factorial import factorial
        decimals: (optional) number of decimal points (default is 4)

    Returns:
        A value or list of values for the probability(ies) of observing the one
        or more provided *k* values given provided *lamda*.

    Examples:
        >>> poisson(3, 3)
        0.224
        >>> poisson(3, [0, 1, 2, 3])
        [0.0498, 0.1494, 0.224, 0.224]
        >>> poisson(5.5, 7)
        0.1234

        >>> poisson(-3)
        Traceback (most recent call last):
            ...
        ValueError: lambda has to be a positive value.

    """
    if lam <= 0:
        raise ValueError('lambda has to be a positive value.')

    if type(k) is int:
        p = (pow(math.e, -lam) * pow(lam, k)) / factorial(k)
        return(round(p, decimals))

    elif type(k) is list:
        ps = []
        for kx in k:

# Path: simplestatistics/statistics/factorial.py
# def factorial(x):
#     """
#     The factorial_ (denoted :math:`n!`) is the product of all positive
#     integers less than or equal to a positive integer (:math:`n`).
# 
#     .. _factorial: https://en.wikipedia.org/wiki/Factorial
# 
#     Equation:
#         .. math::
#             n! = \\prod_{k=1}^n k
# 
#     Args:
#         x: A numeric built-in object, or a list of numeric built-in objects for :math:`n`
# 
#     Returns:
#         A numerical (int) object.
# 
#     Examples:
# 
#         >>> factorial(5)
#         120
#         >>> factorial(1)
#         1
#         >>> factorial(20)
#         2432902008176640000
#         >>> factorial([1, 5, 20])
#         [1, 120, 2432902008176640000]
# 
#         >>> factorial(-2)
#         Traceback (most recent call last):
#             ...
#         ValueError: factorial() expects a positive integer.
#         >>> factorial(4.5)
#         Traceback (most recent call last):
#             ...
#         TypeError: factorial() expects a positive integer or list of positive integers.
#         >>> factorial([2, 3, 'a'])
#         Traceback (most recent call last):
#             ...
#         ValueError: Perhaps you provided a list that contains non-integers.
#     """
# 
#     if type(x) is int:
#         if x < 0:
#             raise ValueError('factorial() expects a positive integer.')
# 
#         return(obtain_factorial(x))
#     elif type(x) is list:
#         try:
#             products = []
#             for element in x:
#                 products.append(obtain_factorial(element))
# 
#             return(products)
#         except:
#             raise ValueError('Perhaps you provided a list that contains non-integers.')
#     else:
#         raise TypeError('factorial() expects a positive integer or list of positive integers.')


# Path: simplestatistics/statistics/poisson.py
import math # to use math.e to get Euler's number
from .factorial import factorial

        decimals: (optional) number of decimal points (default is 4)

    Returns:
        A value or list of values for the probability(ies) of observing the one
        or more provided *k* values given provided *lamda*.

    Examples:
        >>> poisson(3, 3)
        0.224
        >>> poisson(3, [0, 1, 2, 3])
        [0.0498, 0.1494, 0.224, 0.224]
        >>> poisson(5.5, 7)
        0.1234

        >>> poisson(-3)
        Traceback (most recent call last):
            ...
        ValueError: lambda has to be a positive value.

    """
    if lam <= 0:
        raise ValueError('lambda has to be a positive value.')

    if type(k) is int:
        p = (pow(math.e, -lam) * pow(lam, k)) / factorial(k)
        return(round(p, decimals))

    elif type(k) is list:
        ps = []
        for kx in k:

            p = (pow(math.e, -lam) * pow(lam, kx)) / factorial(kx)