Tags » Random Walk

MIT 6.00SC | Lecture 13 | Some Basic Probability and Plotting Data

Introduction

In the last lecture, we had a error in our code, because the Random walk code, did not output correct value of small samples as we had manually checked. 1,006 more words

MIT OCW

MIT 6.00SC | Lecture 12 | Introduction to Simulation and Random Walks

Generator Yield

We will start with the example in the previous lecture, see the code here;-

import datetime

class Person(object):
def __init__(self, name):
#Create a person with name
self.name = name
try:
firstBlank = name.rindex(' ')
# print "__init__: firstBlank: ", firstBlank
self.lastName = name
except :
self.lastName = name
self.birthDay = None
def getLastName(self):
#returns self's last name
return self.lastName
def setBirthday(self,birthDate):
#assumes that self's birthday is of type datetime.date
#sets self's birthday to birthDate
assert type(birthDate) == datetime.date
self.birthDay = birthDate
def getAge(self):
#assumes that self's birthday is set
#returns self's age in days
assert self.birthDay != None
return (datetime.date.today() - self.birthDay).days
def __lt__(self,other):
#returns True if self name is lexicographically greater
#than other's name, and False Otherwise
if self.lastName == other.lastName:
return self.name < other.name
return self.lastName < other.lastName
def __str__(self):
return self.name

class MITPerson(Person):
nextIDNum = 0
def __init__(self, name):
#super(MITPerson, self).__init__()
Person.__init__(self,name)
self.idNum = MITPerson.nextIDNum
MITPerson.nextIDNum += 1
def getIdNum(self):
return self.idNum
def __lt__(self, other):
return self.idNum < other.idNum
def isStudent(self):
return type(self)==UG or type(self)==G

class UG(MITPerson):
def __init__(self, name):
MITPerson.__init__(self, name)
self.year = None
def setYear(self, year):
if year > 5:
raise OverflowError('Too many')
self.year = year
def getYear(self):
return self.year

class G(MITPerson):
pass

class CourseList(object):
def __init__(self, number):
self.number = number
self.students = []
def addStudent(self, who):
if not who.isStudent():
raise TypeError('Not a student')
if who in self.students:
raise ValueError('Duplicate student')
self.students.append(who)
def remStudent(self, who):
try:
self.students.remove(who)
except:
print str(who) + ' not in ' + self.number
def allStudents(self):
for s in self.students:
yield s
def ugs(self):
indx = 0
while indx < len(self.students):
if type(self.students) == UG:
yield self.students
indx += 1
… 1,494 more words
Python

Term of the day: Random walk

In economics the “random walk” refers to the fact that the stock market price can not be predicted, because the historical movement of a stock price is not consistent with the future movement. 111 more words

Economics

An Entanglement with a great mind: Prof. V. Balakrishnan

–Dinesh K. Pinto

It’s been exactly two weeks since Prof V. Balakrishnan, or, as he’s more popularly known in physics circles; ‘the guy wrote the foreword to the Feynman lectures’ returned to St. 967 more words

The Perspective

Pivot algorithm of self-avoiding chain using Python and Cython

Pivot algorithm is best monte carlo algorithm known so far used for generating canonical ensemble of self-avoiding random walks(fixed number of steps). Originally it is for the lattice random walk, but it also can be modified for continuum random walk. 1,579 more words

Academic Life

Simulating Random Walks using Langevin Equation

Random walks (Brownian motions), in addition to their theoretical potency (describes macro-scale behavior of gas starting with micro-scale description), also describes behavior of many processes in nature. 484 more words

Algorithms