# Path: simplestatistics/statistics/gamma_function.py
# def gamma_function(x, decimals=6):
#     """
#     The gamma function is an extension of the factorial function for all
#     positive integers. It is a common component in many probability
#     distributions (e.g., the beta distribution).
# 
#     The probability density function (PDF) for integers is defined as:
# 
#     .. math::
#         \\Gamma(n) = (n - 1)!
# 
#     Whereas for decimals/fractions we use Stirling's approximation:
# 
#     .. math::
#          \\Gamma(x) \\approx \\sqrt{\\frac{2\\pi}{x}} \\bigg{(}\\frac{1}{e}
#          \\bigg{(}x + \\frac{1}{12z - \\frac{1}{10z}} \\bigg{)}\\bigg{)}^x
# 
#     Args:
#         x: Non-negative int or float or list of ints or floats representing
#            values for which the Gamma function probability density function
#            values are desired.
#         decimals: (optional) number of decimal points (default is 6)
# 
#     Returns:
#        Int or float (or list of ints or floats) representing the Gamma function
#        probability density function values for x or each value in x.
# 
#     Examples:
#         >>> gamma_function(6)
#         120
#         >>> gamma_function(1.2, decimals=2)
#         0.92
#         >>> gamma_function([6, 8, 10, 12])
#         [120, 5040, 362880, 39916800]
#         >>> gamma_function((3, 4))
#         [2, 6]
#         >>> gamma_function([3, .5], decimals=2)
#         [2, 1.76]
#         >>> gamma_function(-.5)
#         Traceback (most recent call last):
#             ...
#         ValueError: gamma_function is only defined for non-negative values.
#     """
# 
#     if type(x) in [list, tuple]:
#         results = []
#         for value in x:
#             results.append(gamma_function(value, decimals=decimals))
# 
#         return(results)
#     elif type(x) is float:
#         if x < 0:
#             raise ValueError('gamma_function is only defined for non-negative values.')
# 
#         return(round(calculate_gamma_pdf(x), decimals))
#     elif type(x) is int:
#         return(factorial(x - 1))


from .gamma_function import gamma_function
"""
Implements beta() distribution function.
"""


def calculate_beta_pdf(x, _alpha, _beta):
    """
    Helper function to calculate Beta PDF for value x.
    """

    numerator = (pow(x, _alpha - 1) * pow(1 - x, _beta - 1))

    denominator = (gamma_function(_alpha, decimals=9) *

# Path: simplestatistics/statistics/gamma_function.py
# def gamma_function(x, decimals=6):
#     """
#     The gamma function is an extension of the factorial function for all
#     positive integers. It is a common component in many probability
#     distributions (e.g., the beta distribution).
# 
#     The probability density function (PDF) for integers is defined as:
# 
#     .. math::
#         \\Gamma(n) = (n - 1)!
# 
#     Whereas for decimals/fractions we use Stirling's approximation:
# 
#     .. math::
#          \\Gamma(x) \\approx \\sqrt{\\frac{2\\pi}{x}} \\bigg{(}\\frac{1}{e}
#          \\bigg{(}x + \\frac{1}{12z - \\frac{1}{10z}} \\bigg{)}\\bigg{)}^x
# 
#     Args:
#         x: Non-negative int or float or list of ints or floats representing
#            values for which the Gamma function probability density function
#            values are desired.
#         decimals: (optional) number of decimal points (default is 6)
# 
#     Returns:
#        Int or float (or list of ints or floats) representing the Gamma function
#        probability density function values for x or each value in x.
# 
#     Examples:
#         >>> gamma_function(6)
#         120
#         >>> gamma_function(1.2, decimals=2)
#         0.92
#         >>> gamma_function([6, 8, 10, 12])
#         [120, 5040, 362880, 39916800]
#         >>> gamma_function((3, 4))
#         [2, 6]
#         >>> gamma_function([3, .5], decimals=2)
#         [2, 1.76]
#         >>> gamma_function(-.5)
#         Traceback (most recent call last):
#             ...
#         ValueError: gamma_function is only defined for non-negative values.
#     """
# 
#     if type(x) in [list, tuple]:
#         results = []
#         for value in x:
#             results.append(gamma_function(value, decimals=decimals))
# 
#         return(results)
#     elif type(x) is float:
#         if x < 0:
#             raise ValueError('gamma_function is only defined for non-negative values.')
# 
#         return(round(calculate_gamma_pdf(x), decimals))
#     elif type(x) is int:
#         return(factorial(x - 1))


# Path: simplestatistics/statistics/beta.py
from .gamma_function import gamma_function

"""
Implements beta() distribution function.
"""


def calculate_beta_pdf(x, _alpha, _beta):
    """
    Helper function to calculate Beta PDF for value x.
    """

    numerator = (pow(x, _alpha - 1) * pow(1 - x, _beta - 1))

    denominator = (gamma_function(_alpha, decimals=9) *

                   gamma_function(_beta, decimals=9)) / gamma_function(_alpha + _beta, decimals=9)