Python Mini-Course University of Oklahoma Department of Psychology Lesson 21 NumPy 6/11/09 Python Mini-Course: Lesson 21 1.

Slides:



Advertisements
Similar presentations
Python Mini-Course University of Oklahoma Department of Psychology Day 4 – Lesson 15 Tuples 5/02/09 Python Mini-Course: Day 4 – Lesson 15 1.
Advertisements

Geoprocessing with GDAL and Numpy in Python Delong Zhao
Computer Science 112 Fundamentals of Programming II Bucket Sort: An O(N) Sort Algorithm.
Python Mini-Course University of Oklahoma Department of Psychology Lesson 16 Dictionaries 5/10/09 Python Mini-Course: Lesson 16 1.
1 Pendahuluan Pertemuan 5 Matakuliah: H0062/Teori Sistem Tahun: 2006.
Multidimensional Arrays in Java Vidhu S. Kapadia.
Lecture 7 Sept 19, 11 Goals: two-dimensional arrays (continued) matrix operations circuit analysis using Matlab image processing – simple examples Chapter.
Lecture 6 Sept 15, 09 Goals: two-dimensional arrays matrix operations circuit analysis using Matlab image processing – simple examples.
Concatenation MATLAB lets you construct a new vector by concatenating other vectors: – A = [B C D... X Y Z] where the individual items in the brackets.
Chapter 6 Arrays & Clusters. LabVIEW Arrays > Collection of Elements > Same Data Type > Variable-Sized > One or More Dimensions.
Lecture 4 Sept 7 Chapter 4. Chapter 4 – arrays, collections and indexing This chapter discusses the basic calculations involving rectangular collections.
Lesson 5 Index Laws and Simplifying Algebra. Mathswatch 102/111.
Python Mini-Course University of Oklahoma Department of Psychology Day 1 – Lesson 2 Fundamentals of Programming Languages 4/5/09 Python Mini-Course: Day.
COMPUTER SCIENCE FEBRUARY 2011 Lists in Python. Introduction to Lists Lists (aka arrays): an ordered set of elements  A compound data type, like strings.
APL and J Functional programming with linear algebra Large set of primitive operations Very compact program representation Regular grammar, uniform abbreviation.
Python Mini-Course University of Oklahoma Department of Psychology Lesson 19 Handling Exceptions 6/09/09 Python Mini-Course: Lesson 19 1.
Copyright © 2012 Pearson Education, Inc. Chapter 8 Two Dimensional Arrays.
Computation for Physics 計算物理概論
Python Mini-Course University of Oklahoma Department of Psychology Day 2 – Lesson 6 Program Design 4/18/09 Python Mini-Course: Day 2 - Lesson 6 1.
Python Mini-Course University of Oklahoma Department of Psychology Day 2 – Lesson 9 Iteration: Recursion 5/02/09 Python Mini-Course: Day 3 - Lesson 9 1.
Introduction to Python Session 2: Beginning Numerical Python and Visualization Jeremy Chen.
418512: Computer Programming Languages Lecture 7 Pramook Khungurn TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A AAAA.
Introduction to Python By Neil Cook Twitter: njcuk Slides/Notes:
Scientific Computing with NumPy & SciPy NumPy Installation and Documentation  Not much on the home page—don’t buy the guide, it’s.
Scientific Computing Division A tutorial Introduction to Fortran Siddhartha Ghosh Consulting Services Group.
CIT 590 Intro to Programming First lecture on Java.
Python Mini-Course University of Oklahoma Department of Psychology Day 4 – Lesson 13 Case study: Word play 05/02/09 Python Mini-Course: Day 4 – Lesson.
Linear Algebra 1.Basic concepts 2.Matrix operations.
Python Crash Course Numpy 3 rd year Bachelors V1.0 dd Hour 5.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 8 Lists and Tuples.
Basics Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Python Mini-Course University of Oklahoma Department of Psychology Day 3 – Lesson 11 Using strings and sequences 5/02/09 Python Mini-Course: Day 3 – Lesson.
Open Area Model of Multiplication
CIS 601 Fall 2003 Introduction to MATLAB Longin Jan Latecki Based on the lectures of Rolf Lakaemper and David Young.
Chapter 8 Arrays. A First Book of ANSI C, Fourth Edition2 Introduction Atomic variable: variable whose value cannot be further subdivided into a built-in.
Python & NetworkX Youn-Hee Han
LISTS and TUPLES. Topics Sequences Introduction to Lists List Slicing Finding Items in Lists with the in Operator List Methods and Useful Built-in Functions.
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.
SEQUENTIAL AND OBJECT ORIENTED PROGRAMMING Arrays.
LINEAR MODELS AND MATRIX ALGEBRA
CIS 595 MATLAB First Impressions. MATLAB This introduction will give Some basic ideas Main advantages and drawbacks compared to other languages.
NumPy, SciPy, Mpi4Py Shepelenko Olha. History of NumPy Originally, Python was not developed as a language for numerical computing. However, due to its.
Python Scripting for Computational Science CPS 5401 Fall 2014 Shirley Moore, Instructor October 6,
PH2150 Scientific Computing Skills
Linear Algebra review (optional)
Numerical Python Tom LeFebvre.
Hashing Exercises.
Introduction to MATLAB
CSE Social Media & Text Analytics
Numerical Computing in Python
Python for Scientific Computing
PH2150 Scientific Computing Skills
Matlab tutorial course
while loops; logic; random numbers; tuples
Numpy (Numerical Python)
Topics Sequences Introduction to Lists List Slicing
MATLAB Programming Basics Copyright © Software Carpentry 2011
Python Crash Course Numpy
ARRAYS 2 GCSE COMPUTER SCIENCE.
Data Intensive and Cloud Computing Matrices and Arrays Lecture 9
Topics Sequences Lists Copying Lists Processing Lists
Simulation And Modeling
Multi-Dimensional Arrays
Dr. Sampath Jayarathna Cal Poly Pomona
Topics Sequences Introduction to Lists List Slicing
Linear Algebra review (optional)
Python fundamental.
Tuple.
Introduction to Computer Science
Presentation transcript:

