R: A Quick Reference

Size: px
Start display at page:

Download "R: A Quick Reference"

Transcription

1 R: A Quick Reference Colorado Reed January 17, 2012 Contents 1 Basics Arrays and Matrices Lists Loading Packages Loops Operators Vectors Usage Notes Data Loading Data Debugging Interactive Debugging Functions Anonymous Function Other Function Helpfuls Objects S4 Objects Methods and Generic Functions Creating an R package S3 Objects

2 6 Syntax 11 7 Plotting & Visualization D Plots Labels and Such Random The R Language Notes 12 9 Appendix: Handy Function Reference Appendix: Assorted Tips 14 1 Basics 1.1 Arrays and Matrices > a=array ( 1 : 1 2, dim=c ( 3, 4 ) ) > a [, 1 ] [, 2 ] [, 3 ] [, 4 ] [ 1, ] [ 2, ] [ 3, ] > m=matrix ( 1 : 1 2, nrow=3, ncol =4) # 2D array > m [, 1 ] [, 2 ] [, 3 ] [, 4 ] [ 1, ] [ 2, ] [ 3, ] Access elements of an array/matrix using commas (leave blank to access everything in the row/column/etc) or slice using a colon. > a=array ( 1 : 1 2, dim=c ( 3, 4 ) ) > a [, 2 : 3 ] [, 1 ] [, 2 ] [ 1, ] 4 7 [ 2, ] 5 8 2

3 [ 3, ] 6 9 Use negative indices to specify elements that should not be included. 1.2 Lists Lists can contain heterogeneous objects and named components. > h=l i s t ( myarray=array ( 1 : 6, dim=c ( 2, 3 ) ),myname= c o lorado ) > h $myarray [, 1 ] [, 2 ] [, 3 ] [ 1, ] [ 2, ] $myname [ 1 ] c o l o r a d o which can be accessed in a few different ways > h [ 2 ] $myname [ 1 ] c o l o r a d o > h$myname [ 1 ] c o l o r a d o A data frame is a list that contains multiple named vectors that are the same length (i.e. for experimental data). 1.3 Loading Packages Think of a package as a class in Java. Load a package via 3

4 l i b r a r y ( package. name) OR r e q u i r e ( package. name) Install a package via i n s t a l l. packages ( package. name ) view the currently loaded packages (. packages ( ) ) obtain help documentation for a given library l i b r a r y ( help= topicmodels ) view the vignette for a given library v i g n e t t e ( topicmodels ) to install a package, cd to the directory with the tgz file and issue the command R CMD INSTALL filename.tgz. 1.4 Loops Three types of loops in R: repeat, while, and for. Use break to exit a loop and next to continue to the next iteration. i < 5 # repeat loop repeat { i f ( i > 25) break 4

5 } e l s e { p r i n t ( i ) i < i + 5 } i < 5 # while loop while ( i <=25){ p r i n t ( i ) ; i < i + 5 } # f o r loop f o r ( i in seq ( from=5, to =25, by=5) p r i n t ( i ) Iterators and foreach loops are available through external packages 1.5 Operators %%: mod operator $: similar to the way Java uses dot. %*%: matrix multiply 1.6 Vectors Use sequence operator similar to Matlab to generate a vector > x=1:50 > x =1:2:50 #NO > x=seq ( from=1, to =50,by=2) #yes Use the c( ) function to form longer vectors of mismatched elements > x=c ( 5, 6, 9 : 1 0, h e l l o ) 5

