Wrapup

1 / 29
About This Presentation
Title:

Wrapup

Description:

n x k, with a 256 x 3 color table. image(p,q) = 12 means 'look at row 12 in color table to get the ... When does everyone seem to come down with the same cold? ... – PowerPoint PPT presentation

Number of Views:42
Avg rating:3.0/5.0
Slides: 30
Provided by: JFH

less

Transcript and Presenter's Notes

Title: Wrapup


1
Wrapup
2
Topics
  • Photoshoppe hints/clarifications
  • Social networks, graphs, and matrices

3
Photoshoppe
  • Image Types
  • Crop
  • Zoom
  • Posterize

4
Image Types
  • PNG images come in several forms
  • n x k x 3 image(p, q, ) is a color-triple
  • n x k, with a 256 x 3 color table
  • image(p,q) 12 means look at row 12 in color
    table to get the real color
  • n x k with no colortable for greyscale (?)
  • ONLY need to handle the first form
  • If you want to handle others, feel free

5
Crop
  • When crop is selected, user must click-and-drag
    to complete the operation.
  • crop-button callback needs to set up the
    click-n-drag
  • waitforbuttonpress
  • rbbox
  • Both of these return ONLY after the users done
    something.
  • To get mouse-location, use get(,
    CurrentPoint)
  • Be sure to trim the values returned to within the
    image range!

6
Zoom
  • Two options
  • Implement with a zoom in/out toggle
  • use the builtin zoom function
  • Zoom in/out toggle
  • Double pixel size
  • Double edge length or
  • Double pixel area (mutliply edge by sqrt(2))
  • Both are OK choices

7
Posterize
  • Youll use kmeans to do posterization.
  • Sometimes kmeans comes up with fewer clusters of
    data than you requested
  • Use kmeans(data, k, emptyaction, drop)
  • Tells kmeans to ignore the fact that one or more
    clusters are empty.

8
Social networks and graphs
  • We all have friendsand other people were not
    friends with
  • Can draw diagrams like this

Anna
Cho
Mike
Robin
Sanjaya
9
Encoding social networks
  • Replace names with numbersBuild matrix
  • 1 1 0 0 0
  • 1 1 1 0 0
  • 0 1 1 1 0
  • 0 0 1 1 0
  • 0 0 0 0 1

1
3
2
4
5
10
Graphs and matrices
  • The matrix is called an adjacency matrix
  • Shows all places you can reach in 0 or 1 step
    from a node
  • Information for node i stored in row i (or column
    i)
  • Matrix is symmetric
  • 1 1 0 0 0
  • 1 1 1 0 0
  • 0 1 1 1 0
  • 0 0 1 1 0
  • 0 0 0 0 1

11
  • Matrix has 1s on diagonal to say you can get
    from person k to person k by taking no steps at
    all

12
M 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 0 0 0
0 0 1
  • Whats M2?
  • 1 2 1 0 0
  • 2 2 2 1 0
  • 1 2 3 2 0
  • 0 1 2 2 0
  • 0 0 0 0 1
  • Each entry says number of ways to get from i to j
    in 2 or fewer steps.
  • 3,2 entry 3-2-2 and 3-3-2.

1
3
2
4
5
13
Whats Mk?
  • The (i,j) entry counts the number of ways to get
    from i to j in k or fewer steps
  • let v 0 1 0 0 0. What does Mv represent?
  • All friends of person 2

Mv 1 1 0 0 0 0 1 1 1 0 0 1 0 1 1 1 0 x 0 0
0 1 1 0 0 0 0 0 0 1 0
1 1 1 0 0
14
Whats M(Mv)?
  • M(Mv) represents paths from person 2 to any
    friend of a friend
  • And M(M(M(v))) represents friends-of-friends-of-fr
    iends
  • If we computed u M(M(M(M(M(Mv))))), wed find
    all people reachable by 6 degrees of separation
  • If conjecture is right, this would be everyone.
  • u should be a vector with no zeroes.

15
Six degrees
  • To make that test, wed need a very big matrix M
  • For US population, 250,000,000 x 250,000,000.
  • Too big to store practically
  • Even Rhode Island is 1,000,000 x 1,000,000.

16
Matrix size
  • 1012 entries too many to store
  • Almost all entries are zero
  • Use sparse matrix representation!
  • Assuming 500 friends per person, RI matrix
    becomes workable!

17
Weighted matrices
  • We could write down numbers between 0 and 1 for
    each edge, representing strength of connection
  • You, roomate connection of strength 1
  • You, CS4 TA strength 0.1
  • You, parking enforcement officer for Brown
    strength 0.001

18
Weighted matrices
  • Can be used to study rumor propagation
  • If you hear a rumor from many untrusted sources,
    its like hearing it from a trusted source
  • Mkv tells how much a rumor started by person 2
    has influenced each person after k steps of rumor
    propagation
  • Probably best to include some discount factor
    along the way

19
Discounted rumors
  • When you hear a rumor and spread it to 500
    friends, maybe each believes it only with a 1
    chance.
  • Compute .01 Mv.
  • Eventual result
  • v 0.01 Mv .012M2v

20
Tipping points
  • When does a rumor become believed?
  • When does a riot start?
  • When does a shoe-brand become popular?
  • When does everyone seem to come down with the
    same cold?

21
  • Can study these questions by looking at matrix
    powers
  • When Mkv is mostly nonzero (or mostly above some
    threshold), we have a tipping point

22
Conjectures
  • The tipping point happens when someone with lots
    of friends hears the rumor
  • In any sufficiently connected community, even
    without superfriendlies, it happens after a
    certain time
  • In communities with enough weak links, even if
    there are no strong links, it happens
  • Strong links prevent tipping

23
Testing conjectures
  • Repeatedly
  • Generate random graph M of some density
  • Check whether M6v is all-positive
  • Compute successes/total trials.
  • When this is gt 50, youve found critical density

24
Test2
  • Do the same test, but after removing
    superfriendlies
  • Any difference in required density?

25
Test3
  • Generate friendships with a better model
  • Each person gets a few friends to start with
  • Thereafter, new friendships happen in proportion
    to the number of friends you have
  • Friendly people get more friends!
  • Test connection model with/without
    superfriendlies.

26
Generating numbers with a particular distribution
  • Id like to generate a number from 1 to 5
  • But Id like to have the likelihoods of
    generating each one to be different in
    proportion to 3 4 2 6 2
  • Solution write down1 1 1 2 2 2 2 3 3 4 4 4 4 4
    4 5 5
  • Pick a random from 117 look at that element of
    the list!

27
Code
  • function y randDist(dist)
  • pick a number from 1..size(dist)
  • probability of picking k is proportional to
    dist(k)
  • u sum(dist)
  • k randint(1,1, 1 u)
  • for p 1size(dist)
  • if k lt dist(p)
  • y p
  • return
  • else
  • k k dist(p)
  • end
  • end
  • y size(dist)

28
(No Transcript)
29
(No Transcript)
Write a Comment
User Comments (0)