Skip to content

Commit

Permalink
Add example 10.7
Browse files Browse the repository at this point in the history
  • Loading branch information
aaaakshat committed Nov 16, 2021
1 parent 0a36938 commit f3d92c3
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions ch10.r
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,35 @@ for (i in 1:20) {
matplot(t, x, lwd=2, col="gray")
grid()
lines(t, 0*cos(2*pi*t), lwd=4, col="darkred")

## Example 10.8

# R code for Example 10.7
x = matrix(0, 21, 20)
t = 0:20

for (i in 1:20) {
x[,i] = runif(1) ^ t
}

stem <- function(x,y,pch=1,...){
if (missing(y)){
y = x
x = 1:length(x)
}
for (i in 1:length(x)){
lines(c(x[i],x[i]), c(0,y[i]), ...)
}
lines(c(x[1]-2,x[length(x)]+2), c(0,0), ...)
}

matplot(t, x, pch=1, col="gray", lwd=2)
grid()

for (i in 1:ncol(x)) {
stem(t, x[,i], col="gray", lwd=2)
}
stem(t, 1/(t+1), col="darkred", lwd=2, pch=1, type="o")



0 comments on commit f3d92c3

Please sign in to comment.