6 Note that character vectors are indexed by the quoted string (a C string is a character in R) can use either single or double quotes for a character in R. > x=c ( bye you, h e l l o ) > x [ 1 ] [ 1 ] bye you Can use logical indexing: > b=1:12 > b [ b \%\% 3 == 0 ] [ 1 ] Usage Notes indexing starts at 1 2 Data 2.1 Loading Data 1. read.table: general delimited data 2. read.fwf: fixed width data To read data line-by-line use: con < f i l e ( i n p u t F i l e, open = r ) while ( l e n g t h ( oneline < readlines ( con, n = 1, warn = FALSE) ) > 0) { # do s t u f f } c l o s e ( con ) 6

7 3 Debugging 3.1 Interactive Debugging The five important interactive debugging functions are traceback, debug, browser, trace, recover. Use traceback() after an error to figure out what caused the error. Use debug() on a function then call the function to step through it. Like pdb, type n to go to the next line, use Q to quit. Use undebug() to switch the debug off. To switch to browser mode on error do: o p t i o n s ( e r r o r=r e c o v e r ) 4 Functions In R you can specify function arguments by name: > l o g ( x=64, base =4) Functions are just another object that are assigned to a symbol: > f = f u n c t i o n ( x, y ) { c ( x+1, y+1)} > f ( 1, 2 ) [ 1 ] 2 3 It s possible to provide default values for the arguments > g < f u n c t i o n ( x, y=10) {x+y} > g ( 1 ) [ 1 ] 11 7

8 An ellipses (...) is a special object in R that can only be accessed inside a function and means all of the other arguments. Use etc, to specify the first, second, etc element in... > v < c ( s q r t ( 1 : ) ) > f < f u n c t i o n ( x,... ) { p r i n t ( x ) ; summary (... ) } > f ( Here i s the summary f o r v., v, d i g i t s =2) [ 1 ] Here i s the summary f o r v. Min. 1 s t Qu. Median Mean 3 rd Qu. Max A return() function can be used to return values, however, if no return statement is provided R will return the last evaluated expression (so many programmers omit the return statement). All work in R is accomplished via functions (just with lots of syntactic sugar): > animals [ 4 ]< duck > [< ( animals, 4, duck ) # same e x p r e s s i o n 4.1 Anonymous Function Functions do not need a name, e.g. it s possible to define a function and apply it directly to an argument or sappily, etc. > ( f u n c t i o n ( x ) {x+1}) ( 1 ) [ 1 ] 2 > a < c ( 1, 2, 3, 4, 5) > sapply ( a, f u n c t i o n ( x ) {x+1}) [ 1 ] Other Function Helpfuls Can define binary operators using two %: 8

9 \%myop\% < f u n c t i o n ( a, b ) {2 a + 2 b} Can obtain the arguments of a function via the args() command. 5 Objects R has three types of object oriented systems: S3, S4, R S4 Objects To create a new class use the setclass function: s e t C l a s s ( Class, r e p r e s e n t a t i o n, prototype, c o n t a i n s=c h a r a c t e r ( ), v a l i d i t y, access, where, version, sealed, package, S3methods = FALSE) the readily important parameters are: Class: string specifying the name for the new class. (only required argument) representation: A beamed list of the different slots in the class, specify ANY to allow arbitrary objects to be stored in the slot. prototype: an object containing the default objects for slots in the class contains: character vector with the names of the classes this class extends (superclasses) package: specify the package name of the class s e t C l a s s ( Person, r e p r e s e n t a t i o n (name= c h a r a c t e r, age= numeric ) ) create an instance of the class with new 9

10 hadley < new ( Person,name= Hadley, age =31) Unlike S3, S4 validates the slot types (you can t enter age="cat"). Access the ia > hadley@name [ 1 ] Hadley > s l o t ( hadley, age ) [ 1 ] Methods and Generic Functions properly initialize a generic function a: i f (! i s G e n e r i c ( a ) ) { i f ( i s. f u n c t i o n ( a ) ) fun < a e l s e fun < f u n c t i o n ( o b j e c t ) standardgeneric ( a ) s e t G e n e r i c ( a, fun ) } setmethod ( a, foo, f u n c t i o n ( o b j e c t ) { object@a }) It is also possible to use the method.skeleton() function to generate a setmethod function. 5.3 Creating an R package TODO: See for the definitive guide. Create the appropriate directory package for an R package via: 10

11 package. s k e l e t o n (name= anrpackage, l i s t, environment =.GlobalEnv, path=., f o r c e=false, namespace=false, code f i l e s =c h a r a c t e r ( ) ) Create a file (traditionally) named zzz.r with a method.first.lib. When loading a new package, R searches for a.first.lib function and evaluates it if found. This method should call another function that initializes all classes and methods. From S4Objects.pdf this function should look something like:. F i r s t. l i b < f u n c t i o n ( libname, pkgname, where ) { i f (! r e q u i r e ( methods ) ) stop ( we r e q u i r e methods f o r package Foo ) where < match ( paste ( package :, pkgname, sep= ), search ( ) ). i n i t F o o ( where ) where.initfoo is the function in initialize the classes/methods. i n i t F o o < f u n c t i o n ( where ) { s e t C l a s s ( foo, r e p r e s e n t a t i o n ( a= c h a r a c t e r, b= numeric ), where=where ) s e t C l a s s ( bar, r e p r e s e n t a t i o n ( d= numeric, c= numeric ), where=where ) s e t C l a s s ( baz, c o n t a i n s=c ( foo, bar ), where=where ) } 5.4 S3 Objects S3 is the old-school OOP in R. S3 implements a style of OOP call genericfunction OO. 6 Syntax Curly braces are used to evaluate a sequence of expressions where the last expression is returned. 11

12 7 Plotting & Visualization 7.1 3D Plots Create a 3d interactive scatterplot: l i b r a r y (MCMCpack) x < r d i r i c h l e t (2000, c ( 1, 1, 1 ) ) l i b r a r y ( r g l ) plot3d ( x ) 7.2 Labels and Such Use title to add labels to a plot t i t l e ( main= main t i t l e, sub= sub t i t l e, xlab= x a x i s l a b e l, ylab= y a x i s l a b e l ) 7.3 Random Open a new plot window via p l o t ( 1, 1, xlim=c ( 0.2,2.2), ylim=c ( 0, 0. 5 ), type= n, ann=false) 8 The R Language Notes R is an interpreted language (like Perl or Lisp) Everything in R is an object Objects are copied by value in assignment statements 12

13 NA values are used to represent missing values, Inf and -Inf are infinity, NaN is not a number, and NULL represents no object. Automatic coercion roughly occurs as follows: logical < integer < numeric < complex < character < list. Inhibit coercion using the AsIs function. showmethods(classes=class(ldm)) 9 Appendix: Handy Function Reference as.integer(): convert to integer class(): determine the class of an object dim(): dimension of object dput(): dump an object as R-readable text. fix(): open an object to fix its content (or just view them) ginv(): computes the generalized (pseudo) inverse of a matrix. lapply():when you want to apply a function to each element of a list in turn and get a list back (compare to sappily). ls(): list the names elements of an object (or the current workspace) mode(): Get or set the type of storage mode of an object names(): lists all the $ accessible names of a complex variable par(): adjusts graphical parameters, e.g. lay two plots on top of each othe paste(): use to concatenate strings with each other and other objects print(): print to console rm(list = ls()): clears the current workspace sapply(): when you want to apply a function to each element of a list in turn, but you want a vector back, rather than a list (compare to lapply()). 13

14 showmethods(classes=class(objectvar)): show methods for a given object named objectvar slotnames(): lists all the slots of an object sprintf(): formatted printing into an object str(): shows the structure of any object summary(): provide a description of a model system.time(): time a command typeof(): display the type of an object 10 Appendix: Assorted Tips.Last.value: same as ans in Matlab enclose special symbols with a single quote to refer to them, e.g.?? plot multiple lines and such on the same figure by first issuing plot() then either lines() or points(). use length() to preallocate a vector e.g. l e n g t h ( h ) < 500 use lists like hash maps overwrite the show() method to change how an object is printed draw a 3x1 plot by first calling par(mfrow = c(1, 3)) 14

Introduction to R, Part I

Introduction to R, Part I Introduction to R, Part I Basic math, variables, and variable types Tim Frasier Copyright Tim Frasier This work is licensed under the Creative Commons Attribution 4.0 International license. Click here

More information

Lab 2: Static Response, Cantilevered Beam

Lab 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 information

January 18, 2008 Steve Gu. Reference: Eta Kappa Nu, UCLA Iota Gamma Chapter, Introduction to MATLAB,

January 18, 2008 Steve Gu. Reference: Eta Kappa Nu, UCLA Iota Gamma Chapter, Introduction to MATLAB, Introduction to MATLAB January 18, 2008 Steve Gu Reference: Eta Kappa Nu, UCLA Iota Gamma Chapter, Introduction to MATLAB, Part I: Basics MATLAB Environment Getting Help Variables Vectors, Matrices, and

More information

TDDD08 Tutorial 1. Who? From? When? 6 september Victor Lagerkvist (& Wªodek Drabent)

TDDD08 Tutorial 1. Who? From? When? 6 september Victor Lagerkvist (& Wªodek Drabent) TDDD08 Tutorial 1 Who? From? Victor Lagerkvist (& Wªodek Drabent) Theoretical Computer Science Laboratory, Linköpings Universitet, Sweden When? 6 september 2015 1 / 18 Preparations Before you start with

More information

Python. chrysn

Python. chrysn Python chrysn 2008-09-25 Introduction Structure, Language & Syntax Strengths & Weaknesses Introduction Structure, Language & Syntax Strengths & Weaknesses Python Python is an interpreted,

More information

L3: Review of linear algebra and MATLAB

L3: Review of linear algebra and MATLAB L3: Review of linear algebra and MATLAB Vector and matrix notation Vectors Matrices Vector spaces Linear transformations Eigenvalues and eigenvectors MATLAB primer CSCE 666 Pattern Analysis Ricardo Gutierrez-Osuna

More information

COMS 6100 Class Notes

COMS 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 information

Scripting Languages Fast development, extensible programs

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 information

Package CEC. R topics documented: August 29, Title Cross-Entropy Clustering Version Date

Package CEC. R topics documented: August 29, Title Cross-Entropy Clustering Version Date Title Cross-Entropy Clustering Version 0.9.4 Date 2016-04-23 Package CEC August 29, 2016 Author Konrad Kamieniecki [aut, cre], Przemyslaw Spurek [ctb] Maintainer Konrad Kamieniecki

More information

Vector Spaces. 1 Theory. 2 Matlab. Rules and Operations

Vector Spaces. 1 Theory. 2 Matlab. Rules and Operations Vector Spaces Rules and Operations 1 Theory Recall that we can specify a point in the plane by an ordered pair of numbers or coordinates (x, y) and a point in space with an order triple of numbers (x,

More information

Introduction to RStudio

Introduction to RStudio Introduction to RStudio Carl Tony Fakhry Jie Chen April 4, 2015 Introduction R is a powerful language and environment for statistical computing and graphics. R is freeware and there is lot of help available

More information

Octave. Tutorial. Daniel Lamprecht. March 26, Graz University of Technology. Slides based on previous work by Ingo Holzmann

Octave. Tutorial. Daniel Lamprecht. March 26, Graz University of Technology. Slides based on previous work by Ingo Holzmann Tutorial Graz University of Technology March 26, 2012 Slides based on previous work by Ingo Holzmann Introduction What is? GNU is a high-level interactive language for numerical computations mostly compatible

More information

6.001 Recitation 22: Streams

6.001 Recitation 22: Streams 6.001 Recitation 22: Streams RI: Gerald Dalley, dalleyg@mit.edu, 4 May 2007 http://people.csail.mit.edu/dalleyg/6.001/sp2007/ The three chief virtues of a programmer are: Laziness, Impatience and Hubris

More information

Lab 6: Linear Algebra

Lab 6: Linear Algebra 6.1 Introduction Lab 6: Linear Algebra This lab is aimed at demonstrating Python s ability to solve linear algebra problems. At the end of the assignment, you should be able to write code that sets up

More information

Lisp Introduction. Dr. Neil T. Dantam. Spring CSCI-498/598 RPM, Colorado School of Mines. Dantam (Mines CSCI, RPM) Lisp Spring / 88

Lisp Introduction. Dr. Neil T. Dantam. Spring CSCI-498/598 RPM, Colorado School of Mines. Dantam (Mines CSCI, RPM) Lisp Spring / 88 Lisp Introduction Dr. Neil T. Dantam CSCI-498/598 RPM, Colorado School of Mines Spring 28 Dantam (Mines CSCI, RPM) Lisp Spring 28 / 88 Outline Lisp Common Lisp by Example Implementation Details Typing

More information

Introduction to the R Statistical Computing Environment

Introduction to the R Statistical Computing Environment Introduction to the R Statistical Computing Environment John Fox McMaster University ICPSR 2012 John Fox (McMaster University) Introduction to R ICPSR 2012 1 / 34 Outline Getting Started with R Statistical

More information

Complex Matrix Transformations

Complex Matrix Transformations Gama Network Presents: Complex Matrix Transformations By By Scott Johnson Gamasutra May 17, 2002 URL: http://www.gamasutra.com/features/20020510/johnson_01.htm Matrix transforms are a ubiquitous aspect

More information

Representing Polynomials

Representing Polynomials Lab 4 Representing Polynomials A polynomial of nth degree looks like: a n s n +a n 1 a n 1 +...+a 2 s 2 +a 1 s+a 0 The coefficients a n, a n-1,, a 2, a 1, a 0 are the coefficients of decreasing powers

More information

2 Getting Started with Numerical Computations in Python

2 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 information

Writing Functions In R

Writing Functions In R Writing Functions In R Necessity Really is a Mother Paul E. Johnson 12 1 University of Kansas, Department of Political Science 2 Center for Research Methods and Data Analysis October 12, 2016 Writing Functions

More information

Section 7: Discriminant Analysis.

Section 7: Discriminant Analysis. Section 7: Discriminant Analysis. Ensure you have completed all previous worksheets before advancing. 1 Linear Discriminant Analysis To perform Linear Discriminant Analysis in R we will make use of the

More information

Introduction. How to use this book. Linear algebra. Mathematica. Mathematica cells

Introduction. How to use this book. Linear algebra. Mathematica. Mathematica cells Introduction How to use this book This guide is meant as a standard reference to definitions, examples, and Mathematica techniques for linear algebra. Complementary material can be found in the Help sections

More information

Introduction to Programming (Java) 3/12

Introduction to Programming (Java) 3/12 Introduction to Programming (Java) 3/12 Michal Krátký Department of Computer Science Technical University of Ostrava Introduction to Programming (Java) 2008/2009 c 2006 2008 Michal Krátký Introduction

More information

ALDEx: ANOVA-Like Differential Gene Expression Analysis of Single-Organism and Meta-RNA-Seq

ALDEx: ANOVA-Like Differential Gene Expression Analysis of Single-Organism and Meta-RNA-Seq ALDEx: ANOVA-Like Differential Gene Expression Analysis of Single-Organism and Meta-RNA-Seq Andrew Fernandes, Gregory Gloor, Jean Macklaim July 18, 212 1 Introduction This guide provides an overview of

More information

AMS 132: Discussion Section 2

AMS 132: Discussion Section 2 Prof. David Draper Department of Applied Mathematics and Statistics University of California, Santa Cruz AMS 132: Discussion Section 2 All computer operations in this course will be described for the Windows

More information

Spis treści Contents List of Examples Preface to Third Edition 21

Spis treści Contents List of Examples Preface to Third Edition 21 An engineer's guide to MATLAB : with applications from mechanical, aerospace, electrical, civil, and biological systems engineering / Edward B. Magrab [et al.]. - 3rd ed. - Boston, cop. 2011 Spis treści

More information

Lesson 12: More Systems

Lesson 12: More Systems Lesson 12: More Systems restart; A geometry problem Here's a nice little application of resultants to a geometrical problem. We're given two concentric circles with radii and. From a given point P at a

More information

1 Overview of Simulink. 2 State-space equations

1 Overview of Simulink. 2 State-space equations Modelling and simulation of engineering systems Simulink Exercise 1 - translational mechanical systems Dr. M. Turner (mct6@sun.engg.le.ac.uk 1 Overview of Simulink Simulink is a package which runs in the

More information

I. Numerical Computing

I. 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 information

FIT100 Spring 01. Project 2. Astrological Toys

FIT100 Spring 01. Project 2. Astrological Toys FIT100 Spring 01 Project 2 Astrological Toys In this project you will write a series of Windows applications that look up and display astrological signs and dates. The applications that will make up the

More information

MiniMat: Matrix Language in OCaml LLVM

MiniMat: Matrix Language in OCaml LLVM Terence Lim - tl2735@columbia.edu August 17, 2016 Contents 1 Introduction 4 1.1 Goals........................................ 4 1.1.1 Flexible matrix notation......................... 4 1.1.2 Uncluttered................................

More information

'XNH8QLYHUVLW\ (GPXQG73UDWW-U6FKRRORI(QJLQHHULQJ. EGR 53L Fall Test I. Rebecca A. Simmons & Michael R. Gustafson II

'XNH8QLYHUVLW\ (GPXQG73UDWW-U6FKRRORI(QJLQHHULQJ. EGR 53L Fall Test I. Rebecca A. Simmons & Michael R. Gustafson II 'XNH8QLYHUVLW\ (GPXQG73UDWW-U6FKRRORI(QJLQHHULQJ EGR 53L Fall 2008 Test I Rebecca A. Simmons & Michael R. Gustafson II Name (please print) In keeping with the Community Standard, I have neither provided

More information

1 Introduction & Objective

1 Introduction & Objective Signal Processing First Lab 13: Numerical Evaluation of Fourier Series Pre-Lab and Warm-Up: You should read at least the Pre-Lab and Warm-up sections of this lab assignment and go over all exercises in

More information

Business 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 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 information

Package msir. R topics documented: April 7, Type Package Version Date Title Model-Based Sliced Inverse Regression

Package msir. R topics documented: April 7, Type Package Version Date Title Model-Based Sliced Inverse Regression Type Package Version 1.3.1 Date 2016-04-07 Title Model-Based Sliced Inverse Regression Package April 7, 2016 An R package for dimension reduction based on finite Gaussian mixture modeling of inverse regression.

More information

Python & Numpy A tutorial

Python & Numpy A tutorial Python & Numpy A tutorial Devert Alexandre School of Software Engineering of USTC 13 February 2012 Slide 1/38 Table of Contents 1 Why Python & Numpy 2 First steps with Python 3 Fun with lists 4 Quick tour

More information

Foundations of

Foundations of 91.304 Foundations of (Theoretical) Computer Science Chapter 1 Lecture Notes (Section 1.3: Regular Expressions) David Martin dm@cs.uml.edu d with some modifications by Prof. Karen Daniels, Spring 2012

More information

Math Assignment 3 - Linear Algebra

Math Assignment 3 - Linear Algebra Math 216 - Assignment 3 - Linear Algebra Due: Tuesday, March 27. Nothing accepted after Thursday, March 29. This is worth 15 points. 10% points off for being late. You may work by yourself or in pairs.

More information

Contents. 6.1 Conditional statements 6.2 Iteration 6.3 Procedures and flow control

Contents. 6.1 Conditional statements 6.2 Iteration 6.3 Procedures and flow control Introduction This reference manual gives an essentially complete description of the standard facilities available in SMP. Extensive illustrative examples are included. The same text is given without these

More information

Zelig: Everyone s Statistical Software 1

Zelig: Everyone s Statistical Software 1 Zelig: Everyone s Statistical Software 1 Kosuke Imai 2 Gary King 3 Olivia Lau 4 February 2, 2012 1 The current version of this software is available at http://gking.harvard.edu/zelig, free of charge and

More information

Project 2: Using linear systems for numerical solution of boundary value problems

Project 2: Using linear systems for numerical solution of boundary value problems LINEAR ALGEBRA, MATH 124 Instructor: Dr. T.I. Lakoba Project 2: Using linear systems for numerical solution of boundary value problems Goal Introduce one of the most important applications of Linear Algebra

More information

Notater: INF3331. Veronika Heimsbakk December 4, Introduction 3

Notater: 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 information

New Mexico Tech Hyd 510

New Mexico Tech Hyd 510 Vectors vector - has magnitude and direction (e.g. velocity, specific discharge, hydraulic gradient) scalar - has magnitude only (e.g. porosity, specific yield, storage coefficient) unit vector - a unit

More information

USE OF MATLAB TO UNDERSTAND BASIC MATHEMATICS

USE OF MATLAB TO UNDERSTAND BASIC MATHEMATICS USE OF MATLAB TO UNDERSTAND BASIC MATHEMATICS Sanjay Gupta P. G. Department of Mathematics, Dev Samaj College For Women, Punjab ( India ) ABSTRACT In this paper, we talk about the ways in which computer

More information

CMPSCI 105 Final Exam Spring 2016 Professor William T. Verts CMPSCI 105 Final Exam Spring 2016 May 5, 2016 Professor William T. Verts Solution Key

CMPSCI 105 Final Exam Spring 2016 Professor William T. Verts CMPSCI 105 Final Exam Spring 2016 May 5, 2016 Professor William T. Verts Solution Key CMPSCI 105 Final Exam Spring 2016 May 5, 2016 Professor William T. Verts Solution Key Page 1 of 6 GENERAL KNOWLEDGE, SPECIAL TOPICS, & REVIEW 10 Points One point each question. Answer any ten. Answer

More information

ECE 102 Engineering Computation

ECE 102 Engineering Computation ECE 102 Engineering Computation Phillip Wong MATLAB Vector Operations Vector Math Strings Vector Operations A vector is a list of values placed in a single row or column. Each value is called an element.

More information

BCMB/CHEM 8190 Lab Exercise Using Maple for NMR Data Processing and Pulse Sequence Design March 2012

BCMB/CHEM 8190 Lab Exercise Using Maple for NMR Data Processing and Pulse Sequence Design March 2012 BCMB/CHEM 8190 Lab Exercise Using Maple for NMR Data Processing and Pulse Sequence Design March 2012 Introduction Maple is a powerful collection of routines to aid in the solution of mathematical problems

More information

Introduction to Python

Introduction 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 information

Introduction to Python

Introduction 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 information

WindNinja Tutorial 3: Point Initialization

WindNinja Tutorial 3: Point Initialization WindNinja Tutorial 3: Point Initialization 6/27/2018 Introduction Welcome to WindNinja Tutorial 3: Point Initialization. This tutorial will step you through the process of downloading weather station data

More information

E23: Hotel Management System Wen Yunlu Hu Xing Chen Ke Tang Haoyuan Module: EEE 101

E23: Hotel Management System Wen Yunlu Hu Xing Chen Ke Tang Haoyuan Module: EEE 101 E23: Hotel Management System Author: 1302509 Zhao Ruimin 1301478 Wen Yunlu 1302575 Hu Xing 1301911 Chen Ke 1302599 Tang Haoyuan Module: EEE 101 Lecturer: Date: Dr.Lin December/22/2014 Contents Contents

More information

Statistical Programming with R

Statistical Programming with R Statistical Programming with R Lecture 3: Matrices Bisher M. Iqelan biqelan@iugaza.edu.ps Department of Mathematics, Faculty of Science, The Islamic University of Gaza 2017-2018, Semester 1 Matrices A

More information

(a) Definition of TMs. First Problem of URMs

(a) Definition of TMs. First Problem of URMs Sec. 4: Turing Machines First Problem of URMs (a) Definition of the Turing Machine. (b) URM computable functions are Turing computable. (c) Undecidability of the Turing Halting Problem That incrementing

More information

APPENDIX 1 MATLAB AND ANSYS PROGRAMS

APPENDIX 1 MATLAB AND ANSYS PROGRAMS APPENDIX 1 MATLAB AND ANSYS PROGRAMS This appendix lists all the MATLAB and ANSYS codes used in each chapter, along with a short description of the purpose of each. MATLAB codes have the suffix.m and the

More information

COMS 6100 Class Notes

COMS 6100 Class Notes COMS 6100 Class Notes Daniel Solus November 1, 2016 1 General Remarks We will start with a small overview of the material from the end of last class. Since we were interrupted by the fire alarm. 2 Review

More information

Package rnmf. February 20, 2015

Package rnmf. February 20, 2015 Type Package Title Robust Nonnegative Matrix Factorization Package rnmf February 20, 2015 An implementation of robust nonnegative matrix factorization (rnmf). The rnmf algorithm decomposes a nonnegative

More information

Designing Information Devices and Systems I Fall 2018 Lecture Notes Note Introduction to Linear Algebra the EECS Way

Designing 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 information

Package RootsExtremaInflections

Package RootsExtremaInflections Type Package Package RootsExtremaInflections May 10, 2017 Title Finds Roots, Extrema and Inflection Points of a Curve Version 1.1 Date 2017-05-10 Author Demetris T. Christopoulos Maintainer Demetris T.

More information

WILEY. Differential Equations with MATLAB (Third Edition) Brian R. Hunt Ronald L. Lipsman John E. Osborn Jonathan M. Rosenberg

WILEY. Differential Equations with MATLAB (Third Edition) Brian R. Hunt Ronald L. Lipsman John E. Osborn Jonathan M. Rosenberg Differential Equations with MATLAB (Third Edition) Updated for MATLAB 2011b (7.13), Simulink 7.8, and Symbolic Math Toolbox 5.7 Brian R. Hunt Ronald L. Lipsman John E. Osborn Jonathan M. Rosenberg All

More information

Introduction to Languages and Computation

Introduction to Languages and Computation Introduction to Languages and Computation George Voutsadakis 1 1 Mathematics and Computer Science Lake Superior State University LSSU Math 400 George Voutsadakis (LSSU) Languages and Computation July 2014

More information

Files and their Relationships

Files and their Relationships Contents Preface Files and their Relationships 1 The Java Programming Language 1 1.1 What is Java?............................. 1 1.2 Installing Java: A Simple Program................. 2 1.2.1 Hello World..........................

More information

CSCE 155N Fall Homework Assignment 2: Stress-Strain Curve. Assigned: September 11, 2012 Due: October 02, 2012

CSCE 155N Fall Homework Assignment 2: Stress-Strain Curve. Assigned: September 11, 2012 Due: October 02, 2012 CSCE 155N Fall 2012 Homework Assignment 2: Stress-Strain Curve Assigned: September 11, 2012 Due: October 02, 2012 Note: This assignment is to be completed individually - collaboration is strictly prohibited.

More information

Vectors for Beginners

Vectors 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 information

Math 1 Variable Manipulation Part 5 Absolute Value & Inequalities

Math 1 Variable Manipulation Part 5 Absolute Value & Inequalities Math 1 Variable Manipulation Part 5 Absolute Value & Inequalities 1 ABSOLUTE VALUE REVIEW Absolute value is a measure of distance; how far a number is from zero: 6 is 6 away from zero, and " 6" is also

More information

Section Matrices and Systems of Linear Eqns.

Section Matrices and Systems of Linear Eqns. QUIZ: strings Section 14.3 Matrices and Systems of Linear Eqns. Remembering matrices from Ch.2 How to test if 2 matrices are equal Assume equal until proved wrong! else? myflag = logical(1) How to test

More information

Introduction to MatLab

Introduction to MatLab Introduction to MatLab 1 Introduction to MatLab Graduiertenkolleg Kognitive Neurobiologie Friday, 05 November 2004 Thuseday, 09 Novemer 2004 Kurt Bräuer Institut für Theoretische Physik, Universität Tübingen

More information

Hoare Logic: Reasoning About Imperative Programs

Hoare Logic: Reasoning About Imperative Programs Hoare Logic: Reasoning About Imperative Programs COMP1600 / COMP6260 Dirk Pattinson Australian National University Semester 2, 2018 Programming Paradigms Functional. (Haskell, SML, OCaml,... ) main paradigm:

More information

Meta-Circularity, and Vice-Versa

Meta-Circularity, and Vice-Versa 1/60, and Vice-Versa didier@lrde.epita.fr http://www.lrde.epita.fr/ didier ACCU 2011 Thursday, April 14th 2/60 Table of contents 1 2 Symbolic Expressions 3 The of LISP 4 5 6 7 8 Dynamic 9 4/60 circularity

More information

2013 Eric Pitman Summer Workshop in Computational Science....an introduction to R, statistics, programming, and getting to know datasets

2013 Eric Pitman Summer Workshop in Computational Science....an introduction to R, statistics, programming, and getting to know datasets 2013 Eric Pitman Summer Workshop in Computational Science...an introduction to R, statistics, programming, and getting to know datasets Introducing the Workshop Project Here's what we'll cover: The story

More information

Practical Information

Practical Information MA2501 Numerical Methods Spring 2018 Norwegian University of Science and Technology Department of Mathematical Sciences Semester Project Practical Information This project counts for 30 % of the final

More information

Package gumbel. February 15, 2013

Package gumbel. February 15, 2013 Package gumbel February 15, 2013 Type Package Title Gumbel copula Version 1.04 Date 2012-07-31 Author Anne-Lise Caillat, Christophe Dutang, V eronique Larrieu and Triet Nguyen Maintainer Christophe Dutang

More information

SuperCELL Data Programmer and ACTiSys IR Programmer User s Guide

SuperCELL Data Programmer and ACTiSys IR Programmer User s Guide SuperCELL Data Programmer and ACTiSys IR Programmer User s Guide This page is intentionally left blank. SuperCELL Data Programmer and ACTiSys IR Programmer User s Guide The ACTiSys IR Programmer and SuperCELL

More information

DonnishJournals

DonnishJournals DonnishJournals 2041-1189 Donnish Journal of Educational Research and Reviews. Vol 2(1) pp. 018-024 January, 2015. http:///djerr Copyright 2015 Donnish Journals Original Research Paper Plotting with MAXIMA

More information

The coxvc_1-1-1 package

The coxvc_1-1-1 package Appendix A The coxvc_1-1-1 package A.1 Introduction The coxvc_1-1-1 package is a set of functions for survival analysis that run under R2.1.1 [81]. This package contains a set of routines to fit Cox models

More information

IFM Chemistry Computational Chemistry 2010, 7.5 hp LAB2. Computer laboratory exercise 1 (LAB2): Quantum chemical calculations

IFM Chemistry Computational Chemistry 2010, 7.5 hp LAB2. Computer laboratory exercise 1 (LAB2): Quantum chemical calculations Computer laboratory exercise 1 (LAB2): Quantum chemical calculations Introduction: The objective of the second computer laboratory exercise is to get acquainted with a program for performing quantum chemical

More information

Lab 1: Dynamic Simulation Using Simulink and Matlab

Lab 1: Dynamic Simulation Using Simulink and Matlab Lab 1: Dynamic Simulation Using Simulink and Matlab Objectives In this lab you will learn how to use a program called Simulink to simulate dynamic systems. Simulink runs under Matlab and uses block diagrams

More information

Ratio of Polynomials Fit Many Variables

Ratio of Polynomials Fit Many Variables Chapter 376 Ratio of Polynomials Fit Many Variables Introduction This program fits a model that is the ratio of two polynomials of up to fifth order. Instead of a single independent variable, these polynomials

More information

Jointly Learning Python Programming and Analytic Geometry

Jointly Learning Python Programming and Analytic Geometry Jointly Learning Python Programming and Analytic Geometry Cristina-Maria Păcurar Abstract The paper presents an original Python-based application that outlines the advantages of combining some elementary

More information

Lexical Analysis: DFA Minimization & Wrap Up

Lexical Analysis: DFA Minimization & Wrap Up Lexical Analysis: DFA Minimization & Wrap Up Automating Scanner Construction PREVIOUSLY RE NFA (Thompson s construction) Build an NFA for each term Combine them with -moves NFA DFA (subset construction)

More information

(Re)introduction to Statistics Dan Lizotte

(Re)introduction to Statistics Dan Lizotte (Re)introduction to Statistics Dan Lizotte 2017-01-17 Statistics The systematic collection and arrangement of numerical facts or data of any kind; (also) the branch of science or mathematics concerned

More information

Title of the Book. A. U. Thor XYZ University

Title of the Book. A. U. Thor XYZ University Title of the Book A. U. Thor XYZ University ii Copyright c1997 by Author Preface Preface Head This is the preface and it is created using a TeX field in a paragraph by itself. When the document is loaded,

More information

Module 1: Analyzing the Efficiency of Algorithms

Module 1: Analyzing the Efficiency of Algorithms Module 1: Analyzing the Efficiency of Algorithms Dr. Natarajan Meghanathan Professor of Computer Science Jackson State University Jackson, MS 39217 E-mail: natarajan.meghanathan@jsums.edu What is an Algorithm?

More information

Sample Project: Simulation of Turing Machines by Machines with only Two Tape Symbols

Sample Project: Simulation of Turing Machines by Machines with only Two Tape Symbols Sample Project: Simulation of Turing Machines by Machines with only Two Tape Symbols The purpose of this document is to illustrate what a completed project should look like. I have chosen a problem that

More information

CSE 20. Lecture 4: Introduction to Boolean algebra. CSE 20: Lecture4

CSE 20. Lecture 4: Introduction to Boolean algebra. CSE 20: Lecture4 CSE 20 Lecture 4: Introduction to Boolean algebra Reminder First quiz will be on Friday (17th January) in class. It is a paper quiz. Syllabus is all that has been done till Wednesday. If you want you may

More information

Eric Pitman Summer Workshop in Computational Science

Eric Pitman Summer Workshop in Computational Science Eric Pitman Summer Workshop in Computational Science Intro to Project Introduction Jeanette Sperhac & Amanda Ruby Introducing the Workshop Project Here's what we'll cover: The story of the HWI protein

More information

The Application of California School

The Application of California School The Application of California School Zheng Tian 1 Introduction This tutorial shows how to estimate a multiple regression model and perform linear hypothesis testing. The application is about the test scores

More information

Class 04 - Statistical Inference

Class 04 - Statistical Inference Class 4 - Statistical Inference Question 1: 1. What parameters control the shape of the normal distribution? Make some histograms of different normal distributions, in each, alter the parameter values

More information

Map image from the Atlas of Oregon (2nd. Ed.), Copyright 2001 University of Oregon Press

Map image from the Atlas of Oregon (2nd. Ed.), Copyright 2001 University of Oregon Press Map Layout and Cartographic Design with ArcGIS Desktop Matthew Baker ESRI Educational Services Redlands, CA Education UC 2008 1 Seminar overview General map design principles Working with map elements

More information

Athena Visual Software, Inc. 1

Athena Visual Software, Inc. 1 Athena Visual Studio Visual Kinetics Tutorial VisualKinetics is an integrated tool within the Athena Visual Studio software environment, which allows scientists and engineers to simulate the dynamic behavior

More information

CompA - Complex Analyzer

CompA - Complex Analyzer CompA - Complex Analyzer Xiping Liu(xl2639), Jianshuo Qiu(jq2253), Tianwu Wang(tw2576), Yingshuang Zheng(yz3083), Zhanpeng Su(zs2329) Septembee 25, 2017 1 Introduction The motivation for writing this language

More information

ASSIGNMENT 2 TIPS AND TRICKS

ASSIGNMENT 2 TIPS AND TRICKS ROBERT SEDGEWICK KEVIN WAYNE ASSIGNMENT 2 TIPS AND TRICKS n-body simulation problem decomposition the physics bugs universes http://introcs.cs.princeton.edu Alan Kaplan and Kevin Wayne Last updated on

More information

The OmicCircos usages by examples

The OmicCircos usages by examples The OmicCircos usages by examples Ying Hu and Chunhua Yan October 30, 2017 Contents 1 Introduction 2 2 Input file formats 2 2.1 segment data............................................. 2 2.2 mapping data.............................................

More information

Supplementary Material

Supplementary Material Supplementary Material Contents 1 Keywords of GQL 2 2 The GQL grammar 3 3 THE GQL user guide 4 3.1 The environment........................................... 4 3.2 GQL projects.............................................

More information

(Multiscale) Modelling With SfePy

(Multiscale) Modelling With SfePy (Multiscale) Modelling With SfePy Random Remarks... Robert Cimrman & Eduard Rohan & others Department of Mechanics & New Technologies Research Centre University of West Bohemia Plzeň, Czech Republic PANM

More information

MATLAB BASICS. Instructor: Prof. Shahrouk Ahmadi. TA: Kartik Bulusu

MATLAB BASICS. Instructor: Prof. Shahrouk Ahmadi. TA: Kartik Bulusu MATLAB BASICS Instructor: Prof. Shahrouk Ahmadi 1. What are M-files TA: Kartik Bulusu M-files are files that contain a collection of MATLAB commands or are used to define new MATLAB functions. For the

More information

SEM Day 1 Lab Exercises SPIDA 2007 Dave Flora

SEM Day 1 Lab Exercises SPIDA 2007 Dave Flora SEM Day 1 Lab Exercises SPIDA 2007 Dave Flora 1 Today we will see how to estimate CFA models and interpret output using both SAS and LISREL. In SAS, commands for specifying SEMs are given using linear

More information

APBS electrostatics in VMD - Software. APBS! >!Examples! >!Visualization! >! Contents

APBS electrostatics in VMD - Software. APBS! >!Examples! >!Visualization! >! Contents Software Search this site Home Announcements An update on mailing lists APBS 1.2.0 released APBS 1.2.1 released APBS 1.3 released New APBS 1.3 Windows Installer PDB2PQR 1.7.1 released PDB2PQR 1.8 released

More information

Generalized Linear Models in R

Generalized Linear Models in R Generalized Linear Models in R NO ORDER Kenneth K. Lopiano, Garvesh Raskutti, Dan Yang last modified 28 4 2013 1 Outline 1. Background and preliminaries 2. Data manipulation and exercises 3. Data structures

More information

The Monte Carlo Method

The Monte Carlo Method ORBITAL.EXE Page 1 of 9 ORBITAL.EXE is a Visual Basic 3.0 program that runs under Microsoft Windows 9x. It allows students and presenters to produce probability-based three-dimensional representations

More information

Package depth.plot. December 20, 2015

Package depth.plot. December 20, 2015 Package depth.plot December 20, 2015 Type Package Title Multivariate Analogy of Quantiles Version 0.1 Date 2015-12-19 Maintainer Could be used to obtain spatial depths, spatial ranks and outliers of multivariate

More information