Announcements

- 5/24: Here is mini-project 9, with images and installation instructions.
- 5/17: Mini-project 8 is out. It is due Tuesday, May 24th.
- 5/11: The final exam will be Friday, June 3rd, 12:15-3:15 PM, in room 320-105.
- 5/10: Mini-project 7 is out. It is due Tuesday, May 17th. Here is the data file of national parks for Part 2.
- 5/5: Mini-project 6 is out. It is due Tuesday, May 10th. Here is the data file for Part 2.
- 4/26: Mini-project #5 is available. It is due Tuesday, May 3rd. The datasets are here: county_results.csv and county_facts_dictionary.csv.
- 4/19: Here is mini-project #4 and here is the dataset.
- 4/12: Mini-project #3 is available. QWOP scripts are available for MATLAB here and Python here. It is due Tuesday, April 19th.
- 4/5: Mini-project #2 is available. It is due Tuesday, April 12th. The dataset is available here.
- Here is some starter code for drawing heatmaps in Python (and/or check Stack Overflow).
- 4/4: Here is a review (courtesy of EE263) of the most basic aspects of vectors and matrices (e.g., how to multiply them). Most relevant for CS168 are pages 1--9 (up to "Block matrices and submatrices") and the "Linear functions" and "Linear equations" sections on pages 10--11.
- 3/28: Mini-project #1 is available. It is due Tuesday, April 5th.
- Here is some starter code for drawing histograms in Python (and/or check Stack Overflow).
- 3/28: Welcome to CS168!

Administrative Information

- Tim Roughgarden (Office hours: Mon 4:45 - 5:45pm, Gates 474. Email: first name at cs.stanford.edu).
- Gregory Valiant (Office hours: Thurs 3-4pm, Gates 470. Email: last name at stanford.edu).

**Course Assistants:**

- Seth Hildick-Smith (Office hours: Fri 10:00am - 12:00pm. Lathrop Tech Lounge, Email: sethhjs at stanford.edu).
- Vatsal Sharan (Office hours: Mon 3:00pm - 5:00pm. Gates 400, Email: first initial last name at stanford.edu).
- Leon Yao (Office hours: Mon 11:00am - 1:00pm Huang Basement, Email: first name last name at stanford.edu).

**Time/location:** 1:30 - 2:50pm Mon/Wed in 370-370.

**Piazza site:** Here.

**Prerequisites**: CS107 and CS161, or permission from the instructor.

Course Description

This course will provide a rigorous and hands-on introduction to the central ideas and algorithms that constitute the core of the modern algorithms toolkit. Emphasis will be on understanding the high-level theoretical intuitions and principles underlying the algorithms we discuss, as well as developing a concrete understanding of when and how to implement and apply the algorithms. The course will be structured as a sequence of one-week investigations; each week will introduce one algorithmic idea, and discuss the motivation, theoretical underpinning, and practical applications of that algorithmic idea. Each topic will be accompanied by a mini-project in which students will be guided through a practical application of the ideas of the week. Topics include modern techniques in hashing, dimension reduction, linear and convex programming, gradient descent and regression, sampling and estimation, compressive sensing, and linear-algebraic techniques (principal components analysis, singular value decomposition, spectral techniques).

Detailed Schedule

### Week 1: Modern Hashing

**Lecture 1 (Mon 3/28):**Course introduction. Consistent hashing.- Lecture notes (updated 3/31/16)

- The Akamai paper: Karger/Lehman/Leighton/Levine/Lewin/Panigrahy, Consistent Hashing and Random Trees: Distributed Caching Protocols for Relieving Hot Spots on the World Wide Web, STOC 1997.
- Akamai stories by co-founder Tom Leighton.
- Further implementation details (see Section 3).
- The Chord paper: Stoica et al., Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications, SIGCOMM 2001.
- The Amazon Dynamo paper: DeCandia et al., Dynamo: Amazon's Highly Available Key-value Store, SOSP 2007.
- Review videos on hashing (via Coursera): Operations and Applications, Implementation Details Part 1 and Part 2.

**Lecture 2 (Wed 3/30):**Property-preserving lossy compression. From majority elements to approximate heavy hitters. From bloom filters to the count-min sketch.- Lecture notes (updated 4/4/16)

