Python-NumPy Tutorial

Slides:



Advertisements
Similar presentations
What is shape function ? shape function is a function that will give the displacements inside an element if its displacement at all the node locations.
Advertisements

Lecture 4 Sept 8 Complete Chapter 3 exercises Chapter 4.
Matlab tutorial course Lesson 2: Arrays and data types
A Level Computing#BristolMet Session Objectives U2#S6 MUST identify different data types used in programming aka variable types SHOULD describe each data.
Scientific Computing with NumPy & SciPy NumPy Installation and Documentation  Not much on the home page—don’t buy the guide, it’s.
Class Opener:. Identifying Matrices Student Check:
Introduction to MATLAB adapted from Dr. Rolf Lakaemper.
Python Mini-Course University of Oklahoma Department of Psychology Lesson 21 NumPy 6/11/09 Python Mini-Course: Lesson 21 1.
3.6 Solving Systems Using Matrices You can use a matrix to represent and solve a system of equations without writing the variables. A matrix is a rectangular.
Python Crash Course Numpy & MatplotLib Sterrenkundig Practicum 2 V1.0 dd Hour 3.
1 Lecture 3 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
ECE 103 Engineering Programming Chapter 23 Multi-Dimensional Arrays Herbert G. Mayer, PSU CS Status 6/24/2014 Initial content copied verbatim from ECE.
MULTI-DIMENSIONAL ARRAYS 1. Multi-dimensional Arrays The types of arrays discussed so far are all linear arrays. That is, they all dealt with a single.
Python Scripting for Computational Science CPS 5401 Fall 2014 Shirley Moore, Instructor October 6,
PH2150 Scientific Computing Skills
13.4 Product of Two Matrices
Linear Algebra review (optional)
Numpy (Numerical Python)
Two-Dimension Arrays Computer Programming 2.
Introduction to Matrices
Chapter 3 Arrays and Vectors
Data Structures and Algorithms
Introduction to MATLAB
EGR 115 Introduction to Computing for Engineers
Motivations Thus far, you have used one-dimensional arrays to model linear collections of elements. You can use a two-dimensional array to represent a.
JavaScript: Functions.
Python NumPy AILab Batselem Jagvaral 2016 March.
Introduction to MATLAB
CSE Social Media & Text Analytics
Python Review.
Arrays An Array is an ordered collection of variables
WarmUp 2-3 on your calculator or on paper..
Digital Image Processing using MATLAB
Numerical Computing in Python
Java for Beginners University Greenwich Computing At School DASCO
Introduction to Python
MATH 493 Introduction to MATLAB
PH2150 Scientific Computing Skills
Matlab tutorial course
Vectorized Code, Logical Indexing
Vectors and Matrices I.
Digital Image Processing
Numpy (Numerical Python)
Numpy (Numerical Python)
Coding Concepts (Data- Types)
Data Types and Data Structures
Matrices.
Reference semantics, variables and names
Console.WriteLine(“Good luck!”);
Theano-Basic CSLT, NLP.
Data Intensive and Cloud Computing Matrices and Arrays Lecture 9
Scipy 'Ecosystem' containing a variety of scientific packages including iPython, numpy, matplotlib, and pandas. numpy is both a system for constructing.
Introduction to MATLAB
INC 161 , CPE 100 Computer Programming
Multi-Dimensional Arrays
Dr. Sampath Jayarathna Cal Poly Pomona
Introduction to Matlab
EET 2259 Unit 9 Arrays Read Bishop, Sections 6.1 to 6.3.
Linear Algebra review (optional)
Dr. Sampath Jayarathna Old Dominion University
EECS Introduction to Computing for the Physical Sciences
MATRICES MATRIX OPERATIONS.
Matrices.
Matrix A matrix is a rectangular arrangement of numbers in rows and columns Each number in a matrix is called an Element. The dimensions of a matrix are.
Arrays in MatLab Arrays can have any number dimensions
EE 194/BIO 196: Modeling,simulating and optimizing biological systems
Python Debugging Session
EE 194/BIO 196: Modeling,simulating and optimizing biological systems
Announcements.
COMPUTING.
Presentation transcript:

Python-NumPy Tutorial CIS 581

Intro to NumPy A Python-based Matlab-style library for scientific calculation Uses array as basic operation units For MATLAB Users: Array -- Matrix Indexing & Slicing Row Major -- Column Major

NumPy Arrays A NumPy array is a grid of values, all of the same type. The shape of an array is a tuple of integers giving the size of array along each dimension Creating arrays: np.array([]) np.zeros, np.ones, np.full, np.eye, np.empty, … np.arange np.random Code

Datatypes Some functions require specific datatypes to run properly np.uint8 -- for most images, .png, .jpg, etc. np.int16/32/64 -- integers of different bits length np.float16/32/64 -- floats of different bits length np.bool -- boolean value Manipulation: Code

Slicing Python indexing starts from 0 Slicing a[0:i] will have a[i] excluded Default in slicing Minus value in slicing Use a[0, :] and a[0, …] to omit other axis Use bool value as index Code

Element-wise functions +, -, *, /, &, | np.cos, np.sin, np.tan, np.radians, np.angles np.acos, np.asin, np.atan, np.atan2 np.round, np.ceil, np.floor np.cumsum np.log, np.log2, np.log10, np.exp np.bitwise_and, np.bitwise_or

Shape and broadcasting Most numpy functions has shape constraints for inputs (e.g., input element must equal for most element-wise functions) Use np.reshape() to manipulate the shape Broadcasting NumPy will automatically repeat array to meet shape requirements Start from the last dimension, must fulfill basic rules

Other important functions np.sum, np.mean, np.std, np.max, np.min axis, keep_dims np.sort, np.argsort np.where np.linalg Linear algebra module np.random Generate random variables