This comprehensive assignment is designed to deepen your understanding of Python's NumPy library, essential for numerical computing and data science. Through a series of practical tasks, you will explore array creation, manipulation, linear algebra operations, statistical analysis, and more. This assignment assumes no prior experience with Python or NumPy, making it suitable for beginners.
- Python Installation: Ensure Python 3.8 or later is installed on your system.
- NumPy Installation: Install NumPy by running
pip install numpyin your terminal or command prompt.
- Array Creation: Create the following arrays using NumPy:
- A one-dimensional array from a Python list.
- A two-dimensional matrix with dimensions (3 \times 4) filled with zeros.
- A three-dimensional array with dimensions (2 \times 3 \times 4) filled with ones.
- Array Inspection: For each array you create, display its dimensions, shape, size, data type, and the sum of its elements.
- Indexing: Access the third element of the one-dimensional array and the element at position ([2, 3]) in the two-dimensional matrix.
- Slicing: Extract a (2 \times 2) sub-matrix from the upper left corner of the two-dimensional matrix.
- Iterating: Iterate over the three-dimensional array, printing each two-dimensional section.
- Arithmetic Operations: Perform element-wise addition, subtraction, multiplication, and division on two arrays of your choice.
- Broadcasting: Demonstrate array broadcasting by adding a vector to each column of a matrix.
- Reshaping and Flattening: Reshape the three-dimensional array into a two-dimensional array and flatten it into a one-dimensional array.
- Matrix Multiplication: Perform a dot product between two matrices.
- Determinant and Inverse: Compute the determinant and inverse of a (2 \times 2) matrix.
- Eigenvalues and Eigenvectors: Find the eigenvalues and eigenvectors of a square matrix.
- Descriptive Statistics: Calculate the mean, median, variance, and standard deviation of an array.
- Correlation: Compute the correlation coefficient between two arrays.
- Polynomial Fitting: Given the data points ((x, y)), fit a polynomial of degree 2 and plot the original data points and the fitted curve using Matplotlib (optional).
- Explore more complex linear algebra operations, such as singular value decomposition (SVD).
- Use NumPy to generate random samples and explore probability distributions.
- First fork the repository
- Create a directory in answers directory with your student number
- Put .py files as follow: task1.py task2.py, ...
- Commit your solutions as a Python script (.py file) or a Jupyter notebook (.ipynb).
- Include comments in your code to explain your thought process and steps.
- Ensure your code is readable and well-organized.
Remember, the key to mastering NumPy is practice and exploration. Feel free to experiment beyond the tasks provided and utilize the NumPy documentation to learn about more functions and capabilities.