- Review videos on bloom filters (via Coursera): The Basics and Heuristic Analysis
- Broder/Mitzenmacher, Network Applications of Bloom Filters: A Survey, 2005.
- Cormode/Muthukrishnan, An Improved Data Stream Summary: The Count-Min Sketch and its Applications, 2003.
- One of several count-min sketch implementations.

### Week 2: LSH and Nearest Neighbor

**Lecture 3 (Mon 4/4):**Similarity Search. Similarity metrics: Jaccard, Euclidean, L1. Efficient algorithm for finding similar elements in small/medium (ie. <20) dimensions: k-d-trees.- lecture notes (from last year--will be updated soon).

**Lecture 4 (Wed 4/6):**Curse of Dimensionality, kissing number. Distance-preserving compression. Estimating Jaccard similarity using MinHash. JL dimensionality reduction.- Lecture notes (from last year--will be updated soon)

- A nice survey of "kissing number", and some other strange phenomena from high dimensional spaces: Kissing Numbers, Sphere Packings, and some Unexpected Proofs (from 2000).
- Origins of MinHash at Alta Vista: Broder, Identifying and Filtering Near-Duplicate Documents (from 2000).
- Ailon/Chazelle, Faster Dimension Reduction, CACM '10.
- Andoni/Indyk, Near-Optimal Hashing Algorithms for Approximate Nearest Neighbor in High Dimensions, CACM '08.
- For much more on LSH, see this chapter of the CS246 textbook (by Leskovec, Rajaraman, and Ullman).

### Week 3: Gradient Descent and Regression

**Lecture 5 (Mon 4/11):**The intuition and geometry of gradient descent. Application to linear regression.- Lecture notes (updated 5/3/16)

**Lecture 6 (Wed 4/13):**Stochastic gradient descent and regularization. Supplementary material:- Data sets: Iris, Wikipedia, Tiny Images
- QWOP in the real world: funny videos from darpa grand challenge.

### Week 4: Linear-Algebraic Techniques: Understanding Principal Components Analysis

**Lecture 7 (Mon 4/18):**Understanding Principal Component Analysis (PCA). Minimizing squared distances equals maximizing variance. Use cases for data visualization and data compression. Failure modes for PCA.- Lecture notes (updated 5/6/16)

- A nice exposition by 23andMe of the fact that the top 2 principal components of genetic SNP data of Europeans essentially recovers the geography of europe: nice exposition w. figures. Original Nature paper: Genes mirror geography in Europe, Nature, Aug. 2008.
- Eigenfaces (see also this blog post)
- There's tons of PCA tutorials floating around the Web (some good, some not so good), which you are also permitted to refer to.

**Lecture 8 (Wed 4/20):**How PCA works. Maximizing variance as finding the "direction of maximum stretch" of the covariance matrix. The simple geometry of "diagonals in disguise". The power iteration algorithm.- Lecture notes (updated 5/6/16)

### Week 5: Linear-Algebraic Techniques: Understanding the Singular Value Decomposition

**Lecture 9 (Mon 4/25):**Low-rank matrix approximations. The singular value decomposition (SVD). Recovering missing entries from a matrix.

**Lecture 10 (Wed 4/27):**Tensor methods. The uniqueness of low-rank tensor factorizations, and Jenrich's algorithm. Supplementary material:

### Week 6: Spectral Graph Theory

**Lecture 11 (Mon 5/2):**Graphs as matrices and the Laplacian of a graph. Interpretations of the largest and smallest eigenvectors/eigenvalues of the Laplacian. Spectral embeddings, and an overview of applications (e.g. graph coloring, spectral clustering.) Supplementary material:- Dan Spielman's excellent lecture notes for his semester-long course on Spectral Graph Theory. The notes include a number of helpful plots.
- Amin Saberi offered a grad course last year quarter that is covering some of the research frontier of Spectral Graph Theory.

**Lecture 12 (Wed 5/4):**

### Week 7: Sampling and Estimation

**Lecture 13 (Mon 5/9):**Reservoir sampling (how to select a random sample from a datastream). Basic probability tools: Markov's inequality and Chebyshev's inequality. Importance Sampling (how to make inferences about one distribution based on samples from a different distribution). Description of the Good-Turing estimate of the missing/unseen mass. Supplementary material:- A nice description of the probabilistic tools/approach that go into Nate Silver's political forecasting model: here.

