Random walk data post processing this is my first question on this site, so please be patient with me. I am doing a random walk, where I build a timeseries curve. I do that a preset number of times ( let's say 100 times ). Now I was wondering what should I do with all the generated curves. Eventually I want to have 1 curve that is the best representation. I tried taking the mean and median of the values for each point of time, but that gives me a rather tame and flat curve. What other options do I have? Your input is appreciated!
 A: I'm somewhat confused - if these are random walks, isn't the expectation a flat, uninteresting line?
set.seed(123)
nWalks <- 1000
nTimes <- 100
mat <- matrix(c(rep(0, nWalks), rnorm(nWalks*(nTimes-1))),
              ncol = nTimes)
rwalks <- apply(mat, 1, cumsum)
matplot(rwalks, type = "l")
## Stack the data for fitting a smoother
df <- stack(data.frame(rwalks))[, 2:1]
names(df) <- c("Walk","Xt")
df <- within(df, Time <- rep(seq_len(nTimes), nWalks))
## fit smother and predict
mod <- with(df, smooth.spline(Time, Xt))
pred <- predict(mod, x = 1:100)
lines(pred, col = "red", lwd = 4)

This gives:

Whilst the expectation doesn't do an awful lot, the range and the variance do slightly more-interesting things:
layout(1:3)
plot(apply(rwalks, 1, mean), type = "l", main = "Mean",
     ylab = "Mean")
plot(apply(rwalks, 1, var), type = "l", main = "Variance",
     ylab = "Variance")
plot(apply(rwalks, 1, max) - apply(rwalks, 1, min), type = "l",
     main = "Range", ylab = "Range")
layout(1)


The tiny fluctuations in the mean trace are due to sampling variation for the set of random walks I generated. it should settle down to be 0 if you up the number of random walks generated. (In any case, the value of the mean is effectively zero given the magnitude of the values the walks take.)
Perhaps you could explain a bit more what you mean by "best representation"?
A: Plotting the mean or median for each timepoint sounds a sensible start. You could also plot a reference range for each timepoint to show the variability across curves at each timepoint. You could also add a few (perhaps 5 or 10) randomly-chosen curves to illustrate the variability across timepoints within each curve. Should be perfectly possible to show all of those things on the same plot with a suitable choice of colours and line weights.
That should give a graphical depiction of the process's behaviou but doesn't really answer your requirement for 'one curve that is the best representation'. But to answer that we need to know what you mean by 'best' -- how will you use this 'best curve'? The mean or median may look too flat and boring to use it as the sole graphical display but may be the 'best' summary curve for quite a few purposes.
A: If you're simply looking for a way of representing a process for readers, look up "diffusion modelling" in the psychological literature and you'll find how those folks typically attempt to represent a stochastic process and typical exemplar.
