Skip to content

Tina-Farshadi/NumpyIntroduction

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 

Repository files navigation

NumpyIntroduction

Objective

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.

Setup Instructions

  1. Python Installation: Ensure Python 3.8 or later is installed on your system.
  2. NumPy Installation: Install NumPy by running pip install numpy in your terminal or command prompt.

Assignment Tasks

Task 1: Exploring Array Basics

  1. 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.
  2. Array Inspection: For each array you create, display its dimensions, shape, size, data type, and the sum of its elements.

Task 2: Indexing, Slicing, and Iterating

  1. Indexing: Access the third element of the one-dimensional array and the element at position ([2, 3]) in the two-dimensional matrix.
  2. Slicing: Extract a (2 \times 2) sub-matrix from the upper left corner of the two-dimensional matrix.
  3. Iterating: Iterate over the three-dimensional array, printing each two-dimensional section.

Task 3: Operations and Manipulations

  1. Arithmetic Operations: Perform element-wise addition, subtraction, multiplication, and division on two arrays of your choice.
  2. Broadcasting: Demonstrate array broadcasting by adding a vector to each column of a matrix.
  3. Reshaping and Flattening: Reshape the three-dimensional array into a two-dimensional array and flatten it into a one-dimensional array.

Task 4: Linear Algebra in NumPy

  1. Matrix Multiplication: Perform a dot product between two matrices.
  2. Determinant and Inverse: Compute the determinant and inverse of a (2 \times 2) matrix.
  3. Eigenvalues and Eigenvectors: Find the eigenvalues and eigenvectors of a square matrix.

Task 5: Statistical Analysis

  1. Descriptive Statistics: Calculate the mean, median, variance, and standard deviation of an array.
  2. Correlation: Compute the correlation coefficient between two arrays.

Task 6: Advanced Applications

  • 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).

Additional Challenges (Optional)

  • Explore more complex linear algebra operations, such as singular value decomposition (SVD).
  • Use NumPy to generate random samples and explore probability distributions.

Submission Guidelines

  • 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.

Resources

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%