Presentation is loading. Please wait.

Presentation is loading. Please wait.

Page Rank. Page Rank Overview Two dimensional arrays Monte Carlo algorithms Searching the world wide web Big data Page rank Goal: we will write a program.

Similar presentations

Presentation on theme: "Page Rank. Page Rank Overview Two dimensional arrays Monte Carlo algorithms Searching the world wide web Big data Page rank Goal: we will write a program."— Presentation transcript:


2 Page Rank

3 Overview Two dimensional arrays Monte Carlo algorithms
Searching the world wide web Big data Page rank Goal: we will write a program to compute the relevancy of WWW documents based on the static structure of the WWW.

4 Two Dimensional Arrays
Significance (a topic on the AP Computer Science A exam) Syntax Example of matrix multiplication Arrays of arrays

5 Significance of Two Dimensional Arrays
Tables; for instance, assignments for each student in a class, quarterly sales for each item in inventory, etc. Matrices and binary relations in mathematics. For example, is there a direct road from city1 in USA to city2 in USA? For our goal in the this section, we will have need for the number of links from doc1 in the WWW to doc2 in the WWW.

6 Syntax int[][] frequency = new int [26][26];
Elements are accessed: frequency[4][7] and not frequency[4,7] Array indices in Java (like C, C++, C#) always begin with 0; in other words, the element with index 1 is the second element of the array.

7 Matrix multiplication

8 Matrix Multiplication Exercise

9 Arrays of Arrays Logically: arrays of arrays in the tradition of C and C++. Very simple. Unfortunately: introduces pointers, memory allocation, etc. Very complicated.

10 Monte Carlo Methods Introduction
The example of a Monte Carlo estimate for Pi (Java exercise). Fair shuffling (Java exercise). Random walk (important in financial analysis) Used in path tracing to create realistic images Percolation – an example of the power of a Monte Carlo algorithm Goal: we will write a Monte Carlo algorithm to estimate the relevancy of WWW documents based on the static structure of the WWW.

11 Monte Carlo Casino The name refers to the grand casino in the Principality of Monaco at Monte Carlo, which is well-known around the world as an icon of gambling.

12 Monte Carlo estimate for Pi
Java exercise: Since we know the value of pi it is not really necessary to invent an algorithm to estimate its value.

13 Fair shuffling (Java exercise)
How would you test a algorithm for shuffling, say, cards? In particular how would you know if all of the many possible results are equally likely? Main program ava. Nothing to write; requires the method to shuffle. contains two methods of shuffling cards. Run the experiment with multiple trials and convince yourself both methods are fair

14 Percolation Theory Percolation. Pour liquid on top of some porous material. Will liquid reach the bottom? Many applications in chemistry, materials science, etc. Spread of forest fires. Natural gas through semi-porous rock. Flow of electricity through network of resistors. Permeation of gas in coal mine through a gas mask filter.

15 Percolation Theory Given an N-by-N system where each site is vacant with probability p, what is the probability that system percolates? Remark. Famous open question in statistical physics. No known mathematical solution. Computational thinking creates new science. Recourse. Take a computational approach: Monte Carlo simulation. Uses a recursive, dfs algorithm, but diverges from the present topic. (Recursion is a topic on the AP Computer Science A exam.) p = 0.3 (does not percolate) p = 0.4 (does not percolate) p = 0.5 (does not percolate) p = 0.6 (percolates) p = 0.7 (percolates)

16 We will examine a Monte Carlo algorithm for estimating the relevancy of WWW documents.

17 Random Walk Page rank can be computed a lot like random walk
See the Java applet (1 dim) at l See the Java applet (2 dim) at walk/

18 Searching the World Wide Web
History of Search Engines Hypertext Crawling the World Wide Web Indexing

19 History of Search Engines
History of Search by Larry Kim of WordStream

20 Markup and Hypertext Documents served up through the WWW are generally “marked up” for presentation in a structured, standard called hypertext markup language (HTML). The most important feature of HTML is the referencing (via URLs) of other WWW documents which enables easy, non-sequential, and varied paths of reading the documents.

21 Hypertext

22 WWW Spiders Google, and others, continually, crawl around the WWW recording what they see to enable searching.

23 44% of hits and 35% of bandwidth is attributable to bots (and other odd things).
July 2013 (up to 9:30 am 26 Jul 2013) on the WWW server Russian search engine

24 Indexing Finding a relevant document is a vast ocean of linked HTML documents requires a very large index. An index is a (sorted) list of keywords (terms) and the list of values (URLs) which contain them.

25 An example index of WWW documents
Bourgeois .../manifesto.txt Hero …/lilwomen.txt, …/muchado.txt, …/war+peace.txt His .../manifesto.txt, …/lilwomen.txt, …/mobydick.txt, …/muchado.txt, …/war+peace.txt Treachery …/war+peace.txt Whale …/mobydick.txt Yellowish …/lilwomen.txt , …/war+peace.txt

26 Several Issues Pick out the words from the mark-up
What’s a word? 2nd, abc’s, CSTA Normalize: lowercase, stemming Some words are not worth indexing “the”, “a”, etc. A so-called stop list, eg., words ignored in Wikipedia search Java exercise: First some preliminary remarks before doing the exercise.

27 Searching and Sorting Problem: Determine if the word is in the stop list. What is the best approach? Searching: linear search, binary search. (These are topics on the AP Computer Science A exam.) Binary search requires the data (the index, for example) to be sorted. Sorting: selection sort, insertion sort, merge sort, quick sort; external sorting. (The first three of these sorts are topics on the AP Computer Science A exam.)

28 Linear versus Binary search
Suppose each comparison takes one millisecond (0.001)

29 Linear versus Binary Search

30 Linear versus Binary Search

31 Obama at Google

32 Sorting Demo
See also sorting illustrated by Algo-rythmics and folk dancers

33 Now do the exercise Java exercise: PS. How to students really program? Observe the tool tip!

34 OK, we have a keyword index
OK, we have a keyword index. It is likely we still have “gazillion” documents, for most of the terms. (See Googlewacks, Googlewhackblatt; one and two words search terms that return one document.) How do we find the most relevant pages?

35 Big Data The problem Count-Min Algorithm

36 The problem with Big Data
Consider a popular website which wants to keep track of statistics on the queries used to search the site. One could keep track of the full log of queries, and answer exactly the frequency of any search query at the site. However, the log can quickly become very large. This problem is an instance of the count tracking problem. Even known sophisticated solutions for fast querying such as a tree-structure or hash table to count up the multiple occurrences of the same query, can prove to be slow and wasteful of resources. Notice that in this scenario, we can tolerate a little imprecision. In general, we are interested only in the queries that are asked frequently. So it is acceptable if there is some fuzziness in the counts. Thus, we can tradeoff some precision in the answers for a more efficient and lightweight solution. This tradeoff is at the heart of sketches. Cormode and Muthurishnon, 2011



39 Page Rank Gave Google a Competitive Advantage
Not based on the WWW surfer as voter (popularity), but on the WWW author as voter (hence relatively static) Random surfer mindlessly follows the hyperlinks of the WWW authors Markov chains


41 S&W Tiny Hypertext

42 S&W Tiny Graph

43 S&W Tiny: Adj list & Adj matrix
5 5


45 Wiki2 Hypertext

46 Wiki2 Graph

47 Wiki2: Adj List & Adj Matrix
7 7


49 Wiki1 Hypertext

50 Wiki1 Graph


52 Java Exercise Modify Print adjacency matrix
Print probability matrix Print probability matrix with rule

53 Interactive WWW Page for PageRank

54 Reachability, Markov Theory
Can node 2 reach node 4? Yes, using a path of length 2 through node 3.



57 Final Challenge Raise the page rank of page “23” by modifying only the links on page “23” Decrease the page rank of page “23” by modifying only the links on page “23” Can you find the maximum/minimum page rank?

58 Search engine optimization, link schemes, link farming, Google bombs

59 Ted Talks: Brin & Page: The Genesis of Google

Download ppt "Page Rank. Page Rank Overview Two dimensional arrays Monte Carlo algorithms Searching the world wide web Big data Page rank Goal: we will write a program."

Similar presentations

Ads by Google