


"""simple docstring"""

from math import factorial


def lowerCAmelCase_      (				UpperCamelCase__	: int				,   UpperCamelCase__	: int				,   UpperCamelCase__	: float ):






 """simple docstring"""







 if successes > trials:
  raise ValueError("""successes must be lower or equal to trials""" )
 if trials < 0 or successes < 0:
  raise ValueError("""the function is defined for non-negative integers""" )
 if not isinstance(UpperCamelCase__				,   UpperCamelCase__ ) or not isinstance(UpperCamelCase__				,   UpperCamelCase__ ):
  raise ValueError("""the function is defined for non-negative integers""" )
 if not 0 < prob < 1:
  raise ValueError("""prob has to be in range of 1 - 0""" )
 __lowercase									=	(prob**successes) * ((1 - prob) ** (trials - successes))
 # Calculate the binomial coefficient: n! / k!(n-k)!
 __lowercase									=	float(factorial(UpperCamelCase__ ) )
 coefficient /= factorial(UpperCamelCase__ ) * factorial(trials - successes )
 return probability * coefficient


if __name__ == "__main__":
       from doctest import testmod

       testmod()
       print("Probability of 2 successes out of 4 trails")
       print("with probability of 0.75 is:", end=" ")
       print(binomial_distribution(2, 4, 0.75))




"""simple docstring"""

# Algorithm for the pigeonhole sorting




def lowerCAmelCase_      (				UpperCamelCase__	: Dict ):






 """simple docstring"""







 __lowercase									=	min(UpperCamelCase__ )  # min() finds the minimum value
 __lowercase									=	max(UpperCamelCase__ )  # max() finds the maximum value

 __lowercase									=	max_val - min_val + 1  # size is difference of max and min values plus one

 # list of pigeonholes of size equal to the variable size
 __lowercase									=	[0] * size

 # Populate the pigeonholes.
 for x in a:
  assert isinstance(UpperCamelCase__				,   UpperCamelCase__ ), "integers only please"
  holes[x - min_val] += 1

 # Putting the elements back into the array in an order.
 __lowercase									=	0
 for count in range(UpperCamelCase__ ):
  while holes[count] > 0:
   holes[count] -= 1
   __lowercase									=	count + min_val
   i += 1


def lowerCAmelCase_      (				):






 """simple docstring"""







 __lowercase									=	[8, 3, 2, 7, 4, 6, 8]
 pigeonhole_sort(UpperCamelCase__ )
 print("""Sorted order is:"""				,   """ """.join(UpperCamelCase__ ) )


if __name__ == "__main__":
       main()
