[PDF] [PDF] MIT6_0002F16_Lecture 5 - MIT OpenCourseWare

Drunkard's Walk 6 0002 LECTURE 5 4 Page 5 One Possible First Step 6 0002 LECTURE 5 5 Page 6 Another Possible First Step 6 0002 LECTURE 5 6 



Previous PDF Next PDF





[PDF] MIT6_0002F16_Lecture 2 - MIT OpenCourseWare

A Search Tree Enumerates Possibili0es 6 0002 LECTURE 2 6 Take Don'tTake Left-first, depth-first enumera0on Val = 170 Cal = 766 Val = 120 Cal = 766



[PDF] MIT6_0002F16_Lecture 15 - MIT OpenCourseWare

Lawrence Solomon, Financial Post, April 15, 2013 6 0002 LECTURE 15 6 Moral Cherry picking image © source unknown All rights reserved This content is 



[PDF] MIT6_0002F16_Lecture 11

that the past predicts the future Interested in extending to programs that can infer useful informaion from paterns in data 6 0002 LECTURE 11 Slide 6 



[PDF] MIT6_0002F16_Lecture 8 - MIT OpenCourseWare

Variability of subgroups less than of entire population ▫Requires care to do properly ▫Well stick to simple random samples 6 0002 LECTURE 8 6 



[PDF] MIT6_0002F16_Python Resources - MIT OpenCourseWare

TEXTBOOKS/TUTORIALS • Dive Into Python - another survey of Python syntax, datatypes, etc • Think Python by Allen Downey - a good general overview of the  



[PDF] MIT6_0002F16_Lecture 13 - MIT OpenCourseWare

the label of a new example ◦ Find the nearest example in the training data ◦ Predict the label associated with that example X 6 0002 LECTURE 13 6 



[PDF] MIT6_0002F16_Lecture 12 - MIT OpenCourseWare

one fewer cluster 3 Continue the process until all items are clustered into a single cluster of size N What does distance mean? 6 0002 LECTURE 12 6 



[PDF] MIT6_0002F16_Lecture 3

in a molecule are related to one another ◦ Ancestral rela1onships 6 0002 LECTURE 3 6 For more information, see https://ocw mit edu/help/faq-fair-use



[PDF] MIT6_0002F16_Lecture 5 - MIT OpenCourseWare

Drunkard's Walk 6 0002 LECTURE 5 4 Page 5 One Possible First Step 6 0002 LECTURE 5 5 Page 6 Another Possible First Step 6 0002 LECTURE 5 6 

[PDF] mit 6.0002 edx

[PDF] mit 6.0002 solutions

[PDF] mit 6.0002 syllabus

[PDF] mit algo videos

[PDF] mit algorithms course notes

[PDF] mit assignment solution

[PDF] mit course 6 9

[PDF] mit course 6 audit

[PDF] mit embedded systems course

[PDF] mit highest salaries

[PDF] mit media lab food project

[PDF] mit ocw

[PDF] mit opencourseware 6.0002

[PDF] mit opencourseware data mining

[PDF] mit starting salary by major

E E u

6.02L.

CTE

UR51ha

pRter

Leccctu

r5:Rand

Relevant

Reading

§Chapter11

§Chapter14

6.0002

LECTURE52

Why

RandomWalks?

§Randomwalksareimportantinmany

domains ?*5623<1/56=5@thestockmarket(maybe) ?E762:=5@diffusionprocesses ?'1A"

§Goodillustrationofhowtouse

simu lations tounderstandthings

§Excusetocoversomeimportant

programming topics ?K3/A1=A2withclasses ?K3/A1 =A2 withplotting

6.0002

LECTURE53

E u lL5eRL1kr pRte

Leccctu

r5:Ranv E E E u s5. ihrrnyt.◦nLr2g2.c

Leccctu