Python Mini-Course University of Oklahoma Department of Psychology Lesson 21 NumPy 6/11/09 Python Mini-Course: Lesson 21 1

Lesson objectives 1. Use the NumPy package 6/11/09 Python Mini-Course: Lesson 21 2

What is NumPy? NumPy is the fundamental package needed for scientific computing with Python. It contains: a powerful N-dimensional array object basic linear algebra functions basic Fourier transforms sophisticated random number capabilities tools for integrating Fortran code tools for integrating C/C++ code 6/11/09 Python Mini-Course: Lesson 21 3

NumPy documentation Official documentation The NumPy book Example list st_With_Doc st_With_Doc 6/11/09 Python Mini-Course: Lesson 21 4

The ndarray data structure NumPy adds a new data structure to Python – the ndarray An N-dimensional array is a homogeneous collection of “items” indexed using N integers Defined by: 1. the shape of the array, and 2. the kind of item the array is composed of 6/11/09 Python Mini-Course: Lesson 21 5

Array shape ndarrays are rectangular The shape of the array is a tuple of N integers (one for each dimension) 6/11/09 Python Mini-Course: Lesson 21 6

Array item types Every ndarray is a homogeneous collection of exactly the same data-type every item takes up the same size block of memory each block of memory in the array is interpreted in exactly the same way 6/11/09 Python Mini-Course: Lesson 21 7

6/11/09 Python Mini-Course: Lesson 21 8

6/11/09 Python Mini-Course: Lesson 21 9

Example: creating an array import numpy a = array([[1,2,3], [4,5,6], [7,8,9]]) a.shape a.dtype 6/11/09 Python Mini-Course: Lesson 21 10

Indexing arrays Use a tuple to index multi- dimensional arrays Example: a[1,2] 6/11/09 Python Mini-Course: Lesson 21 11

Slicing arrays Slicing arrays is almost the same as slicing lists, except you can specify multiple dimensions 6/11/09 Python Mini-Course: Lesson 21 12

Examples: Slicing arrays a[1] a[1,:] a[1,1:] a[:1,1:] 6/11/09 Python Mini-Course: Lesson 21 13

Some ndarray methods ndarray. tolist () The contents of self as a nested list ndarray. copy () Return a copy of the array ndarray. fill (scalar) Fill an array with the scalar value 6/11/09 Python Mini-Course: Lesson 21 14

Some NumPy functions abs() add() binomial() cumprod() cumsum() floor() histogram() min() max() multipy() polyfit() randint() shuffle() transpose() 6/11/09 Python Mini-Course: Lesson 21 15

Suggested exercise Complete the desc_stat_calc.py program 6/11/09 Python Mini-Course: Lesson 21 16