**Lecture 14 (Wed 5/11):**Markov Chains, stationary distributions. Markov Chain Monte Carlo (MCMC) as approaches to solving hard problems by sampling from carefully crafted distributions. Supplementary material:- A basic description of MCMC, here.
- Lecture notes from Persi Diaconis on MCMC, including a description of the MCMC approach to decoding substitution-ciphers, here.
- Example of MCMC used for fitting extremely complex biological models: The human splicing code... Science, Jan. 2015.
- For those interested in computer Go: here is the Jan, 2016 Nature paper from Google's DeepMind group.

### Week 8: The Fourier Perspective

**Lecture 15 (Mon 5/16):**Fourier methods, part 1. Supplementary material:

**Lecture 16 (Wed 5/18):**Fourier methods, part 2 (emphasis on convolutions).- Lecture notes combined with Lecture 15 (rough, to be updated shortly)

### Week 9: Mathematical Programming and Sparse Vector/Matrix Recovery

**Lecture 17 (Mon 5/23):**Compressive sensing. Supplementary material:- A video and lecture notes from CS264 with more of the mathematics behind compressive sensing.
- Survey talk by Candes from ICM 2014.
- Rice's single-pixel camera
- More on potential applications in cameras.
- Developments in medical imaging.
- More resources on compressive sensing.

**Lecture 18 (Wed 5/25):**Linear and convex programming. Matrix completion. Supplementary material:- Linear programming FAQ, out of date but still with lots of useful info.
- For convex optimization at Stanford, start with Stephen Boyd.
- For more on matrix completion, start with Chapter 7 of Moitra's notes.

### Week 10: Bonus Lecture

**No lecture on Mon 5/30 (Memorial Day)**

**Lecture 19 (Wed 6/1):**Expander codes. (optional lecture) Optional supplementary material:- Sipser/Spielman, Expander Codes.
- Lecture notes from CS264.

Coursework

**Assignments (75%)**: There will be 9 weekly mini-projects centered around the topics covered that week. Each mini-project contains both written and programming parts. The projects can be done individually or in pairs. If you work in a pair,**only one member**should submit all of the relevant files.For the written part, you are encouraged to use LaTeX to typeset your homeworks; we've provided a template for your convenience. We will be using the GradeScope online submission system. You should have received an email saying that you've been enrolled in CS168 on Gradescope. If not, create an account on Gradescope using your Stanford ID and join CS168 using entry code MWNP89.

For the programming part, you are encouraged to use matlab (tutorial), Numpy and Pyplot in Python (Python tutorial, Numpy tutorial, Pyplot tutorial), or some other scientific computing tool (with plotting). Here is a comprehensive python tutorial using IPython Notebook. IPython Notebook is an interactive computational environment, especially useful for scientific computing (tutorial on how to set up). For easy reference, you can also view the notebook here.

To turn in your programming part:

- Compress all your files into a .zip file, such
as
`p1.zip`

. - See the instructions on the mini-project for details about what files to submit. For example, we generally want your code in addition to your answers.
- Copy the zip file to the corn machine (don't miss the colon in the end): scp <zip file> <your SUNetID>@corn.stanford.edu:
- Log onto the corn machine:
ssh <your SUNetID>corn.stanford.edu

- Run the submit script (run the script without any argument to see its usage):
/usr/class/cs168/WWW/submit.py <project ID> .

Note: your file must have the proper name (such as

`p1.zip`

) for the submit script to process it.You can submit multiple times; each submission will just replace the previous one.

Assignments are released on Mondays, and are due at 11:59pm on Tuesdays the following week (both the written and the programming parts).

**No late assignments will be accepted**, but we will drop your lowest assignment grade when calculating your final grade.- Compress all your files into a .zip file, such
as
**Exam (25%)**: Date: Friday, June 3rd, 12:15 - 3:15 pm. Location: room 320-105.

Collaboration Policy

Except where otherwise noted, you may refer to your course notes, the textbooks and research papers listed on the course Web page

**only**. You cannot refer to textbooks, handouts, or research papers that are not listed on the course home page. If you do use any approved sources, make you sure you cite them appropriately, and make sure that all your words are your own.You are also permitted to use general resources for whatever programming language you choose to use.

You can discuss the problems verbally at a high level with other groups. And of course, you are encouraged to contact the course staff (via Piazza or office hours) for additional help.

Please follow the honor code.