r5:Rann E E E u (5h2o.L ihrrnyt.◦nLr2g2.c

Leccctu

r5:RanL

E E E E

u b.2 (5h2o.Lihrrnyt.◦nLr2g2.c

Leccctu

r5:RanC E E E u 6Rr2 ihrrnyt.◦nLr2g2.c

Leccctu

r5:RanK

E E E E

u ihrrnyt. lnr2R50.r()2.LMfhg2.cr

Leccctu

r5:RanM

Expected

DistanceAfter100,000Steps?

§Needadifferentapproachtoproblem

§Willus

e simulation

6.0002

LECTURE510

Structure

ofSimulation

§Simulateonewalksofksteps

§Simulatensuchwalks

§Report

averagedistancefromorigin

6.0002

LECTURE511

First,

SomeUsefulAbstractions

§3oqYtionÑY plYqe

§fielDÑY qolleqtion of plYqes YnD Drunks

§)runkÑsomeOoDy who wYnDers from

plYqe to plYqe in Y f ielD E E E u u 7tRrr

6h0R2nh5PcRL2x

class Location(object):

2yyElmYDk

lbWk def __init__(self, x, y): """x and y are floats""" self.x = x self.y = y def move(self, deltaX, deltaY): """deltaX and deltaY are floats""" return Location(self.x + deltaX self.y + deltaY def getX(self): return self.x def getY(self): return self.y

Leccctu

r5:RandU E E u 7tRrr

6h0R2nh5P0h52n5.1

def distFrom(self, other): xDist = self.x -other.getX() yDist = self.y -other.getY() return (xDist**2 + yDist**2)**0.5 def __str__(self): return '<' + str(self.x) + ', ' +str(self.y) + '>'

Leccctu

r5:Randv E u u u u u u u u u u u u 7tRrr lL5e class Drunk(object): def __init__(self, name = None): """Assumes name is a str""" self.name = name def __str__(self): if self §= None: return self.name return 'Anonymous' Ihl

PilkigkglhYkEOkwEDhiPlOh?i

Tu

YmOkpDmOOlhYkPioksPlkg

Leccctu

r5:Randn Two

SubclassesofDrunk

6.0002

LECTURE516

E E E u u u Mfh

8n51rh)lL5er

import random class UsualDrunk (Drunk): def takeStep(self): stepChoices = [(0,1), (0,-1), (1, 0), (-1, 0)] return random.choice(ste pChoices) class MasochistDrunk(Drunk): def takeStep(self): stepChoices = [(0.0,1.1), (0.0,-0.9), (1.0, 0.0), ( -1.0, 0.0)] return random.choice(stepChoices)

2yyElmYDk

hsihlX

Leccctu

r5:RandC E E E u 7tRrr ◦n.t1PcRL2x class Field(object): def __init__(self): self.drunks = {} def addDrunk(self, drunk, loc): if drunk in self.drunks raise ValueError('Duplicate drunk') else: self.drunks[drunk] = loc def getLoc(self, drunk): if drunk not in self.drunks: raise ValueError('Drunk not in field') return self.drunks[drunk]

Leccctu

r5:RandK E E u u u 7tRrr ◦n.t1P0h52n5.1 def moveDrunk (self, drunk): if drunk not in self.drunks raise ValueError('Drunk not in field') xDist, yDist = drunk.takeStep() #use move method of Location to get new location self.drunks[drunk] = self.drunks [drunk].move(xDist, yDist)

2yyElmYDk

hsihlX

Leccctu

r5:RandM E E E u gnatR2n5d

Rgn5dt.pRte

def walk(f, d, numSteps): """Assumes: f a Field, d a Drunk in f, and numSteps an int >= 0.

Moves d numSteps times; returns

the distance between the final location and the location at the start of the walk.""" start = f.getLoc(d) for s in range(numSteps): f.moveDrunk (d) return start.distFrom(f.getLoc(d))

Leccctu

r5:Rantc E E u gnatR2n5d

9t2nct.pRter

def simWalks (numSteps, numTrials, dClass): """Assumes numSteps an int >= 0, numTrials an int > 0, dClass a subclass of Drunk

Simulates numTrials walks of numSteps steps

each. Returns a list of the final distances for each trial"""

Homer = dClass()

origin = Location(0, 0) distances = [] for t in range(numTrials): f = Field() f.addDrunk(Homer, origin) distances.append(round(walk(f, Homer, numTrials), 1)) return distances

Leccctu

r5:Rantd E E E u i22n5d

N2(ttMhd.2o.L

def drunkTest (walkLengths, numTrials, dClass): """Assumes walkLengths a sequence of ints >= 0 numTrials an int > 0, dClass a subclass of Drunk

For each number of steps in walkLengths

quotesdbs_dbs17.pdfusesText_23