problemset4

# Problemset4

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 360 0.1680 0.1064 0.0507 r=3 0.4544 0.3788 0.3120 0.2505 0.1936 0.1401 0.0902 0.0435 r=4 0.3334 0.2824 0.2360 0.1936 0.1531 0.1135 0.0746 0.0367 r=5 0.2309 0.1979 0.1680 0.1401 0.1135 0.0870 0.0591 0.0298 r=6 0.1429 0.1238 0.1064 0.0902 0.0746 0.0591 0.0426 0.0227 r=7 0.0667 0.0583 0.0507 0.0435 0.0367 0.0298 0.0227 0.0145 Table 4: Computed probabilities for the three-person ballot problem for p = 8. A C++ codes for simulating the Cauchy ﬁrst passage problem This listing provides a simple C++ code for generating the distribution of ﬁrst passage times for a Cauchy walk. The code accepts two command line argumerts: the drift parameter d, and a random seed. Once all walks have been simulated, the ﬁrst passage probabilities for each number of walk step are printed to the standard output. Walks which did not achieve ﬁrst passage in n steps are listed in the ﬁnal line of the output. #include <string> #include <iostream> #include <cstdio> #include <cmath> using namespace std; const double p=3.1415926535897932384626433832795; const long n=10000; //Cutoff number of steps const long w=10000000; //Number of walkers double d=0; //Drift inline int cauchy() { static double x;x=1; for(int i=0;i<n;i++) { x+=d+tan(((double(rand())+0.5)/RAND MAX −0.5)∗p); if (x<0) return i; } return n; } int main(int argc,char ∗ argv) { srand(atoi(argv[1])); M. Z. Bazant – 18.366 Random Walks and Diﬀusion – Problem Set 4 Solutions q q q q q q q q q =0 =1 =2 =3 =4 =5 =6 =7 =8 r=0 1.0000 0.8000 0.6362 0.5000 0.3849 0.2860 0.2000 0.1250 0.0588 r=1 0.8000 0.6544 0.5303 0.4236 0.3301 0.2477 0.1750 0.1103 0.0523 r=2 0.6362 0.5303 0.4379 0.3550 0.2801 0.2129 0.1521 0.0968 0.0462 r=3 0.5000 0.4236 0.3550 0.2921 0.2343 0.1807 0.1307 0.0841 0.0406 r=4 0.3849 0.3301 0.2801 0.2343 0.1914 0.1501 0.1103 0.0719 0.0351 r=5 0.2860 0.2477 0.2129 0.1807 0.1501 0.1203 0.0902 0.0600 0.0298 r=6 0.2000 0.1750...
View Full Document

## This note was uploaded on 01/23/2014 for the course MATH 18.366 taught by Professor Martinbazant during the Fall '06 term at MIT.

Ask a homework question - tutors are online