user622194
user622194

Reputation:

help with math in R

Need help to plot graphs:

Wt contains 1000 Iterators on how far one has walked the 100 steps. Mean and sd are the mean and standard deviation of those 1000. I am asked to create five graphs showing from the starting position to the end position after a hundred steps with time t on the x-axis and the status of the y-axis. t is 100.

Can someone explain and show how to plot graph like that?

Code for Wt:

 Wt = NULL
    for(i in 1:1000){
        Xk = rnorm(100,mean=0.4,sd=0.7)
        Wt[i]=sum(Xk)
    }

    mean(Wt)
    sd(Wt)

Upvotes: 1

Views: 147

Answers (1)

mbq
mbq

Reputation: 18628

matplot(replicate(5,cumsum(rnorm(100,mean=0.4,sd=0.7))),type="l")

Upvotes: 1

Related Questions