{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport matplotlib.pyplot as plt\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))","metadata":{"_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","papermill":{"duration":0.03018,"end_time":"2022-10-13T05:41:51.103039","exception":false,"start_time":"2022-10-13T05:41:51.072859","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2022-10-13T06:01:29.562099Z","iopub.execute_input":"2022-10-13T06:01:29.562806Z","iopub.status.idle":"2022-10-13T06:01:29.599463Z","shell.execute_reply.started":"2022-10-13T06:01:29.562666Z","shell.execute_reply":"2022-10-13T06:01:29.598372Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import math\nimport scipy\nfrom scipy import constants","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:51.132755Z","iopub.status.busy":"2022-10-13T05:41:51.132195Z","iopub.status.idle":"2022-10-13T05:41:51.166090Z","shell.execute_reply":"2022-10-13T05:41:51.165448Z"},"papermill":{"duration":0.049662,"end_time":"2022-10-13T05:41:51.167888","exception":false,"start_time":"2022-10-13T05:41:51.118226","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(scipy.__version__)","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:51.194822Z","iopub.status.busy":"2022-10-13T05:41:51.193922Z","iopub.status.idle":"2022-10-13T05:41:51.199623Z","shell.execute_reply":"2022-10-13T05:41:51.198238Z"},"papermill":{"duration":0.02148,"end_time":"2022-10-13T05:41:51.202178","exception":false,"start_time":"2022-10-13T05:41:51.180698","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Constants","metadata":{"papermill":{"duration":0.013124,"end_time":"2022-10-13T05:41:51.229547","exception":false,"start_time":"2022-10-13T05:41:51.216423","status":"completed"},"tags":[]}},{"cell_type":"code","source":"print(dir(constants))","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:51.258591Z","iopub.status.busy":"2022-10-13T05:41:51.257776Z","iopub.status.idle":"2022-10-13T05:41:51.263178Z","shell.execute_reply":"2022-10-13T05:41:51.262151Z"},"papermill":{"duration":0.022417,"end_time":"2022-10-13T05:41:51.265312","exception":false,"start_time":"2022-10-13T05:41:51.242895","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(constants.mebi)\nprint(constants.electron_volt)\nprint(constants.gallon_US)\nprint(constants.gram)\nprint(constants.lb)\nprint(constants.degree)\nprint(constants.minute)\nprint(constants.mile)\nprint(constants.psi)\nprint(constants.hectare)\nprint(constants.mach)\nprint(constants.horsepower)","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:51.292901Z","iopub.status.busy":"2022-10-13T05:41:51.292259Z","iopub.status.idle":"2022-10-13T05:41:51.298623Z","shell.execute_reply":"2022-10-13T05:41:51.297616Z"},"papermill":{"duration":0.022179,"end_time":"2022-10-13T05:41:51.300768","exception":false,"start_time":"2022-10-13T05:41:51.278589","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Optimizers","metadata":{"papermill":{"duration":0.01333,"end_time":"2022-10-13T05:41:51.327477","exception":false,"start_time":"2022-10-13T05:41:51.314147","status":"completed"},"tags":[]}},{"cell_type":"code","source":"from scipy import optimize","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:51.355712Z","iopub.status.busy":"2022-10-13T05:41:51.355370Z","iopub.status.idle":"2022-10-13T05:41:51.682482Z","shell.execute_reply":"2022-10-13T05:41:51.681444Z"},"papermill":{"duration":0.344511,"end_time":"2022-10-13T05:41:51.685490","exception":false,"start_time":"2022-10-13T05:41:51.340979","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(dir(optimize))","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:51.719238Z","iopub.status.busy":"2022-10-13T05:41:51.718259Z","iopub.status.idle":"2022-10-13T05:41:51.725580Z","shell.execute_reply":"2022-10-13T05:41:51.724544Z"},"papermill":{"duration":0.028835,"end_time":"2022-10-13T05:41:51.731102","exception":false,"start_time":"2022-10-13T05:41:51.702267","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def func(x):\n    return x**3 + x*math.cos(x) +3","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:51.766745Z","iopub.status.busy":"2022-10-13T05:41:51.765832Z","iopub.status.idle":"2022-10-13T05:41:51.771149Z","shell.execute_reply":"2022-10-13T05:41:51.770370Z"},"papermill":{"duration":0.024849,"end_time":"2022-10-13T05:41:51.773047","exception":false,"start_time":"2022-10-13T05:41:51.748198","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"optimize.root(func,1)","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:51.803124Z","iopub.status.busy":"2022-10-13T05:41:51.802546Z","iopub.status.idle":"2022-10-13T05:41:51.814674Z","shell.execute_reply":"2022-10-13T05:41:51.813635Z"},"papermill":{"duration":0.029351,"end_time":"2022-10-13T05:41:51.816684","exception":false,"start_time":"2022-10-13T05:41:51.787333","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"optimize.minimize(func, 0, method='CG')# 'CG','BFGS','Newton-CG','L-BFGS-B','TNC','COBYLA','SLSQP'","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:51.849776Z","iopub.status.busy":"2022-10-13T05:41:51.849382Z","iopub.status.idle":"2022-10-13T05:41:52.095168Z","shell.execute_reply":"2022-10-13T05:41:52.094230Z"},"papermill":{"duration":0.266427,"end_time":"2022-10-13T05:41:52.097123","exception":false,"start_time":"2022-10-13T05:41:51.830696","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Sparse Data","metadata":{"papermill":{"duration":0.013978,"end_time":"2022-10-13T05:41:52.125919","exception":false,"start_time":"2022-10-13T05:41:52.111941","status":"completed"},"tags":[]}},{"cell_type":"code","source":"from scipy import sparse","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:52.155037Z","iopub.status.busy":"2022-10-13T05:41:52.154133Z","iopub.status.idle":"2022-10-13T05:41:52.158323Z","shell.execute_reply":"2022-10-13T05:41:52.157554Z"},"papermill":{"duration":0.020699,"end_time":"2022-10-13T05:41:52.160198","exception":false,"start_time":"2022-10-13T05:41:52.139499","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"arr1 = np.array([3,0,1,0,0,1,0,0,0,0,21,0,0,0,5,0,0,0,0,0])","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:52.188165Z","iopub.status.busy":"2022-10-13T05:41:52.187857Z","iopub.status.idle":"2022-10-13T05:41:52.192679Z","shell.execute_reply":"2022-10-13T05:41:52.191842Z"},"papermill":{"duration":0.021136,"end_time":"2022-10-13T05:41:52.194618","exception":false,"start_time":"2022-10-13T05:41:52.173482","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(sparse.csr_matrix(arr1))","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:52.223120Z","iopub.status.busy":"2022-10-13T05:41:52.222582Z","iopub.status.idle":"2022-10-13T05:41:52.230146Z","shell.execute_reply":"2022-10-13T05:41:52.228819Z"},"papermill":{"duration":0.024131,"end_time":"2022-10-13T05:41:52.232369","exception":false,"start_time":"2022-10-13T05:41:52.208238","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sparse.csr_matrix(arr1).data","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:52.260774Z","iopub.status.busy":"2022-10-13T05:41:52.260502Z","iopub.status.idle":"2022-10-13T05:41:52.267663Z","shell.execute_reply":"2022-10-13T05:41:52.266734Z"},"papermill":{"duration":0.023433,"end_time":"2022-10-13T05:41:52.269587","exception":false,"start_time":"2022-10-13T05:41:52.246154","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(sparse.csr_matrix(arr1).count_nonzero())","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:52.299720Z","iopub.status.busy":"2022-10-13T05:41:52.299149Z","iopub.status.idle":"2022-10-13T05:41:52.305545Z","shell.execute_reply":"2022-10-13T05:41:52.304551Z"},"papermill":{"duration":0.025301,"end_time":"2022-10-13T05:41:52.308750","exception":false,"start_time":"2022-10-13T05:41:52.283449","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"arr2 = np.array([[0, 1,0], [1,0, 0], [2, 0, 0]])","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:52.340147Z","iopub.status.busy":"2022-10-13T05:41:52.339527Z","iopub.status.idle":"2022-10-13T05:41:52.344944Z","shell.execute_reply":"2022-10-13T05:41:52.343737Z"},"papermill":{"duration":0.022866,"end_time":"2022-10-13T05:41:52.347043","exception":false,"start_time":"2022-10-13T05:41:52.324177","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(sparse.csr_matrix(arr2).tocsc())","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:52.375422Z","iopub.status.busy":"2022-10-13T05:41:52.375108Z","iopub.status.idle":"2022-10-13T05:41:52.381024Z","shell.execute_reply":"2022-10-13T05:41:52.379972Z"},"papermill":{"duration":0.022503,"end_time":"2022-10-13T05:41:52.383053","exception":false,"start_time":"2022-10-13T05:41:52.360550","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from scipy.sparse.csgraph import connected_components","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:52.412156Z","iopub.status.busy":"2022-10-13T05:41:52.411340Z","iopub.status.idle":"2022-10-13T05:41:52.415251Z","shell.execute_reply":"2022-10-13T05:41:52.414639Z"},"papermill":{"duration":0.02005,"end_time":"2022-10-13T05:41:52.417031","exception":false,"start_time":"2022-10-13T05:41:52.396981","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"arr = np.array([\n  [0, 1, 2],\n  [1, 0, 0],\n  [2, 0, 0]\n])\n\nnewarr = sparse.csr_matrix(arr)\n\nprint(connected_components(newarr))","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:52.445038Z","iopub.status.busy":"2022-10-13T05:41:52.444749Z","iopub.status.idle":"2022-10-13T05:41:52.452428Z","shell.execute_reply":"2022-10-13T05:41:52.451372Z"},"papermill":{"duration":0.02409,"end_time":"2022-10-13T05:41:52.454476","exception":false,"start_time":"2022-10-13T05:41:52.430386","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Dijkstra","metadata":{"papermill":{"duration":0.013352,"end_time":"2022-10-13T05:41:52.481656","exception":false,"start_time":"2022-10-13T05:41:52.468304","status":"completed"},"tags":[]}},{"cell_type":"code","source":"from scipy.sparse.csgraph import dijkstra","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:52.510471Z","iopub.status.busy":"2022-10-13T05:41:52.509899Z","iopub.status.idle":"2022-10-13T05:41:52.513786Z","shell.execute_reply":"2022-10-13T05:41:52.512902Z"},"papermill":{"duration":0.020352,"end_time":"2022-10-13T05:41:52.515641","exception":false,"start_time":"2022-10-13T05:41:52.495289","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(dijkstra(newarr, return_predecessors=True, indices=0))","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:52.545880Z","iopub.status.busy":"2022-10-13T05:41:52.545301Z","iopub.status.idle":"2022-10-13T05:41:52.550710Z","shell.execute_reply":"2022-10-13T05:41:52.549734Z"},"papermill":{"duration":0.022762,"end_time":"2022-10-13T05:41:52.552571","exception":false,"start_time":"2022-10-13T05:41:52.529809","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Floyd Warshall","metadata":{"papermill":{"duration":0.014084,"end_time":"2022-10-13T05:41:52.580904","exception":false,"start_time":"2022-10-13T05:41:52.566820","status":"completed"},"tags":[]}},{"cell_type":"code","source":"from scipy.sparse.csgraph import floyd_warshall","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:52.611109Z","iopub.status.busy":"2022-10-13T05:41:52.610539Z","iopub.status.idle":"2022-10-13T05:41:52.614156Z","shell.execute_reply":"2022-10-13T05:41:52.613488Z"},"papermill":{"duration":0.020589,"end_time":"2022-10-13T05:41:52.615863","exception":false,"start_time":"2022-10-13T05:41:52.595274","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(floyd_warshall(newarr, return_predecessors=True))","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:52.646137Z","iopub.status.busy":"2022-10-13T05:41:52.645550Z","iopub.status.idle":"2022-10-13T05:41:52.650978Z","shell.execute_reply":"2022-10-13T05:41:52.649830Z"},"papermill":{"duration":0.022708,"end_time":"2022-10-13T05:41:52.653093","exception":false,"start_time":"2022-10-13T05:41:52.630385","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Bellman Ford","metadata":{"papermill":{"duration":0.014233,"end_time":"2022-10-13T05:41:52.681746","exception":false,"start_time":"2022-10-13T05:41:52.667513","status":"completed"},"tags":[]}},{"cell_type":"code","source":"from scipy.sparse.csgraph import bellman_ford","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:52.712611Z","iopub.status.busy":"2022-10-13T05:41:52.712249Z","iopub.status.idle":"2022-10-13T05:41:52.716847Z","shell.execute_reply":"2022-10-13T05:41:52.715807Z"},"papermill":{"duration":0.022382,"end_time":"2022-10-13T05:41:52.718700","exception":false,"start_time":"2022-10-13T05:41:52.696318","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(bellman_ford(newarr, return_predecessors=True, indices=0))","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:52.748373Z","iopub.status.busy":"2022-10-13T05:41:52.748087Z","iopub.status.idle":"2022-10-13T05:41:52.754162Z","shell.execute_reply":"2022-10-13T05:41:52.752662Z"},"papermill":{"duration":0.023328,"end_time":"2022-10-13T05:41:52.756246","exception":false,"start_time":"2022-10-13T05:41:52.732918","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Depth First Order","metadata":{"papermill":{"duration":0.014101,"end_time":"2022-10-13T05:41:52.784855","exception":false,"start_time":"2022-10-13T05:41:52.770754","status":"completed"},"tags":[]}},{"cell_type":"code","source":"from scipy.sparse.csgraph import depth_first_order","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:52.815521Z","iopub.status.busy":"2022-10-13T05:41:52.815182Z","iopub.status.idle":"2022-10-13T05:41:52.819427Z","shell.execute_reply":"2022-10-13T05:41:52.818400Z"},"papermill":{"duration":0.022365,"end_time":"2022-10-13T05:41:52.821566","exception":false,"start_time":"2022-10-13T05:41:52.799201","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(depth_first_order(newarr, 1))","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:52.852818Z","iopub.status.busy":"2022-10-13T05:41:52.852493Z","iopub.status.idle":"2022-10-13T05:41:52.858528Z","shell.execute_reply":"2022-10-13T05:41:52.856911Z"},"papermill":{"duration":0.024282,"end_time":"2022-10-13T05:41:52.860800","exception":false,"start_time":"2022-10-13T05:41:52.836518","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Breadth First Order","metadata":{"papermill":{"duration":0.014189,"end_time":"2022-10-13T05:41:52.890254","exception":false,"start_time":"2022-10-13T05:41:52.876065","status":"completed"},"tags":[]}},{"cell_type":"code","source":"from scipy.sparse.csgraph import breadth_first_order","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:52.921794Z","iopub.status.busy":"2022-10-13T05:41:52.921422Z","iopub.status.idle":"2022-10-13T05:41:52.925802Z","shell.execute_reply":"2022-10-13T05:41:52.925077Z"},"papermill":{"duration":0.022674,"end_time":"2022-10-13T05:41:52.927710","exception":false,"start_time":"2022-10-13T05:41:52.905036","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(breadth_first_order(newarr, 1))","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:52.959522Z","iopub.status.busy":"2022-10-13T05:41:52.959143Z","iopub.status.idle":"2022-10-13T05:41:52.965907Z","shell.execute_reply":"2022-10-13T05:41:52.964338Z"},"papermill":{"duration":0.025203,"end_time":"2022-10-13T05:41:52.967991","exception":false,"start_time":"2022-10-13T05:41:52.942788","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Triangulation","metadata":{"papermill":{"duration":0.014739,"end_time":"2022-10-13T05:41:52.997384","exception":false,"start_time":"2022-10-13T05:41:52.982645","status":"completed"},"tags":[]}},{"cell_type":"code","source":"from scipy.spatial import Delaunay\n\npoints = np.array([\n  [2, 4],\n  [3, 4],\n  [3, 0],\n  [2, 2],\n  [4, 1]\n])\n\nsimplices = Delaunay(points).simplices\n\nplt.triplot(points[:, 0], points[:, 1], simplices)\nplt.scatter(points[:, 0], points[:, 1], color='r')\n\nplt.show()","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:53.028563Z","iopub.status.busy":"2022-10-13T05:41:53.028136Z","iopub.status.idle":"2022-10-13T05:41:53.276133Z","shell.execute_reply":"2022-10-13T05:41:53.275381Z"},"papermill":{"duration":0.265875,"end_time":"2022-10-13T05:41:53.277872","exception":false,"start_time":"2022-10-13T05:41:53.011997","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Convex Hull","metadata":{"papermill":{"duration":0.013781,"end_time":"2022-10-13T05:41:53.306292","exception":false,"start_time":"2022-10-13T05:41:53.292511","status":"completed"},"tags":[]}},{"cell_type":"code","source":"from scipy.spatial import ConvexHull","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:53.336624Z","iopub.status.busy":"2022-10-13T05:41:53.336256Z","iopub.status.idle":"2022-10-13T05:41:53.340297Z","shell.execute_reply":"2022-10-13T05:41:53.339354Z"},"papermill":{"duration":0.021698,"end_time":"2022-10-13T05:41:53.342262","exception":false,"start_time":"2022-10-13T05:41:53.320564","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"points = np.array([\n  [2, 4],\n  [3, 4],\n  [3, 0],\n  [2, 2],\n  [4, 1],\n  [1, 2],\n  [5, 0],\n  [3, 1],\n  [1, 2],\n  [0, 2]\n])\n\nhull = ConvexHull(points)\nhull_points = hull.simplices\n\nplt.scatter(points[:,0], points[:,1])\nfor simplex in hull_points:\n  plt.plot(points[simplex,0], points[simplex,1], 'k-')\n\nplt.show()","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:53.373541Z","iopub.status.busy":"2022-10-13T05:41:53.373171Z","iopub.status.idle":"2022-10-13T05:41:53.576238Z","shell.execute_reply":"2022-10-13T05:41:53.575161Z"},"papermill":{"duration":0.221884,"end_time":"2022-10-13T05:41:53.578789","exception":false,"start_time":"2022-10-13T05:41:53.356905","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# KDTrees","metadata":{"papermill":{"duration":0.015417,"end_time":"2022-10-13T05:41:53.609545","exception":false,"start_time":"2022-10-13T05:41:53.594128","status":"completed"},"tags":[]}},{"cell_type":"code","source":"from scipy.spatial import KDTree\n\npoints = [(1, -1), (2, 3), (-2, 3), (2, -3)]\n\nkdtree = KDTree(points)\n\nres = kdtree.query((1, 1))\n\nprint(res)","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:53.642071Z","iopub.status.busy":"2022-10-13T05:41:53.641537Z","iopub.status.idle":"2022-10-13T05:41:53.649758Z","shell.execute_reply":"2022-10-13T05:41:53.648710Z"},"papermill":{"duration":0.026939,"end_time":"2022-10-13T05:41:53.651935","exception":false,"start_time":"2022-10-13T05:41:53.624996","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Euclidean Distance","metadata":{"papermill":{"duration":0.014581,"end_time":"2022-10-13T05:41:53.682140","exception":false,"start_time":"2022-10-13T05:41:53.667559","status":"completed"},"tags":[]}},{"cell_type":"code","source":"from scipy.spatial.distance import euclidean\n\np1 = (1, 0)\np2 = (10, 2)\n\nres = euclidean(p1, p2)\n\nprint(res)","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:53.720377Z","iopub.status.busy":"2022-10-13T05:41:53.719508Z","iopub.status.idle":"2022-10-13T05:41:53.725741Z","shell.execute_reply":"2022-10-13T05:41:53.724674Z"},"papermill":{"duration":0.032134,"end_time":"2022-10-13T05:41:53.729049","exception":false,"start_time":"2022-10-13T05:41:53.696915","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Manhattan Distance","metadata":{"papermill":{"duration":0.01837,"end_time":"2022-10-13T05:41:53.767364","exception":false,"start_time":"2022-10-13T05:41:53.748994","status":"completed"},"tags":[]}},{"cell_type":"code","source":"from scipy.spatial.distance import cityblock\n\np1 = (1, 0)\np2 = (10, 2)\n\nres = cityblock(p1, p2)\n\nprint(res)","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:53.805013Z","iopub.status.busy":"2022-10-13T05:41:53.804303Z","iopub.status.idle":"2022-10-13T05:41:53.810868Z","shell.execute_reply":"2022-10-13T05:41:53.809627Z"},"papermill":{"duration":0.028223,"end_time":"2022-10-13T05:41:53.813455","exception":false,"start_time":"2022-10-13T05:41:53.785232","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Cosine Distance","metadata":{"papermill":{"duration":0.014622,"end_time":"2022-10-13T05:41:53.843802","exception":false,"start_time":"2022-10-13T05:41:53.829180","status":"completed"},"tags":[]}},{"cell_type":"code","source":"from scipy.spatial.distance import cosine\n\np1 = (1, 0)\np2 = (10, 2)\n\nres = cosine(p1, p2)\n\nprint(res)","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:53.875599Z","iopub.status.busy":"2022-10-13T05:41:53.874545Z","iopub.status.idle":"2022-10-13T05:41:53.880783Z","shell.execute_reply":"2022-10-13T05:41:53.879793Z"},"papermill":{"duration":0.024079,"end_time":"2022-10-13T05:41:53.882880","exception":false,"start_time":"2022-10-13T05:41:53.858801","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Hamming Distance","metadata":{"papermill":{"duration":0.014506,"end_time":"2022-10-13T05:41:53.912830","exception":false,"start_time":"2022-10-13T05:41:53.898324","status":"completed"},"tags":[]}},{"cell_type":"code","source":"from scipy.spatial.distance import hamming\n\np1 = (True, False, True)\np2 = (False, True, True)\n\nres = hamming(p1, p2)\n\nprint(res)","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:53.945054Z","iopub.status.busy":"2022-10-13T05:41:53.944669Z","iopub.status.idle":"2022-10-13T05:41:53.949699Z","shell.execute_reply":"2022-10-13T05:41:53.948725Z"},"papermill":{"duration":0.025746,"end_time":"2022-10-13T05:41:53.953192","exception":false,"start_time":"2022-10-13T05:41:53.927446","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Matlab Arrays","metadata":{"papermill":{"duration":0.015333,"end_time":"2022-10-13T05:41:53.985483","exception":false,"start_time":"2022-10-13T05:41:53.970150","status":"completed"},"tags":[]}},{"cell_type":"code","source":"from scipy import io\n\narr = np.arange(10)\n\nio.savemat('arr.mat', {\"vec\": arr})","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:54.017283Z","iopub.status.busy":"2022-10-13T05:41:54.016944Z","iopub.status.idle":"2022-10-13T05:41:54.140997Z","shell.execute_reply":"2022-10-13T05:41:54.139830Z"},"papermill":{"duration":0.143262,"end_time":"2022-10-13T05:41:54.143631","exception":false,"start_time":"2022-10-13T05:41:54.000369","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"io.savemat('arr.mat', {\"vec\": arr})\n\n# Import:\nmydata = io.loadmat('arr.mat')\n\nprint(mydata)","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:54.175780Z","iopub.status.busy":"2022-10-13T05:41:54.175474Z","iopub.status.idle":"2022-10-13T05:41:54.182074Z","shell.execute_reply":"2022-10-13T05:41:54.180612Z"},"papermill":{"duration":0.024842,"end_time":"2022-10-13T05:41:54.184185","exception":false,"start_time":"2022-10-13T05:41:54.159343","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(mydata['vec'])","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:54.215949Z","iopub.status.busy":"2022-10-13T05:41:54.215645Z","iopub.status.idle":"2022-10-13T05:41:54.221057Z","shell.execute_reply":"2022-10-13T05:41:54.219803Z"},"papermill":{"duration":0.024011,"end_time":"2022-10-13T05:41:54.223453","exception":false,"start_time":"2022-10-13T05:41:54.199442","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mydata = io.loadmat('arr.mat', squeeze_me=True)\n\nprint(mydata['vec'])","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:54.256817Z","iopub.status.busy":"2022-10-13T05:41:54.256051Z","iopub.status.idle":"2022-10-13T05:41:54.261318Z","shell.execute_reply":"2022-10-13T05:41:54.260382Z"},"papermill":{"duration":0.023993,"end_time":"2022-10-13T05:41:54.263820","exception":false,"start_time":"2022-10-13T05:41:54.239827","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# 1D Interpolation","metadata":{"papermill":{"duration":0.015089,"end_time":"2022-10-13T05:41:54.295107","exception":false,"start_time":"2022-10-13T05:41:54.280018","status":"completed"},"tags":[]}},{"cell_type":"code","source":"from scipy.interpolate import interp1d\n\nxs = np.arange(10)\nys = 2*xs + 1\n\ninterp_func = interp1d(xs, ys)\n\nnewarr = interp_func(np.arange(2.1, 3, 0.1))\n\nprint(newarr)","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:54.326721Z","iopub.status.busy":"2022-10-13T05:41:54.326381Z","iopub.status.idle":"2022-10-13T05:41:54.360604Z","shell.execute_reply":"2022-10-13T05:41:54.359476Z"},"papermill":{"duration":0.052147,"end_time":"2022-10-13T05:41:54.362382","exception":false,"start_time":"2022-10-13T05:41:54.310235","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Spline Interpolation","metadata":{"papermill":{"duration":0.015195,"end_time":"2022-10-13T05:41:54.392722","exception":false,"start_time":"2022-10-13T05:41:54.377527","status":"completed"},"tags":[]}},{"cell_type":"code","source":"from scipy.interpolate import UnivariateSpline\ninterp_func = UnivariateSpline(xs, ys)\n\nnewarr = interp_func(np.arange(2.1, 3, 0.1))\n\nprint(newarr)","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:54.426678Z","iopub.status.busy":"2022-10-13T05:41:54.425838Z","iopub.status.idle":"2022-10-13T05:41:54.432971Z","shell.execute_reply":"2022-10-13T05:41:54.431801Z"},"papermill":{"duration":0.026034,"end_time":"2022-10-13T05:41:54.435863","exception":false,"start_time":"2022-10-13T05:41:54.409829","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Interpolation with Radial Basis Function","metadata":{"papermill":{"duration":0.015322,"end_time":"2022-10-13T05:41:54.467040","exception":false,"start_time":"2022-10-13T05:41:54.451718","status":"completed"},"tags":[]}},{"cell_type":"code","source":"from scipy.interpolate import Rbf\ninterp_func = Rbf(xs, ys)\n\nnewarr = interp_func(np.arange(2.1, 3, 0.1))\n\nprint(newarr)","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:54.501797Z","iopub.status.busy":"2022-10-13T05:41:54.500954Z","iopub.status.idle":"2022-10-13T05:41:54.517246Z","shell.execute_reply":"2022-10-13T05:41:54.516038Z"},"papermill":{"duration":0.035891,"end_time":"2022-10-13T05:41:54.519906","exception":false,"start_time":"2022-10-13T05:41:54.484015","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# T-Test","metadata":{"papermill":{"duration":0.015873,"end_time":"2022-10-13T05:41:54.551892","exception":false,"start_time":"2022-10-13T05:41:54.536019","status":"completed"},"tags":[]}},{"cell_type":"code","source":"from scipy.stats import ttest_ind\n\nv1 = np.random.normal(size=100)\nv2 = np.random.normal(size=100)\n\nres = ttest_ind(v1, v2)\n\nprint(res)","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:54.584374Z","iopub.status.busy":"2022-10-13T05:41:54.584012Z","iopub.status.idle":"2022-10-13T05:41:54.811891Z","shell.execute_reply":"2022-10-13T05:41:54.810470Z"},"papermill":{"duration":0.24679,"end_time":"2022-10-13T05:41:54.814301","exception":false,"start_time":"2022-10-13T05:41:54.567511","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# P value ","metadata":{"papermill":{"duration":0.015979,"end_time":"2022-10-13T05:41:54.846970","exception":false,"start_time":"2022-10-13T05:41:54.830991","status":"completed"},"tags":[]}},{"cell_type":"code","source":"res = ttest_ind(v1, v2).pvalue\n\nprint(res)","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:54.880912Z","iopub.status.busy":"2022-10-13T05:41:54.880539Z","iopub.status.idle":"2022-10-13T05:41:54.886871Z","shell.execute_reply":"2022-10-13T05:41:54.885721Z"},"papermill":{"duration":0.025974,"end_time":"2022-10-13T05:41:54.889165","exception":false,"start_time":"2022-10-13T05:41:54.863191","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# KS-Test\n","metadata":{"papermill":{"duration":0.016369,"end_time":"2022-10-13T05:41:54.921562","exception":false,"start_time":"2022-10-13T05:41:54.905193","status":"completed"},"tags":[]}},{"cell_type":"code","source":"from scipy.stats import kstest\n\nv = np.random.normal(size=100)\n\nres = kstest(v, 'norm')\n\nprint(res)","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:54.955431Z","iopub.status.busy":"2022-10-13T05:41:54.955039Z","iopub.status.idle":"2022-10-13T05:41:54.965797Z","shell.execute_reply":"2022-10-13T05:41:54.964669Z"},"papermill":{"duration":0.029837,"end_time":"2022-10-13T05:41:54.967789","exception":false,"start_time":"2022-10-13T05:41:54.937952","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Statistical Description of Data","metadata":{"papermill":{"duration":0.016732,"end_time":"2022-10-13T05:41:55.000878","exception":false,"start_time":"2022-10-13T05:41:54.984146","status":"completed"},"tags":[]}},{"cell_type":"code","source":"from scipy.stats import describe\n\nv = np.random.normal(size=100)\nres = describe(v)\n\nprint(res)","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:55.036676Z","iopub.status.busy":"2022-10-13T05:41:55.036310Z","iopub.status.idle":"2022-10-13T05:41:55.042731Z","shell.execute_reply":"2022-10-13T05:41:55.041410Z"},"papermill":{"duration":0.027526,"end_time":"2022-10-13T05:41:55.045715","exception":false,"start_time":"2022-10-13T05:41:55.018189","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Skewness and Kurtosis ","metadata":{"papermill":{"duration":0.016621,"end_time":"2022-10-13T05:41:55.079547","exception":false,"start_time":"2022-10-13T05:41:55.062926","status":"completed"},"tags":[]}},{"cell_type":"code","source":"from scipy.stats import skew, kurtosis\n\nv = np.random.normal(size=100)\n\nprint(skew(v))\nprint(kurtosis(v))","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:55.115217Z","iopub.status.busy":"2022-10-13T05:41:55.114839Z","iopub.status.idle":"2022-10-13T05:41:55.121950Z","shell.execute_reply":"2022-10-13T05:41:55.120672Z"},"papermill":{"duration":0.027917,"end_time":"2022-10-13T05:41:55.124341","exception":false,"start_time":"2022-10-13T05:41:55.096424","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Normal test","metadata":{"papermill":{"duration":0.016006,"end_time":"2022-10-13T05:41:55.157627","exception":false,"start_time":"2022-10-13T05:41:55.141621","status":"completed"},"tags":[]}},{"cell_type":"code","source":"from scipy.stats import normaltest\n\nv = np.random.normal(size=100)\n\nprint(normaltest(v))","metadata":{"execution":{"iopub.execute_input":"2022-10-13T05:41:55.190748Z","iopub.status.busy":"2022-10-13T05:41:55.190434Z","iopub.status.idle":"2022-10-13T05:41:55.196613Z","shell.execute_reply":"2022-10-13T05:41:55.195677Z"},"papermill":{"duration":0.025719,"end_time":"2022-10-13T05:41:55.199013","exception":false,"start_time":"2022-10-13T05:41:55.173294","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"papermill":{"duration":0.015763,"end_time":"2022-10-13T05:41:55.231094","exception":false,"start_time":"2022-10-13T05:41:55.215331","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]}]}