Numerical Python Tom LeFebvre.

Slides:



Advertisements
Similar presentations
Week 6 - Programming I So far, we’ve looked at simple programming via “scripts” = programs of sequentially evaluated commands Today, extend features to:
Advertisements

Chapter 9 IF Statement Bernard Chen. If Statement The main statement used for selecting from alternative actions based on test results It’s the primary.
Numerical Python Tom LeFebvre. Sept , 2002Numerical Python2 Since Python is an interpreted language, we need better performance particularly when.
Logic (continuation) Boolean Logic and Bit Operations.
Python Mini-Course University of Oklahoma Department of Psychology Lesson 21 NumPy 6/11/09 Python Mini-Course: Lesson 21 1.
Fundamental Programming Fundamental Programming More on Repetition.
Conditional statements and boolean expressions Arithmetic, relational and logical operators.
PH2150 Scientific Computing Skills Control Structures in Python In general, statements are executed sequentially, top to bottom. There are many instances.
IST 210: PHP Logic IST 210: Organization of Data IST2101.
From Word Embeddings To Document Distances
Virtual Environments and Computer Graphics
D. Phát triển thương hiệu
Điều trị chống huyết khối trong tai biến mạch máu não
Evolving Architecture for Beyond the Standard Model
HF NOISE FILTERS PERFORMANCE
L-Systems and Affine Transformations
CMSC423: Bioinformatic Algorithms, Databases and Tools
Some aspect concerning the LMDZ dynamical core and its use
Current State of Japanese Economy under Negative Interest Rate and Proposed Remedies Naoyuki Yoshino Dean Asian Development Bank Institute Professor Emeritus,
Front End Electronics for SOI Monolithic Pixel Sensor
Face Recognition Monday, February 1, 2016.
Summer Student Program First results
Fuel cell development program for electric vehicle
داده کاوی سئوالات نمونه
Inter-system biases estimation in multi-GNSS relative positioning with GPS and Galileo Cecile Deprez and Rene Warnant University of Liege, Belgium  
ლექცია 4 - ფული და ინფლაცია
On Robust Neighbor Discovery in Mobile Wireless Networks
Fairness-oriented Scheduling Support for Multicore Systems
Ch48 Statistics by Chtan FYHSKulai
The ABCD matrix for parabolic reflectors and its application to astigmatism free four-mirror cavities.
Limits on Anomalous WWγ and WWZ Couplings from DØ
Introduction to python programming
Lesson #4 Logical Operators and Selection Statements.
Lesson #4 Logical Operators and Selection Statements.
Bool operators and, or, not
Numeric Arrays Numeric Arrays Chapter 4.
BY GAWARE S.R. COMPUTER SCI. DEPARTMENT
Engineering Innovation Center
Introduction to Python
11/10/2018.
PH2150 Scientific Computing Skills
JavaScript Selection Statement Creating Array
CSE Social Media & Text Analytics
Introduction to Python
TUTORIAL 6 – BUBBLE SORTING AN ARRAY
CMSC 120: Visualizing Information 3/25/08
Lists in Python.
Use of Mathematics using Technology (Maltlab)
Introduction to Python
Python: Array Slicing Damian Gordon.
PH2150 Scientific Computing Skills
Control Structures: for & while Loops
Web DB Programming: PHP
Numpy (Numerical Python)
What does this do? def revList(L): if len(L) < = 1: return L x = L[0] LR = revList(L[1:]) return LR + x.
MATLAB Programming Indexing Copyright © Software Carpentry 2011
Coding Concepts (Data- Types)
Three Special Structures – Case, Do While, and Do Until
Starting Out with Programming Logic & Design
For Loops (Iteration 1) Programming Guides.
CSE 303 Concepts and Tools for Software Development
Dr. Sampath Jayarathna Cal Poly Pomona
And now for something completely different . . .
Midterm Review October 23, 2006 ComS 207: Programming I (in Java)
EE 194/BIO 196: Modeling biological systems
Introduction to Python
INTRODUCING PYTHON PANDAS:-SERIES
The return Statement © 2018 Kris Jordan.
Introduction to Computer Science
Control 9 / 25 / 19.
Presentation transcript:

Numerical Python Tom LeFebvre

Numerical Python Since Python is an interpreted language, we need better performance particularly when crunching numbers. Advantages: High-level language allows very fast development Disadvantages: Not always intuitive Sept. 24-27, 2002 Numerical Python

Numerical Python Numerical Python operates on “multiarrays” One line of Numerical Python processes one or more whole arrays, not just one number. Currently NumPy is implemented as an “extension” to Python. But soon it will be an intrinsic part of Python Sept. 24-27, 2002 Numerical Python

Importing Numeric >>> from Numeric import * You must import the Numeric module before using Numerical Python import Numeric or >>> from Numeric import * Sept. 24-27, 2002 Numerical Python

Making Numeric Arrays >>> a = array ([0, 1, -2, 6, -5]) >>> b = arrayrange(10) >>> b Sept. 24-27, 2002 Numerical Python

Multi-dimensional Arrays >>> a = array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) >>> a >>> a.shape Sept. 24-27, 2002 Numerical Python

Creating Special Arrays >>> BunchaZeros = zeros((4, 4)) >>> BunchaZeros >>> BunchaOnes = ones((4, 4)) >>> BunchaOnes Sept. 24-27, 2002 Numerical Python

Manipulating Arrays >>> BunchaThrees = BunchaOnes * 3 >>> f = arrayrange(0, 100, 5) >>> c = (f - 32) * 5 / 9 >>> c >>> c = (f - 32) * 5 / 9.0 >>> c Sept. 24-27, 2002 Numerical Python

Array Slicing Slicing Operator “[:]” array[start : stop : increment] array - a Numeric Python array start - begin here including this index stop - end here but do not include this index increment - skip this many Sept. 24-27, 2002 Numerical Python

Slicing Arrays >>> a = arrayrange(10) >>> a Sept. 24-27, 2002 Numerical Python

Slicing Multi-dimensional Arrays >>> b = reshape(arrayrange(9), (3, 3)) >>> b >>> b[0, 0] >>> b [2, 1] >>> b[-1, -1] Sept. 24-27, 2002 Numerical Python

Slicing Multi-dimensional Arrays >>> b >>> b[0:1, 0] >>> b[0:2, 0:2] >>> b [:] >>> b[::2] >>> b[::-1] >>> b[::-1, ::-1] Sept. 24-27, 2002 Numerical Python

Some Useful Functions >>> a = arrayrange(10) >>> a >>> add.reduce(a) Sept. 24-27, 2002 Numerical Python

Logical Functions - makes 0s or 1s >>> b = reshape(arrayrange(25), (5, 5)) >>> b >>> less (b, 12) >>> greater(b, 7) >>> less_equal(b, 10) Sept. 24-27, 2002 Numerical Python

Array Functions - where() “where” is the Numerical Python “if” statement where(condition, true value, false value) >>> b >>> c = where (less(b, 12), 0, b) >>> c Note: 0 is false, everything else is true Sept. 24-27, 2002 Numerical Python

Array Functions - clip() clip(array, min, max) >>> b >>> d = clip(b, 5, 15) >>> d Sept. 24-27, 2002 Numerical Python