

"""simple docstring"""


import matplotlib.pyplot as plt
import numpy as np






def 					a__					(					__SCREAMING_SNAKE_CASE      ,				__SCREAMING_SNAKE_CASE      ,				__SCREAMING_SNAKE_CASE				)			->			np.ndarray:
		__lowerCAmelCase: Any					   =    len(__SCREAMING_SNAKE_CASE				)  # Number of training samples
		__lowerCAmelCase: Dict					   =    np.eye(__SCREAMING_SNAKE_CASE				)  # Initialize weights as identity matrix
		for j in range(__SCREAMING_SNAKE_CASE				):
				__lowerCAmelCase: Tuple					   =    point - x_train[j]
				__lowerCAmelCase: int					   =    np.exp(diff @ diff.T / (-2.0 * tau**2)				)

		return weights






def 					a__					(					__SCREAMING_SNAKE_CASE      ,				__SCREAMING_SNAKE_CASE      ,				__SCREAMING_SNAKE_CASE      ,				__SCREAMING_SNAKE_CASE				)			->			np.ndarray:
		__lowerCAmelCase: int					   =    weight_matrix(__SCREAMING_SNAKE_CASE      ,				__SCREAMING_SNAKE_CASE      ,				__SCREAMING_SNAKE_CASE				)
		__lowerCAmelCase: Dict					   =    np.linalg.inv(x_train.T @ weight_mat @ x_train				) @ (
		    x_train.T @ weight_mat @ y_train.T
		)

		return weight






def 					a__					(					__SCREAMING_SNAKE_CASE      ,				__SCREAMING_SNAKE_CASE      ,				__SCREAMING_SNAKE_CASE				)			->			np.ndarray:
		__lowerCAmelCase: Tuple					   =    np.zeros(len(__SCREAMING_SNAKE_CASE				)				)  # Initialize array of predictions
		for i, item in enumerate(__SCREAMING_SNAKE_CASE				):
				__lowerCAmelCase: int					   =    item @ local_weight(__SCREAMING_SNAKE_CASE      ,				__SCREAMING_SNAKE_CASE      ,				__SCREAMING_SNAKE_CASE      ,				__SCREAMING_SNAKE_CASE				)

		return y_pred






def 					a__					(					__SCREAMING_SNAKE_CASE      ,				__SCREAMING_SNAKE_CASE      ,				__SCREAMING_SNAKE_CASE				)			->			tuple[np.ndarray, np.ndarray, np.ndarray]:
		import seaborn as sns

		__lowerCAmelCase: List[str]					   =    sns.load_dataset(__SCREAMING_SNAKE_CASE				)
		__lowerCAmelCase: List[str]					   =    np.array(data[x_name]				)
		__lowerCAmelCase: int					   =    np.array(data[y_name]				)

		__lowerCAmelCase: str					   =    np.ones(len(__SCREAMING_SNAKE_CASE				)				)

		# pairing elements of one and x_data
		__lowerCAmelCase: int					   =    np.column_stack((one, x_data)				)

		return x_train, x_data, y_data






def 					a__					(					__SCREAMING_SNAKE_CASE      ,				__SCREAMING_SNAKE_CASE      ,				__SCREAMING_SNAKE_CASE      ,				__SCREAMING_SNAKE_CASE      ,				__SCREAMING_SNAKE_CASE      ,				__SCREAMING_SNAKE_CASE      ,				)			->			None:
		__lowerCAmelCase: List[str]					   =    np.sort(__SCREAMING_SNAKE_CASE      ,				axis=0				)
		plt.scatter(__SCREAMING_SNAKE_CASE      ,				__SCREAMING_SNAKE_CASE      ,				color="blue"				)
		plt.plot(
		    x_train_sorted[:, 1]      ,				preds[x_train[:, 1].argsort(0				)]      ,				color="yellow"      ,				linewidth=5      ,				)
		plt.title("Local Weighted Regression"				)
		plt.xlabel(__SCREAMING_SNAKE_CASE				)
		plt.ylabel(__SCREAMING_SNAKE_CASE				)
		plt.show()


if __name__ == "__main__":
			import doctest

			doctest.testmod()

			# Demo with a dataset from the seaborn module
			__A     ,       __A     ,       __A		     =    load_data("tips", "total_bill", "tip")
			__A		     =    local_weight_regression(training_data_x, tip, 5)
			plot_preds(training_data_x, predictions, total_bill, tip, "total_bill", "tip")





"""simple docstring"""


import math

import qiskit
from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute






def 					a__					(					__SCREAMING_SNAKE_CASE = 1      ,				__SCREAMING_SNAKE_CASE = 1				)			->			qiskit.result.counts.Counts:
		if isinstance(__SCREAMING_SNAKE_CASE      ,				__SCREAMING_SNAKE_CASE				) or isinstance(__SCREAMING_SNAKE_CASE      ,				__SCREAMING_SNAKE_CASE				):
				raise TypeError("inputs must be integers."				)
		if (bit_a < 0) or (bit_a < 0):
				raise ValueError("inputs must be positive."				)
		if (math.floor(__SCREAMING_SNAKE_CASE				) != bit_a) or (math.floor(__SCREAMING_SNAKE_CASE				) != bit_a):
				raise ValueError("inputs must be exact integers."				)
		if (bit_a > 1) or (bit_a > 1):
				raise ValueError("inputs must be less or equal to 1."				)

		# build registers
		__lowerCAmelCase: str					   =    QuantumRegister(2      ,				"qr"				)
		__lowerCAmelCase: Optional[Any]					   =    ClassicalRegister(2      ,				"cr"				)

		__lowerCAmelCase: Dict					   =    QuantumCircuit(__SCREAMING_SNAKE_CASE      ,				__SCREAMING_SNAKE_CASE				)

		# entanglement the qubits
		quantum_circuit.h(1				)
		quantum_circuit.cx(1      ,				0				)

		# send the information
		__lowerCAmelCase: Dict					   =    str(__SCREAMING_SNAKE_CASE				) + str(__SCREAMING_SNAKE_CASE				)

		if c_information == "11":
				quantum_circuit.x(1				)
				quantum_circuit.z(1				)
		elif c_information == "10":
				quantum_circuit.z(1				)
		elif c_information == "01":
				quantum_circuit.x(1				)
		else:
				quantum_circuit.i(1				)

		# unentangled the circuit
		quantum_circuit.cx(1      ,				0				)
		quantum_circuit.h(1				)

		# measure the circuit
		quantum_circuit.measure(__SCREAMING_SNAKE_CASE      ,				__SCREAMING_SNAKE_CASE				)

		__lowerCAmelCase: List[str]					   =    Aer.get_backend("aer_simulator"				)
		__lowerCAmelCase: Dict					   =    execute(__SCREAMING_SNAKE_CASE      ,				__SCREAMING_SNAKE_CASE      ,				shots=1_0_0_0				)

		return job.result().get_counts(__SCREAMING_SNAKE_CASE				)


if __name__ == "__main__":
			print(F'''Counts for classical state send: {superdense_coding(1,1)}''')


