(*
	(c) 2001, 2010 Alex Kontorovich
*)

(* Makes 3x+1 paths*)

(* Seed *)
start=1234567891011;

length=100;

(* CODE *)
coll[x_]:=Module[{y},
y=3x+1;
While[Mod[y,2]==0,
y=y/2;
];
y
];
path={start};
step=start;

(* Make a path *)

For[i=1,i<length,i++,
step=coll[step];
AppendTo[path,step];
];

(* Normalize *)
logpath=Log[path];
driftpath=logpath;
For[i=1,i≤length,i++,
driftpath[[i]]-= i Log[3/4];
];


(* Now make a random path *)
randompath=logpath; (* just to make it same length *)
randompath[[1]]=0;
For[i=2,i≤length,i++,
randompath[[i]]=randompath[[i-1]]+2Random[Integer,{0,1}]-1;
];

(* pic1 is normalized 3x+1 *)

pic1=ListPlot[driftpath,Axes->False,Joined->True,PlotStyle->Thick,InterpolationOrder->4]

(* pic2 is just a random walk *)
pic2=ListPlot[randompath,Axes->False,Joined->True,PlotStyle->Thick,InterpolationOrder->4]