Increasing vector & another example [Two-Stage / GS Designs]
❝ In C you can get punished real bad if you do stuff like that.
Makes sense.
❝ Looks like R knows that users make occasional mistakes and will reallocate the array length when the user tries to set something that is out of bounds.
Couldn’t find anything about in the man-pages or on R-help. IMHO, R should at least throw a warning.
Another surprising goodie:
x <- runif(1e3)
ops <- 1e6
ptm <- proc.time()
for(i in 1:ops) { }
t0 <- proc.time()-ptm
ptm <- proc.time()
for(i in 1:ops) { y1 <- mean(x) }
t1 <- 1e6*(proc.time()-ptm-t0)/ops
ptm <- proc.time()
for(i in 1:ops) { y2 <- sum(x)/length(x) }
t2 <- 1e6*(proc.time()-ptm-t0)/ops
cat("\n",
sprintf("%14s: %.2f %s", "mean()", t1[3], "\u03bcs/op\n"),
sprintf("%14s: %.2f %s", "sum()/length()", t2[3], "\u03bcs/op\n\n"))
Dif-tor heh smusma 🖖🏼 Довге життя Україна!
![[image]](https://static.bebac.at/pics/Blue_and_yellow_ribbon_UA.png)
Helmut Schütz
![[image]](https://static.bebac.at/img/CC by.png)
The quality of responses received is directly proportional to the quality of the question asked. 🚮
Science Quotes
Complete thread:
- Gimmick & survey Helmut 2015-02-20 01:47
- Gimmick & survey nobody 2015-02-20 08:25
- Gimmick & survey Helmut 2015-02-20 13:01
- Gimmick & survey nobody 2015-02-20 14:18
- Speeed! Helmut 2015-02-20 15:38
- Speeed! nobody 2015-02-20 16:37
- Speeed! ElMaestro 2015-02-20 23:48
- Speeed! Helmut 2015-02-21 01:11
- Unrolled example ElMaestro 2015-02-21 01:32
- Unrolled example Helmut 2015-02-21 01:50
- Unrolled example ElMaestro 2015-02-21 02:27
- Increasing vector & another exampleHelmut 2015-02-21 13:13
- Unrolled example ElMaestro 2015-02-21 02:27
- Unrolled example Helmut 2015-02-21 01:50
- Speeed! nobody 2015-02-21 21:02
- Unrolled example ElMaestro 2015-02-21 01:32
- Speeed! Helmut 2015-02-21 01:11
- Speeed! Helmut 2015-02-20 15:38
- Gimmick & survey nobody 2015-02-20 14:18
- Gimmick & survey Helmut 2015-02-20 13:01
- Gimmick & survey nobody 2015-02-20 08:25