




"""simple docstring"""

from math import radians as angle_to_radians
from math import sin

# Acceleration Constant on Earth (unit m/s^2)
__A							=     9.80_665



def 					UpperCamelCase__       (						lowercase__					:       float    ,       lowercase__					:       float				):

		# Ensure valid instance
		if not isinstance(lowercase__    ,       (int, float)				):
				raise TypeError("Invalid velocity. Should be a positive number."				)

		if not isinstance(lowercase__    ,       (int, float)				):
				raise TypeError("Invalid angle. Range is 1-90 degrees."				)

		# Ensure valid angle
		if angle > 90 or angle < 1:
				raise ValueError("Invalid angle. Range is 1-90 degrees."				)

		# Ensure valid velocity
		if init_velocity < 0:
				raise ValueError("Invalid velocity. Should be a positive number."				)



def 					UpperCamelCase__       (						lowercase__					:       float    ,       lowercase__					:       float				):
		check_args(lowercase__    ,       lowercase__				)
		snake_case						:  Dict        =			angle_to_radians(2 * angle				)
		return round(init_velocity**2 * sin(lowercase__				) / g    ,       2				)



def 					UpperCamelCase__       (						lowercase__					:       float    ,       lowercase__					:       float				):
		check_args(lowercase__    ,       lowercase__				)
		snake_case						:  Optional[Any]        =			angle_to_radians(lowercase__				)
		return round(init_velocity**2 * sin(lowercase__				) ** 2 / (2 * g)    ,       2				)



def 					UpperCamelCase__       (						lowercase__					:       float    ,       lowercase__					:       float				):
		check_args(lowercase__    ,       lowercase__				)
		snake_case						:  str        =			angle_to_radians(lowercase__				)
		return round(2 * init_velocity * sin(lowercase__				) / g    ,       2				)



def 					UpperCamelCase__       (						):
		snake_case     ,			snake_case						:  List[Any]        =			25, 20
		assert horizontal_distance(lowercase__    ,       lowercase__				) == 40.97
		assert max_height(lowercase__    ,       lowercase__				) == 3.73
		assert total_time(lowercase__    ,       lowercase__				) == 1.74


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

							testmod()

							# Get input from user
							__A							=     float(input("Initial Velocity: ").strip())

							# Get input from user
							__A							=     float(input("angle: ").strip())

							# Print results
							print()
							print("Results: ")
							print(f'Horizontal Distance: {horizontal_distance(init_vel, angle)!s} [m]')
							print(f'Maximum Height: {max_height(init_vel, angle)!s} [m]')
							print(f'Total Time: {total_time(init_vel, angle)!s} [s]')







"""simple docstring"""

import matplotlib.pyplot as plt
import numpy as np



def 					UpperCamelCase__       (						lowercase__					:       np.ndarray    ,       lowercase__					:       np.ndarray    ,       lowercase__					:       float				):
		snake_case						:  Any        =			len(lowercase__				)  # Number of training samples
		snake_case						:  str        =			np.eye(lowercase__				)  # Initialize weights as identity matrix
		for j in range(lowercase__				):
				snake_case						:  Any        =			point - x_train[j]
				snake_case						:  Dict        =			np.exp(diff @ diff.T / (-2.0 * tau**2)				)

		return weights



def 					UpperCamelCase__       (						lowercase__					:       np.ndarray    ,       lowercase__					:       np.ndarray    ,       lowercase__					:       np.ndarray    ,       lowercase__					:       float				):
		snake_case						:  str        =			weight_matrix(lowercase__    ,       lowercase__    ,       lowercase__				)
		snake_case						:  str        =			np.linalg.inv(x_train.T @ weight_mat @ x_train				) @ (
		    x_train.T @ weight_mat @ y_train.T
		)

		return weight



def 					UpperCamelCase__       (						lowercase__					:       np.ndarray    ,       lowercase__					:       np.ndarray    ,       lowercase__					:       float				):
		snake_case						:  Optional[int]        =			np.zeros(len(lowercase__				)				)  # Initialize array of predictions
		for i, item in enumerate(lowercase__				):
				snake_case						:  Dict        =			item @ local_weight(lowercase__    ,       lowercase__    ,       lowercase__    ,       lowercase__				)

		return y_pred



def 					UpperCamelCase__       (						lowercase__					:       str    ,       lowercase__					:       str    ,       lowercase__					:       str				):
		import seaborn as sns

		snake_case						:  Union[str, Any]        =			sns.load_dataset(lowercase__				)
		snake_case						:  Any        =			np.array(data[x_name]				)
		snake_case						:  str        =			np.array(data[y_name]				)

		snake_case						:  Any        =			np.ones(len(lowercase__				)				)

		# pairing elements of one and x_data
		snake_case						:  Optional[int]        =			np.column_stack((one, x_data)				)

		return x_train, x_data, y_data



def 					UpperCamelCase__       (						lowercase__					:       np.ndarray    ,       lowercase__					:       np.ndarray    ,       lowercase__					:       np.ndarray    ,       lowercase__					:       np.ndarray    ,       lowercase__					:       str    ,       lowercase__					:       str    ,       ):
		snake_case						:  List[str]        =			np.sort(lowercase__    ,       axis=0				)
		plt.scatter(lowercase__    ,       lowercase__    ,       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(lowercase__				)
		plt.ylabel(lowercase__				)
		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")

