October 2, 2007--Class 11 - Final Project, Intro. to Mathematica,
Random Walks
Activities:
Final Project
It is time to start thinking about your final project. Some
of you may have a problem related to your research that can
be used for the project. If not, there may be some problem
that interests you that would serve as a project. If you
don't have an idea of your own, you might like to look through
our text book. If there is a chapter that we will not cover,
you might find some homework problems that can be combined to
make a project. The book also has some suggestions for
projects. Some of these, even in chapters will will cover some
of may make suitable projects. So start to think about what
you want to do, because in a couple of weeks, I will be asking
everyone to get their project approved by me.
Here is how the final project will be graded:
Statement 10
Eq Solved 5
Num. Method 5
Code 5
Results 10
Discussion 10
Critique 5
------------------
Total 50
Introduction to Mathematica
An eight page handout on Mathematica is available as
~sg/mathematica_notes_sg.pdf
Over the next four classes we will go through the notes
and the examples it contains.
The material in sections A-E was elementary and known to most
people. Here is some elaboration about using mathematica to
define a random walk. We did not actually do the statistics of a
random walk after N steps in class.
Random walks
We can create a random walk with these two statements
randomStep[x_] := x + 2 Random[Integer] - 1
w = NestList[randomStep, 0, 5000];
We can make 1000 random walks of length 5000 and print the
ending value from each walk
v = Table[ w = NestList[randomStep, 0, 5000]; w[[Length[w]]], {i, 1000}]
Do[ Write["oct13.dat", v[[i]] ], {i, Length[v]}]
Note use of Length function to make sure we get the last value of
the list w, and that all of v is printed without needing to know
how long it is.
We expect that for a random walk of length N the mean value of the
final position is 0 and the the mean value of the final position
squared is N. We can use Mathematica's built in functions to test.
Mathetmatica can create histograms. These are part of the
Graphics add-on package.
Needs["Graphics`Graphics`"]
Histogram[v]
Mathematica can do statistical analysis. For this, you will need
the DescriptiveStatistics sub-package in the Statistics package:
Needs["Statistics`DescriptiveStatistics`"]
Mean[v]
Variance[v]
We did not actually need to run the Needs command to use Histogram,
Mean or Variance.