Python & Numpy A tutorial
|
|
- Amelia Ryan
- 5 years ago
- Views:
Transcription
1 Python & Numpy A tutorial Devert Alexandre School of Software Engineering of USTC 13 February 2012 Slide 1/38
2 Table of Contents 1 Why Python & Numpy 2 First steps with Python 3 Fun with lists 4 Quick tour of Numpy 5 Conclusion Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 2/38
3 Why Python I will provide code examples in Python All the algorithms I will introduce 150 lines Works on Windows, Linux, Mac,... It s easy to read It s free It s fun Best way to learn it program something for fun with it Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 3/38
4 Why Python Numpy is Python module to do scientific computing Helps to have short & easy to read code With practice, about same speed as C Increasingly popular in comp. sci. Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 4/38
5 Table of Contents 1 Why Python & Numpy 2 First steps with Python 3 Fun with lists 4 Quick tour of Numpy 5 Conclusion Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 5/38
6 Printing messages Your first program in Python p r i n t H e l l o, H e f e i! It will print Hello, Hefei! Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 6/38
7 Printing messages Let s use some variables name = A l e x age = p r i n t name, your age i s, age It will print Alex your age i s 31 Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 7/38
8 Printing messages You can also use something like printf in C name = A l e x age = p r i n t %s, your age i s %d % ( name, age ) It will print Alex, your age i s 31 Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 8/38
9 Variables Python defines a few default types a = I am a s t r i n g! # Those a r e s t r i n g s b = Me too ˆˆ c = 42 # This an i n t e g e r number d = # This i s a f l o a t i n g p o i n t number e = [ 7, 6, 2, 1, ORLY, 5 ] # This i s a l i s t f = ( 7, 6, 2, 1, ORLY, 5) # This i s a t u p l e g = { name : A l e x, age : 31} # This a d i c t i o n a r y Lists, tuples and dictionaries will be introduced later Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 9/38
10 Numbers Numbers works like in the C language a = 3 b = 5 c = ( a + 5 b ) / ( a ) csquare = c 2 # Same as : csquare = c c Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 10/38
11 Math module If you need common math functions, you should use the math module i m p o r t math x = math. s i n ( 0. 7 math. e ) y = math. c o s ( 0. 3 math. p i ) norm = math. s q r t ( x 2 + y 2) A module adds new functions and types Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 11/38
12 Conditionals Conditionals in Python i f b == 4 : p r i n t I do t h i s i f a == b : p r i n t I do t h i s e l s e : p r i n t I do t h a t i f a == c and c < 0. 0 : p r i n t I do t h i s e l i f a > 2. 0 c o r a + c < a 2 : p r i n t I do t h a t e l s e : p r i n t I do what? Note that indentation is important in Python Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 12/38
13 Loops Loops in Python w h i l e math. f a b s ( a ) < 1. 0 : a = b b += c 2 w h i l e b > 0. 0 : b /= c + a i f b == 1. 0 : b r e a k Note that indentation is really important in Python Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 13/38
14 Functions Function in Python def saysomething ( ) : p r i n t do t h i s def harmonicsum ( a, b ) i = a s = 0. 0 w h i l e i < b : s += 1. 0 / ( i + 1) i += 1 r e t u r n s saysomething ( ) p r i n t harmonicsum ( 0, 42) Note that indentation is really, really important in Python Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 14/38
15 Table of Contents 1 Why Python & Numpy 2 First steps with Python 3 Fun with lists 4 Quick tour of Numpy 5 Conclusion Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 15/38
16 Lists Lists will be important for us, as a dataset is made of list of data a = [ ] # Empty l i s t a = [ 1, 2, 3 ] # A l i s t w i t h 3 numbers a = [ [ 1, 2 ], [ 3, 4 ], [ 5, 6, 7 ] ] # A l i s t c o n t a i n i n g l i s t s a = [ H e l l o, 42, [ LOL, OMG ] ] # A l i s t can c o n t a i n a n y t h i n g Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 16/38
17 List of integers The function range build lists of integers p r i n t r a n g e ( 1 0 ) p r i n t r a n g e ( 5, 10) p r i n t r a n g e ( 1 5, 0, 2) It will print [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ] [ 5, 6, 7, 8, 9 ] [ 1 5, 13, 11, 9, 7, 5, 3, 1 ] Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 17/38
18 Iterating You can iterate through a list like this s = [ H e f e i, Suzhou, N a n j i n g, Kunming, Chengdu ] f o r s i n mylist : p r i n t H e l l o,, s,! Exactly like a loop... Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 18/38
19 Indexing Lists can be used as an array s = [ H e f e i, Suzhou, N a n j i n g, Kunming, Chengdu ] p r i n t l e n ( s ) # Length o f a l i s t p r i n t s [ 0 ] # F i r s t e l e m e n t p r i n t s [ 1 ] # Second e l e m e n t p r i n t s [ 2 ] # T h i rd e l e m e n t p r i n t s [ 1] # L a s t e l e m e n t p r i n t s [ 2] # B e f o r e l a s t e l e m e n t Negative indexes can help to have simpler, shorter code Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 19/38
20 Slicing Lists can be cut or assembled s = [ H e f e i, Suzhou, N a n j i n g, Kunming, Chengdu ] p r i n t s [ 1 : 4 ] p r i n t s [ : 4 ] p r i n t s [: 2] p r i n t s [ 1 : ] p r i n t s + [ B e i j i n g, Shanghai ] Will print [ Suzhou, N a n j i n g, Kunming ] [ H e f e i, Suzhou, N a n j i n g, Kunming ] [ H e f e i, Suzhou, N a n j i n g ] [ Suzhou, N a n j i n g, Kunming, Chengdu ] [ H e f e i, Suzhou, N a n j i n g, Kunming, Chengdu, B e i j i n g, Shanghai ] Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 20/38
21 Sorting Sorting is simple too a = [ 8, 3, 0, 2, 4, 1, 5, 9, 6, 7 ] a. s o r t ( ) p r i n t a Will print [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ] Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 21/38
22 List operations Common list operations are of course available a = [ 7, 1 3 ] a. append ( 4 2 ) # Add 42 a t t h e end o f t h e l i s t a. i n s e r t ( i, 9) # I n s e r t 9 b e f o r e p o s i t i o n i a. pop ( i ) # Remove e l e m e n t a p o s i t i o n i and r e t u r n i t a. remove ( 4 2 ) # Remove 42 from t h e l i s t min ( a ) # Return minimum element max ( a ) # Return maximum element sum ( a ) # Return sum of elements i f 13 i n a : # Test i f 13 e x i s t s i n l i s t p r i n t you got 13 i n a Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 22/38
23 List comprehension You can build lists from an other list a = [ 2 i + 1 f o r i i n r a n g e ( 1 0 ) ] p r i n t a a = [ 2 i + 1 f o r i in range (10) i f i % 3!= 0 ] p r i n t a It will print [ 1, 3, 5, 7, 9, 11, 13, 15, 17, 1 9 ] [ 3, 5, 9, 11, 15, 1 7 ] Short, simple & also very efficient on large lists! Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 23/38
24 Tuples comprehension This same powerful trick works for tuples a = (2 i + 1 f o r i i n r a n g e ( 1 0 ) ) p r i n t a a = (2 i + 1 f o r i in range ( 10) i f i % 3!= 0) p r i n t a It will print ( 1, 3, 5, 7, 9, 11, 13, 15, 17, 19) ( 3, 5, 9, 11, 15, 17) Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 24/38
25 Table of Contents 1 Why Python & Numpy 2 First steps with Python 3 Fun with lists 4 Quick tour of Numpy 5 Conclusion Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 25/38
26 Introducing : Numpy Numpy is Python module for scientific computing Written in C Add new types and function in Python Fast vector & matrix operations Python + Numpy = Enhanced Matlab, and for free Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 26/38
27 Vectors Numpy manipulate arrays. 1d array vector i m p o r t numpy p r i n t numpy. zeros (10) # Create vector of 10 zeros p r i n t numpy. ones (10) # Create vector of 10 ones p r i n t numpy. a r r a y ( [ 1. 0, 2. 0, 3. 0 ] ) # C r e a t e v e c t o r from a l i s t p r i n t numpy. l i n s p a c e ( 0. 0, 1. 0, 9) # C r e a t e a v e c t o r o f 10 v a l u e s i n [ 0. 0, 1. 0 ] p r i n t numpy. random. randn ( 5 ) # C r e a t e a v e c t o r o f 10 v a l u e s w i t h norm. d i s t r i b. It will print [ ] [ ] [ ] [ ] [ ] Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 27/38
28 Matrices Numpy manipulate arrays. 2d array matrices i m p o r t numpy p r i n t numpy. z e r o s ( ( 2, 3 ) ) # C r e a t e 2 x3 m a t r i x o f z e r o s p r i n t numpy. ones ( ( 2, 3 ) ) # C r e a t e 2 x3 m a t r i x o f ones p r i n t numpy. random. randn ( 2, 3) # C r e a t e 2 x3 m a t r i x o f norm. d i s t r i b. It will print [ [ ] [ ] ] [ [ ] [ ] ] [[ ] [ ] ] Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 28/38
29 Array shape An array s dimensions can be read and modified i m p o r t numpy A = numpy. ones (6) p r i n t A, A. shape A = A. r e s h a p e ( ( 3, 2 ) ) p r i n t A, A. shape A = A. r e s h a p e ( ( 2, 3 ) ) p r i n t A, A. shape It will print [ ] ( 6, ) [ [ ] [ ] [ ] ] ( 3, 2) [ [ ] [ ] ] ( 2, 3) Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 29/38
30 Indexing Access to coefficients of an array i m p o r t numpy A = numpy. l i n s p a c e ( 0, 1, 5) p r i n t A p r i n t A [ 1 ] M = numpy. a r r a y ( r a n g e ( 1, 7 ) ). r e s h a p e ( ( 2, 3 ) ) p r i n t M p r i n t M[ 1, 2 ] It will print [ ] [ [ ] [ ] ] 6 Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 30/38
31 Dot product Dot product between vectors/matrices i m p o r t numpy A = numpy. array ( range (1, 3 ) ) B = numpy. array ( range (3, 5 ) ) M = numpy. ones ( ( 3, 2 ) ) N = numpy. ones ( ( 2, 7 ) ) p r i n t A. dot (B) # Computes A. B p r i n t M. dot (A) # Computes M x A p r i n t M. dot (N) # Computes M x N It will print 11 [ ] [ [ ] [ ] [ ] ] Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 31/38
32 Data file loading i m p o r t numpy data = numpy. l o a d t x t ( s t u f f s. dat ) p r i n t data Figure: Program It will print Figure: Input file [ [ e e e e e+00] [ e e e e e+00] [ e e e e e+00] [ e e e e e 01] [ e e e e e 01] [ e e e e e 01]] Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 32/38
33 Statistics Computing some basic statistics, per column i m p o r t numpy data = numpy. l o a d t x t ( s t u f f s. dat ) p r i n t numpy. mean ( data, a x i s = 0) # mean f o r each column p r i n t numpy. s t d ( data, a x i s = 0) # s t d. dev. f o r each column p r i n t numpy. median ( data, a x i s = 0) # median f o r each column It s much faster than coding it yourself in Python Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 33/38
34 Deleting We often want to remove rows or columns i m p o r t numpy data = numpy. l o a d t x t ( l o l. dat ) data = numpy. d e l e t e ( data, 2, a x i s =0) p r i n t data data = numpy. l o a d t x t ( l o l. dat ) data = numpy. d e l e t e ( data, 2, a x i s =1) p r i n t data Figure: Program It will print Figure: Input file [ [ ] [ ] ] [ [ ] [ ] [ ] ] Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 34/38
35 Slicing Working with one column of a 2d array i m p o r t numpy data = numpy. l o a d t x t ( s t u f f s. dat ) p r i n t data [ 2 ] # P r i n t t h e 2nd column Figure: Program It will print Figure: Input file [ e e e e e+00] Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 35/38
36 Slicing Working with one row of a 2d array i m p o r t numpy data = numpy. l o a d t x t ( s t u f f s. dat ) p r i n t data [ :, 2 ] # P r i n t t h e 2nd row Figure: Program It will print Figure: Input file [ ] Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 36/38
37 Table of Contents 1 Why Python & Numpy 2 First steps with Python 3 Fun with lists 4 Quick tour of Numpy 5 Conclusion Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 37/38
38 Conclusion This is only a quick introduction! More things: eigen values, linear solver,... Memorizing this is USELESS Practising this is USEFUL Many tutorial and examples on the web Try to program some algorithms you know, and you will master all this very quickly Devert Alexandre (School of Software Engineering of USTC) Python & Numpy Slide 38/38
Scripting Languages Fast development, extensible programs
Scripting Languages Fast development, extensible programs Devert Alexandre School of Software Engineering of USTC November 30, 2012 Slide 1/60 Table of Contents 1 Introduction 2 Dynamic languages A Python
More informationIntroduction to Python
Introduction to Python Luis Pedro Coelho Institute for Molecular Medicine (Lisbon) Lisbon Machine Learning School II Luis Pedro Coelho (IMM) Introduction to Python Lisbon Machine Learning School II (1
More informationIntroduction to Python
Introduction to Python Luis Pedro Coelho luis@luispedro.org @luispedrocoelho European Molecular Biology Laboratory Lisbon Machine Learning School 2015 Luis Pedro Coelho (@luispedrocoelho) Introduction
More informationComp 11 Lectures. Dr. Mike Shah. August 9, Tufts University. Dr. Mike Shah (Tufts University) Comp 11 Lectures August 9, / 34
Comp 11 Lectures Dr. Mike Shah Tufts University August 9, 2017 Dr. Mike Shah (Tufts University) Comp 11 Lectures August 9, 2017 1 / 34 Please do not distribute or host these slides without prior permission.
More informationECE521 W17 Tutorial 1. Renjie Liao & Min Bai
ECE521 W17 Tutorial 1 Renjie Liao & Min Bai Schedule Linear Algebra Review Matrices, vectors Basic operations Introduction to TensorFlow NumPy Computational Graphs Basic Examples Linear Algebra Review
More informationNotater: INF3331. Veronika Heimsbakk December 4, Introduction 3
Notater: INF3331 Veronika Heimsbakk veronahe@student.matnat.uio.no December 4, 2013 Contents 1 Introduction 3 2 Bash 3 2.1 Variables.............................. 3 2.2 Loops...............................
More informationTutorial Three: Loops and Conditionals
Tutorial Three: Loops and Conditionals Imad Pasha Chris Agostino February 18, 2015 1 Introduction In lecture Monday we learned that combinations of conditionals and loops could make our code much more
More informationPractical Bioinformatics
4/24/2017 Resources Course website: http://histo.ucsf.edu/bms270/ Resources on the course website: Syllabus Papers and code (for downloading before class) Slides and transcripts (available after class)
More informationLecture 3: Special Matrices
Lecture 3: Special Matrices Feedback of assignment1 Random matrices The magic matrix commend magic() doesn t give us random matrix. Random matrix means we will get different matrices each time when we
More informationName: INSERT YOUR NAME HERE. Due to dropbox by 6pm PDT, Wednesday, December 14, 2011
AMath 584 Name: INSERT YOUR NAME HERE Take-home Final UWNetID: INSERT YOUR NETID Due to dropbox by 6pm PDT, Wednesday, December 14, 2011 The main part of the assignment (Problems 1 3) is worth 80 points.
More informationLectures about Python, useful both for beginners and experts, can be found at (http://scipy-lectures.github.io).
Random Matrix Theory (Sethna, "Entropy, Order Parameters, and Complexity", ex. 1.6, developed with Piet Brouwer) 2016, James Sethna, all rights reserved. This is an ipython notebook. This hints file is
More informationWrite a simple 1D DFT code in Python
Write a simple 1D DFT code in Python Ask Hjorth Larsen, asklarsen@gmail.com Keenan Lyon, lyon.keenan@gmail.com September 15, 2018 Overview Our goal is to write our own KohnSham (KS) density functional
More informationPYTHON, NUMPY, AND SPARK. Prof. Chris Jermaine
PYTHON, NUMPY, AND SPARK Prof. Chris Jermaine cmj4@cs.rice.edu 1 Next 1.5 Days Intro to Python for statistical/numerical programming (day one) Focus on basic NumPy API, using arrays efficiently Will take
More informationOutline Resource Introduction Usage Testing Exercises. Linked Lists COMP SCI / SFWR ENG 2S03. Department of Computing and Software McMaster University
COMP SCI / SFWR ENG 2S03 Department of Computing and Software McMaster University Week 10: November 7 - November 11 Outline 1 Resource 2 Introduction Nodes Illustration 3 Usage Accessing and Modifying
More informationI. Numerical Computing
I. Numerical Computing A. Lectures 1-3: Foundations of Numerical Computing Lecture 1 Intro to numerical computing Understand difference and pros/cons of analytical versus numerical solutions Lecture 2
More informationComp 11 Lectures. Mike Shah. July 26, Tufts University. Mike Shah (Tufts University) Comp 11 Lectures July 26, / 45
Comp 11 Lectures Mike Shah Tufts University July 26, 2017 Mike Shah (Tufts University) Comp 11 Lectures July 26, 2017 1 / 45 Please do not distribute or host these slides without prior permission. Mike
More informationNumPy 1.5. open source. Beginner's Guide. v g I. performance, Python based free open source NumPy. An action-packed guide for the easy-to-use, high
NumPy 1.5 Beginner's Guide An actionpacked guide for the easytouse, high performance, Python based free open source NumPy mathematical library using realworld examples Ivan Idris.; 'J 'A,, v g I open source
More informationPYTHON AND DATA SCIENCE. Prof. Chris Jermaine
PYTHON AND DATA SCIENCE Prof. Chris Jermaine cmj4@cs.rice.edu 1 Python Old language, first appeared in 1991 But updated often over the years Important characteristics Interpreted Dynamically-typed High
More informationCOMP 204. Object Oriented Programming (OOP) Mathieu Blanchette
COMP 204 Object Oriented Programming (OOP) Mathieu Blanchette 1 / 14 Object-Oriented Programming OOP is a way to write and structure programs to make them easier to design, understand, debug, and maintain.
More informationCOMS 6100 Class Notes
COMS 6100 Class Notes Daniel Solus September 20, 2016 1 General Remarks The Lecture notes submitted by the class have been very good. Integer division seemed to be a common oversight when working the Fortran
More informationIntroduction to Special Relativity
1 Introduction to Special Relativity PHYS 1301 F99 Prof. T.E. Coan version: 20 Oct 98 Introduction This lab introduces you to special relativity and, hopefully, gives you some intuitive understanding of
More informationL435/L555. Dept. of Linguistics, Indiana University Fall 2016
in in L435/L555 Dept. of Linguistics, Indiana University Fall 2016 1 / 13 in we know how to output something on the screen: print( Hello world. ) input: input() returns the input from the keyboard
More informationLab 2 Worksheet. Problems. Problem 1: Geometry and Linear Equations
Lab 2 Worksheet Problems Problem : Geometry and Linear Equations Linear algebra is, first and foremost, the study of systems of linear equations. You are going to encounter linear systems frequently in
More informationx y = 1, 2x y + z = 2, and 3w + x + y + 2z = 0
Section. Systems of Linear Equations The equations x + 3 y =, x y + z =, and 3w + x + y + z = 0 have a common feature: each describes a geometric shape that is linear. Upon rewriting the first equation
More informationOutline Python, Numpy, and Matplotlib Making Models with Polynomials Making Models with Monte Carlo Error, Accuracy and Convergence Floating Point Mod
Outline Python, Numpy, and Matplotlib Making Models with Polynomials Making Models with Monte Carlo Error, Accuracy and Convergence Floating Point Modeling the World with Arrays The World in a Vector What
More information/Users/jenskremkow/Science/Courses/python-summerschool-berlin/faculty/Day2/examples numpy.py September 2,
/Users/jenskremkow/Science/Courses/python-summerschool-berlin/faculty/Day2/examples numpy.py September 2, 2009 1 Numpy Many of the examples are taken from: http://www.scipy.org/cookbook Building Arrays
More informationCOMP 204. Exceptions continued. Yue Li based on material from Mathieu Blanchette, Carlos Oliver Gonzalez and Christopher Cameron
COMP 204 Exceptions continued Yue Li based on material from Mathieu Blanchette, Carlos Oliver Gonzalez and Christopher Cameron 1 / 27 Types of bugs 1. Syntax errors 2. Exceptions (runtime) 3. Logical errors
More informationCSC236 Week 4. Larry Zhang
CSC236 Week 4 Larry Zhang 1 Announcements PS2 due on Friday This week s tutorial: Exercises with big-oh PS1 feedback People generally did well Writing style need to be improved. This time the TAs are lenient,
More informationf = Xw + b, We can compute the total square error of the function values above, compared to the observed training set values:
Linear regression Much of machine learning is about fitting functions to data. That may not sound like an exciting activity that will give us artificial intelligence. However, representing and fitting
More informationPython. Tutorial. Jan Pöschko. March 22, Graz University of Technology
Tutorial Graz University of Technology March 22, 2010 Why? is: very readable easy to learn interpreted & interactive like a UNIX shell, only better object-oriented but not religious about it slower than
More informationVectors for Beginners
Vectors for Beginners Leo Dorst September 6, 2007 1 Three ways of looking at linear algebra We will always try to look at what we do in linear algebra at three levels: geometric: drawing a picture. This
More informationError Correcting Codes Prof. Dr. P. Vijay Kumar Department of Electrical Communication Engineering Indian Institute of Science, Bangalore
(Refer Slide Time: 00:15) Error Correcting Codes Prof. Dr. P. Vijay Kumar Department of Electrical Communication Engineering Indian Institute of Science, Bangalore Lecture No. # 03 Mathematical Preliminaries:
More informationMachine Learning 11. week
Machine Learning 11. week Feature Extraction-Selection Dimension reduction PCA LDA 1 Feature Extraction Any problem can be solved by machine learning methods in case of that the system must be appropriately
More informationModern Functional Programming and Actors With Scala and Akka
Modern Functional Programming and Actors With Scala and Akka Aaron Kosmatin Computer Science Department San Jose State University San Jose, CA 95192 707-508-9143 akosmatin@gmail.com Abstract For many years,
More informationAssignment 1 Physics/ECE 176
Assignment 1 Physics/ECE 176 Made available: Thursday, January 13, 211 Due: Thursday, January 2, 211, by the beginning of class. Overview Before beginning this assignment, please read carefully the part
More informationNumerical and Algebraic Fractions
Numerical and Algebraic Fractions Aquinas Maths Department Preparation for AS Maths This unit covers numerical and algebraic fractions. In A level, solutions often involve fractions and one of the Core
More informationHomework 2: MDPs and Search
Graduate Artificial Intelligence 15-780 Homework 2: MDPs and Search Out on February 15 Due on February 29 Problem 1: MDPs [Felipe, 20pts] Figure 1: MDP for Problem 1. States are represented by circles
More information2 Getting Started with Numerical Computations in Python
1 Documentation and Resources * Download: o Requirements: Python, IPython, Numpy, Scipy, Matplotlib o Windows: google "windows download (Python,IPython,Numpy,Scipy,Matplotlib" o Debian based: sudo apt-get
More informationConditioning and Stability
Lab 17 Conditioning and Stability Lab Objective: Explore the condition of problems and the stability of algorithms. The condition number of a function measures how sensitive that function is to changes
More informationDepartment of Chemical Engineering University of California, Santa Barbara Spring Exercise 2. Due: Thursday, 4/19/09
Department of Chemical Engineering ChE 210D University of California, Santa Barbara Spring 2012 Exercise 2 Due: Thursday, 4/19/09 Objective: To learn how to compile Fortran libraries for Python, and to
More informationVPython Class 2: Functions, Fields, and the dreaded ˆr
Physics 212E Classical and Modern Physics Spring 2016 1. Introduction VPython Class 2: Functions, Fields, and the dreaded ˆr In our study of electric fields, we start with a single point charge source
More information/home/thierry/columbia/msongsdb/pyreport_tutorials/tutorial1/tutorial1.py January 23, 20111
/home/thierry/columbia/msongsdb/pyreport_tutorials/tutorial1/tutorial1.py January 23, 20111 27 """ 28 Tutorial for the Million Song Dataset 29 30 by Thierry Bertin - Mahieux ( 2011) Columbia University
More information(Mathematical Operations with Arrays) Applied Linear Algebra in Geoscience Using MATLAB
Applied Linear Algebra in Geoscience Using MATLAB (Mathematical Operations with Arrays) Contents Getting Started Matrices Creating Arrays Linear equations Mathematical Operations with Arrays Using Script
More information1 Problem 1 Solution. 1.1 Common Mistakes. In order to show that the matrix L k is the inverse of the matrix M k, we need to show that
1 Problem 1 Solution In order to show that the matrix L k is the inverse of the matrix M k, we need to show that Since we need to show that Since L k M k = I (or M k L k = I). L k = I + m k e T k, M k
More informationLab 2: Static Response, Cantilevered Beam
Contents 1 Lab 2: Static Response, Cantilevered Beam 3 1.1 Objectives.......................................... 3 1.2 Scalars, Vectors and Matrices (Allen Downey)...................... 3 1.2.1 Attribution.....................................
More informationHW5 computer problem: modelling a dye molecule Objectives By the end of this lab you should: Know how to manipulate complex numbers and matrices. Prog
HW5 computer problem: modelling a dye molecule Objectives By the end of this lab you should: Know how to manipulate complex numbers and matrices. Programming environment: Spyder. To implement this, do
More informationDynamics of Ocean Structures Prof. Dr. Srinivasan Chandrasekaran Department of Ocean Engineering Indian Institute of Technology, Madras
Dynamics of Ocean Structures Prof. Dr. Srinivasan Chandrasekaran Department of Ocean Engineering Indian Institute of Technology, Madras Module - 1 Lecture - 20 Orthogonality of modes (Refer Slide Time:
More informationLecture 1: Asymptotics, Recurrences, Elementary Sorting
Lecture 1: Asymptotics, Recurrences, Elementary Sorting Instructor: Outline 1 Introduction to Asymptotic Analysis Rate of growth of functions Comparing and bounding functions: O, Θ, Ω Specifying running
More informationIntroduction to Python and its unit testing framework
Introduction to Python and its unit testing framework Instructions These are self evaluation exercises. If you know no python then work through these exercises and it will prepare yourself for the lab.
More informationIntroduction to Cryptology Dr. Sugata Gangopadhyay Department of Computer Science and Engineering Indian Institute of Technology, Roorkee
Introduction to Cryptology Dr. Sugata Gangopadhyay Department of Computer Science and Engineering Indian Institute of Technology, Roorkee Lecture 05 Problem discussion on Affine cipher and perfect secrecy
More informationBusiness Analytics and Data Mining Modeling Using R Prof. Gaurav Dixit Department of Management Studies Indian Institute of Technology, Roorkee
Business Analytics and Data Mining Modeling Using R Prof. Gaurav Dixit Department of Management Studies Indian Institute of Technology, Roorkee Lecture - 04 Basic Statistics Part-1 (Refer Slide Time: 00:33)
More informationMath 308 Midterm Answers and Comments July 18, Part A. Short answer questions
Math 308 Midterm Answers and Comments July 18, 2011 Part A. Short answer questions (1) Compute the determinant of the matrix a 3 3 1 1 2. 1 a 3 The determinant is 2a 2 12. Comments: Everyone seemed to
More informationAnd, even if it is square, we may not be able to use EROs to get to the identity matrix. Consider
.2. Echelon Form and Reduced Row Echelon Form In this section, we address what we are trying to achieve by doing EROs. We are trying to turn any linear system into a simpler one. But what does simpler
More informationTwo problems to be solved. Example Use of SITATION. Here is the main menu. First step. Now. To load the data.
Two problems to be solved Example Use of SITATION Mark S. Daskin Department of IE/MS Northwestern U. Evanston, IL 1. Minimize the demand weighted total distance (or average distance) Using 10 facilities
More informationA Glimpse at Scipy FOSSEE. June Abstract This document shows a glimpse of the features of Scipy that will be explored during this course.
A Glimpse at Scipy FOSSEE June 010 Abstract This document shows a glimpse of the features of Scipy that will be explored during this course. 1 Introduction SciPy is open-source software for mathematics,
More information5. Sequences & Recursion
5. Sequences & Recursion Terence Sim 1 / 42 A mathematician, like a painter or poet, is a maker of patterns. Reading Sections 5.1 5.4, 5.6 5.8 of Epp. Section 2.10 of Campbell. Godfrey Harold Hardy, 1877
More informationPython Tutorial on Reading in & Manipulating Fits Images and Creating Image Masks (with brief introduction on DS9)
1 Tyler James Metivier Professor Whitaker Undergrad. Research February 26, 2017 Python Tutorial on Reading in & Manipulating Fits Images and Creating Image Masks (with brief introduction on DS9) Abstract:
More informationDM534 - Introduction to Computer Science
Department of Mathematics and Computer Science University of Southern Denmark, Odense October 21, 2016 Marco Chiarandini DM534 - Introduction to Computer Science Training Session, Week 41-43, Autumn 2016
More informationComp 11 Lectures. Mike Shah. July 26, Tufts University. Mike Shah (Tufts University) Comp 11 Lectures July 26, / 40
Comp 11 Lectures Mike Shah Tufts University July 26, 2017 Mike Shah (Tufts University) Comp 11 Lectures July 26, 2017 1 / 40 Please do not distribute or host these slides without prior permission. Mike
More informationExperiment 1: Linear Regression
Experiment 1: Linear Regression August 27, 2018 1 Description This first exercise will give you practice with linear regression. These exercises have been extensively tested with Matlab, but they should
More informationSkriptsprachen. Numpy und Scipy. Kai Dührkop. Lehrstuhl fuer Bioinformatik Friedrich-Schiller-Universitaet Jena
Skriptsprachen Numpy und Scipy Kai Dührkop Lehrstuhl fuer Bioinformatik Friedrich-Schiller-Universitaet Jena kai.duehrkop@uni-jena.de 24. September 2015 24. September 2015 1 / 37 Numpy Numpy Numerische
More informationFunctions in Python L435/L555. Dept. of Linguistics, Indiana University Fall Functions in Python. Functions.
L435/L555 Dept. of Linguistics, Indiana University Fall 2016 1 / 18 What is a function? Definition A function is something you can call (possibly with some parameters, i.e., the things in parentheses),
More informationReview for Exam 1. Erik G. Learned-Miller Department of Computer Science University of Massachusetts, Amherst Amherst, MA
Review for Exam Erik G. Learned-Miller Department of Computer Science University of Massachusetts, Amherst Amherst, MA 0003 March 26, 204 Abstract Here are some things you need to know for the in-class
More informationClass Note #14. In this class, we studied an algorithm for integer multiplication, which. 2 ) to θ(n
Class Note #14 Date: 03/01/2006 [Overall Information] In this class, we studied an algorithm for integer multiplication, which improved the running time from θ(n 2 ) to θ(n 1.59 ). We then used some of
More informationPython. chrysn
Python chrysn 2008-09-25 Introduction Structure, Language & Syntax Strengths & Weaknesses Introduction Structure, Language & Syntax Strengths & Weaknesses Python Python is an interpreted,
More informationCS 231: Algorithmic Problem Solving
CS 231: Algorithmic Problem Solving Naomi Nishimura Module 4 Date of this version: June 11, 2018 WARNING: Drafts of slides are made available prior to lecture for your convenience. After lecture, slides
More information7 Principal Component Analysis
7 Principal Component Analysis This topic will build a series of techniques to deal with high-dimensional data. Unlike regression problems, our goal is not to predict a value (the y-coordinate), it is
More informationDesigning Information Devices and Systems I Spring 2018 Lecture Notes Note Introduction to Linear Algebra the EECS Way
EECS 16A Designing Information Devices and Systems I Spring 018 Lecture Notes Note 1 1.1 Introduction to Linear Algebra the EECS Way In this note, we will teach the basics of linear algebra and relate
More informationCSC2515 Assignment #2
CSC2515 Assignment #2 Due: Nov.4, 2pm at the START of class Worth: 18% Late assignments not accepted. 1 Pseudo-Bayesian Linear Regression (3%) In this question you will dabble in Bayesian statistics and
More informationLinear algebra and differential equations (Math 54): Lecture 8
Linear algebra and differential equations (Math 54): Lecture 8 Vivek Shende February 11, 2016 Hello and welcome to class! Last time We studied the formal properties of determinants, and how to compute
More informationLecture 10: Powers of Matrices, Difference Equations
Lecture 10: Powers of Matrices, Difference Equations Difference Equations A difference equation, also sometimes called a recurrence equation is an equation that defines a sequence recursively, i.e. each
More informationLinear Referencing in Boulder County, CO. Getting Started
Linear Referencing in Boulder County, CO Getting Started 1 Authors Janie Pierre GIS Technician, Boulder County Road centerline and storm sewer geodatabases & maps John Mosher GIS Specialist, Boulder County
More informationAssignment 4. CSci 3110: Introduction to Algorithms. Sample Solutions
Assignment 4 CSci 3110: Introduction to Algorithms Sample Solutions Question 1 Denote the points by p 1, p 2,..., p n, ordered by increasing x-coordinates. We start with a few observations about the structure
More informationAppendix 2: Linear Algebra
Appendix 2: Linear Algebra This appendix provides a brief overview of operations using linear algebra, and how they are implemented in Mathcad. This overview should provide readers with the ability to
More informationProfessor Terje Haukaas University of British Columbia, Vancouver Notation
Notation This document establishes the notation that is employed throughout these notes. It is intended as a look-up source during the study of other documents and software on this website. As a general
More informationApplied Machine Learning Lecture 2, part 1: Basic linear algebra; linear algebra in NumPy and SciPy. Richard Johansson
Applied Machine Learning Lecture 2, part 1: Basic linear algebra; linear algebra in NumPy and SciPy Richard Johansson linear algebra linear algebra is the branch of mathematics that deals with relationships
More informationHOMEWORK #4: LOGISTIC REGRESSION
HOMEWORK #4: LOGISTIC REGRESSION Probabilistic Learning: Theory and Algorithms CS 274A, Winter 2019 Due: 11am Monday, February 25th, 2019 Submit scan of plots/written responses to Gradebook; submit your
More informationNUMERICAL ANALYSIS WEEKLY OVERVIEW
NUMERICAL ANALYSIS WEEKLY OVERVIEW M. AUTH 1. Monday 28 August Students are encouraged to download Anaconda Python. Anaconda is a version of Python that comes with some numerical packages (numpy and matplotlib)
More informationVectorization. Yu Wu, Ishan Patil. October 13, 2017
Vectorization Yu Wu, Ishan Patil October 13, 2017 Exercises to be covered We will implement some examples of image classification algorithms using a subset of the MNIST dataset logistic regression for
More informationepistasis Documentation
epistasis Documentation Release 0.1 Zach Sailer May 19, 2017 Contents 1 Table of Contents 3 1.1 Setup................................................... 3 1.2 Basic Usage...............................................
More informationDesigning Information Devices and Systems I Fall 2018 Lecture Notes Note Introduction to Linear Algebra the EECS Way
EECS 16A Designing Information Devices and Systems I Fall 018 Lecture Notes Note 1 1.1 Introduction to Linear Algebra the EECS Way In this note, we will teach the basics of linear algebra and relate it
More informationECE 250 / CPS 250 Computer Architecture. Basics of Logic Design Boolean Algebra, Logic Gates
ECE 250 / CPS 250 Computer Architecture Basics of Logic Design Boolean Algebra, Logic Gates Benjamin Lee Slides based on those from Andrew Hilton (Duke), Alvy Lebeck (Duke) Benjamin Lee (Duke), and Amir
More informationMATH36061 Convex Optimization
M\cr NA Manchester Numerical Analysis MATH36061 Convex Optimization Martin Lotz School of Mathematics The University of Manchester Manchester, September 26, 2017 Outline General information What is optimization?
More informationNeural Networks Teaser
1/11 Neural Networks Teaser February 27, 2017 Deep Learning in the News 2/11 Go falls to computers. Learning 3/11 How to teach a robot to be able to recognize images as either a cat or a non-cat? This
More informationConjugate-Gradient. Learn about the Conjugate-Gradient Algorithm and its Uses. Descent Algorithms and the Conjugate-Gradient Method. Qx = b.
Lab 1 Conjugate-Gradient Lab Objective: Learn about the Conjugate-Gradient Algorithm and its Uses Descent Algorithms and the Conjugate-Gradient Method There are many possibilities for solving a linear
More informationLecture 2: Linear regression
Lecture 2: Linear regression Roger Grosse 1 Introduction Let s ump right in and look at our first machine learning algorithm, linear regression. In regression, we are interested in predicting a scalar-valued
More informationDivide-Conquer-Glue. Divide-Conquer-Glue Algorithm Strategy. Skyline Problem as an Example of Divide-Conquer-Glue
Divide-Conquer-Glue Tyler Moore CSE 3353, SMU, Dallas, TX February 19, 2013 Portions of these slides have been adapted from the slides written by Prof. Steven Skiena at SUNY Stony Brook, author of Algorithm
More informationNumerical Methods. for Math 451. Dr. Randall Paul. January 19, 2018
Numerical Methods for Math 451 Dr. Randall Paul January 19, 2018 This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. The essence of the license is
More informationSupervised Learning Coursework
Supervised Learning Coursework John Shawe-Taylor Tom Diethe Dorota Glowacka November 30, 2009; submission date: noon December 18, 2009 Abstract Using a series of synthetic examples, in this exercise session
More informationCanonical Forms Some questions to be explored by high school investigators William J. Martin, WPI
MME 529 June 2017 Canonical Forms Some questions to be explored by high school investigators William J. Martin, WPI Here are some exercises based on various ideas of canonical form in mathematics. Perhaps
More informationLinear Transformations
Lab 4 Linear Transformations Lab Objective: Linear transformations are the most basic and essential operators in vector space theory. In this lab we visually explore how linear transformations alter points
More informationSPARSE TENSORS DECOMPOSITION SOFTWARE
SPARSE TENSORS DECOMPOSITION SOFTWARE Papa S Diaw, Master s Candidate Dr. Michael W. Berry, Major Professor Department of Electrical Engineering and Computer Science University of Tennessee, Knoxville
More informationRead all questions and answers carefully! Do not make any assumptions about the code other than those that are clearly stated.
Read all questions and answers carefully! Do not make any assumptions about the code other than those that are clearly stated. CS177 Fall 2014 Final - Page 2 of 38 December 17th, 10:30am 1. Consider we
More informationOutline Resource Introduction Usage Testing Exercises. Linked Lists COMP SCI / SFWR ENG 2S03. Department of Computing and Software McMaster University
COMP SCI / SFWR ENG 2S03 Department of Computing and Software McMaster University Week 10: November 10 - November 14 Outline 1 Resource 2 Introduction Nodes Illustration 3 Usage Adding Finding and Removing
More informationIntroduction to Parallel Programming in OpenMP Dr. Yogish Sabharwal Department of Computer Science & Engineering Indian Institute of Technology, Delhi
Introduction to Parallel Programming in OpenMP Dr. Yogish Sabharwal Department of Computer Science & Engineering Indian Institute of Technology, Delhi Lecture - 33 Parallel LU Factorization So, now, how
More informationLecture 3. Big-O notation, more recurrences!!
Lecture 3 Big-O notation, more recurrences!! Announcements! HW1 is posted! (Due Friday) See Piazza for a list of HW clarifications First recitation section was this morning, there s another tomorrow (same
More informationCrash Course on TensorFlow! Vincent Lepetit!
Crash Course on TensorFlow Vincent Lepetit 1 TensorFlow Created by Google for easily implementing Deep Networks; Library for Python, but can also be used with C and Java; Exists for Linux, Mac OSX, Windows;
More informationLecture 10: Linear Multistep Methods (LMMs)
Lecture 10: Linear Multistep Methods (LMMs) 2nd-order Adams-Bashforth Method The approximation for the 2nd-order Adams-Bashforth method is given by equation (10.10) in the lecture note for week 10, as
More informationWorksheet 1: Integrators
Simulation Methods in Physics I WS 2014/2015 Worksheet 1: Integrators Olaf Lenz Alexander Schlaich Stefan Kesselheim Florian Fahrenberger Peter Košovan October 22, 2014 Institute for Computational Physics,
More informationLinear Algebra and TI 89
Linear Algebra and TI 89 Abdul Hassen and Jay Schiffman This short manual is a quick guide to the use of TI89 for Linear Algebra. We do this in two sections. In the first section, we will go over the editing
More information