
import math





class    __A:

					def  lowercase__   (						self       :  str ,       __UpperCamelCase       :  list[list[float]] ,       __UpperCamelCase       :  list[int] ):
												lowerCamelCase_					=       0.0
												lowerCamelCase_					=       0.0
												for i in range(len(__UpperCamelCase ) ):
																			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  lowercase__   (						self       :  List[str] ,       __UpperCamelCase       :  list[list[int | float]] ,       __UpperCamelCase       :  list[int] ,       __UpperCamelCase       :  int ,       __UpperCamelCase       :  float ):
												for i in range(len(__UpperCamelCase ) ):
																			weights[j][i] += alpha * (sample[i] - weights[j][i])
												return weights



def   __lowerCAmelCase    (				)	->     None:
							# Training Examples ( m, n )
							lowerCamelCase_					=       [[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 1]]

							# weight initialization ( n, C )
							lowerCamelCase_					=       [[0.2, 0.6, 0.5, 0.9], [0.8, 0.4, 0.7, 0.3]]

							# training
							lowerCamelCase_					=       SelfOrganizingMap()
							lowerCamelCase_					=       3
							lowerCamelCase_					=       0.5

							for _ in range(UpperCAmelCase__							):
														for j in range(len(UpperCAmelCase__							)							):
																					# training sample
																					lowerCamelCase_					=       training_samples[j]

																					# Compute the winning vector
																					lowerCamelCase_					=       self_organizing_map.get_winner(UpperCAmelCase__      ,					UpperCAmelCase__							)

																					# Update the winning vector
																					lowerCamelCase_					=       self_organizing_map.update(UpperCAmelCase__      ,					UpperCAmelCase__      ,					UpperCAmelCase__      ,					UpperCAmelCase__							)

    # classify test sample
							lowerCamelCase_					=       [0, 0, 0, 1]
							lowerCamelCase_					=       self_organizing_map.get_winner(UpperCAmelCase__      ,					UpperCAmelCase__							)

							# 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()







lowercase   =	8.314_4598



def   __lowerCAmelCase    (				UpperCAmelCase__					:   float      ,					UpperCAmelCase__					:   float							)	->     float:
							if temperature < 0:
														raise Exception("""Temperature cannot be less than 0 K"""							)
							if molar_mass <= 0:
														raise Exception("""Molar mass cannot be less than or equal to 0 kg/mol"""							)
							else:
														return (3 * UNIVERSAL_GAS_CONSTANT * temperature / molar_mass) ** 0.5


if __name__ == "__main__":
		import doctest

		# run doctest
		doctest.testmod()

		# example
		lowercase   =	3_0_0
		lowercase   =	2_8
		lowercase   =	rms_speed_of_molecule(temperature, molar_mass)
		print(F"""Vrms of Nitrogen gas at 300 K is {vrms} m/s""")





