I have to admit that I'm completely new to R. Thus, my question may be very simple.
For an assignment, I need to simulate a random walk series. The initial position is a fixed point a on the real line. The first step is then taken with length X1 and the current position of the random walk process is changed to S(1)=a+X1. This process continues until n=1000.
After generating the random variable X~N(1,10^2) 1000 times, I need to report the value of S(n) and show the plot of this random walk series. I also need to report the mean and variance of the series.
This is what I have so far:
Each element of
x is a step, therefore, the total distance traveled, i.e. the value of S(N) is the sum of the elements. In addition, the distance traveled at each
S(p) equals the sum of the random walk vector
x up to index
cumsum you can generate the graph that shows the function of S(n) over time:
Not to be rude, but I think these kind of basic questions are typically something your supervisor or teacher is best equipped to help you with.