




import math
class 		_A   :






  def    __a     (    self						:      Optional[Any] ,		_A						:      list[list[float]] ,		_A						:      list[int] )						->       int:






       """simple docstring"""







       lowercase   :  Optional[Any]        =					0.0
       lowercase   :  str        =					0.0
       for i in range(len(snake_case__ ) ):
            da += math.pow((sample[i] - weights[0][i]) ,		2 )
            da += math.pow((sample[i] - weights[1][i]) ,		2 )
            return 0 if da > da else 1
       return 0






  def    __a     (    self						:      Optional[int] ,		_A						:      list[list[int | float]] ,		_A						:      list[int] ,		_A						:      int ,		_A						:      float )						->       list[list[int | float]]:






       """simple docstring"""







       for i in range(len(snake_case__ ) ):
            weights[j][i] += alpha * (sample[i] - weights[j][i])
       return weights






def    snake_case(							)					->				Any:





     '''simple docstring'''


     lowercase   :  Union[str, Any]        =					[[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 1]]

     # weight initialization ( n, C )
     lowercase   :  List[str]        =					[[0.2, 0.6, 0.5, 0.9], [0.8, 0.4, 0.7, 0.3]]

     # training
     lowercase   :  int        =					SelfOrganizingMap()
     lowercase   :  List[Any]        =					3
     lowercase   :  Tuple        =					0.5

     for _ in range(__lowerCamelCase       ):
          for j in range(len(__lowerCamelCase       )       ):
               # training sample
               lowercase   :  Any        =					training_samples[j]

               # Compute the winning vector
               lowercase   :  List[Any]        =					self_organizing_map.get_winner(__lowerCamelCase					,						__lowerCamelCase       )

               # Update the winning vector
               lowercase   :  Dict        =					self_organizing_map.update(__lowerCamelCase					,						__lowerCamelCase					,						__lowerCamelCase					,						__lowerCamelCase       )

    # classify test sample
     lowercase   :  Any        =					[0, 0, 0, 1]
     lowercase   :  Optional[int]        =					self_organizing_map.get_winner(__lowerCamelCase					,						__lowerCamelCase       )

     # results
     print(F"""Clusters that the test sample belongs to : {winner}"""       )
     print(F"""Weights that have been trained : {weights}"""       )


# running the main() function
if __name__ == "__main__":
 main()

from math import factorial


def      UpperCamelCase   (       __lowerCamelCase	:					int							,   __lowerCamelCase	:					int							,   __lowerCamelCase	:					float       ):
       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(__lowerCamelCase							,   __lowerCamelCase       ) or not isinstance(__lowerCamelCase							,   __lowerCamelCase       ):
              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"       )
       snake_case			:  Tuple     							= (prob**successes) * ((1 - prob) ** (trials - successes))
       # Calculate the binomial coefficient: n! / k!(n-k)!
       snake_case			:  str     							= float(factorial(__lowerCamelCase       )       )
       coefficient /= factorial(__lowerCamelCase       ) * 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))





