[1] 1 2 3 4 5
: vrai ou faux et pourquoi ?
(1,2,3,4,5)
c(1,2,3,4,5)
1:5
1,5
rep(1,5)
seq(1,5)
cumsum(rep(1,5))
which(rep(1,5)==1)
which(rbin(5,1,1)<1)
sort(sample(1:5,5))
sort(seq(5,1,-1))
for (i in 1:5){v[i] <- i}
v <- rep(1,5); for (i in 1:5){v[i] <- i}; v
v <- 1; for (i in 2:5){append(v,i)}; v
v <- 1; for (i in 2:5){v <- append(v,i)}; v
v <- 1; for (i in 2:5){v <- c(v,i)}; v
v <- 1; for (i in 2:5){v <- rbind(v,i)}; v
v <- rep(1,5); while (i<5){v[i] <- i}; v
v<- 1; i<-1; while (i<5){i<-i+1; v[i] <- i}; v
[1] 1 0.5 0.25 0.125 0.0625
: vrai ou faux
et pourquoi ?
2^-0:4
2^(-0:4)
2^-(0:4)
2^(-(0:4))
1/2^0:4
1/2^(0:4)
cumprod(rep(0.5,5))
cumprod(c(1,rep(0.5,4)))
v<-1; for (i in 1:4){v <- c(v,v/2)}; v
v<-rep(1,5); for (i in 0:4){v(i) <- 2^(-i)}; v
v<-1; for (i in 0:4){v[i] <- 1/2^i}; v
v<-1; for (i in 2:4){v[i] <- 1/2^i}; v
v<-1; while (v>0.1){v <- v/2}; v
x<-1; v<-x; while(x>0.1){x<-x/2; v<-c(v,x)}; v
0 1
, la seconde ligne est le vecteur
1 0
: vrai ou faux et pourquoi ?
[[0,1];[1,0]]
rbind(c(0,1),c(1,0))
cbind(0:1,1:0)
matrix(c(0,1,1,0),2,2)
matrix(rep(c(0,1),2),2,2)
diag(rep(1,2))
1-diag(rep(1,2))
v <- c(1,0); cbind(v,v)
v <- c(1,0); rbind(sort(v),v)
c(1,0)%*%t(c(0,1))+c(0,1)%*%t(c(1,0))
1:0%*%t(0:1)+0:1%*%t(1:0)
1:0*t(0:1)+0:1*t(1:0)
toeplitz(c(0,1))
toeplitz(0:1)
as.vector(rbind(rep(0,n),1:n))
matrix(cbind(rep(0,n),1:n),1,2*n)
matrix(rbind(rep(0,n),1:n),1,2*n)
as.vector(matrix(rbind(rep(0,n),1:n),1,2*n))
as.vector(matrix(rbind(1:n,rep(0,n)),2*n,1))
as.vector(0:1%*%t(1:n))
as.vector(1:n%*%t(1:0))
as.vector(1:n%*%t(0:1))
v<-0; for (i in 1:n){v[2*i]<-i}; v
v<-rep(0,2*n); for (i in 1:n){v[2*i]<-i}; v
v<-c(0,1); for (i in 2:n){v<-c(v,c(0,i))}; v
v<-c(0,1); for (i in 2:n){v<-c(v,0:i)}; v
1:n*0:n-1/2
1:n*0:(n-1)/2
1:n*seq(0,n-1)/2
v<-1:n; v^2-v/2
v<-1:n; (v^2-v)/2
v<-1:n; v%*%(v-1)/2
cumsum(0:n-1)
cumsum(0:(n-1))
cumsum(seq(0,n-1))
v<-rep(0,n); for (i in 1:n){v(i)<-i*(i-1)/2}; v
v<-rep(0,n); for (i in 1:n){v[i]<-i*(i-1)/2}; v
v<-0; for (i in 2:n){v<-c(v,i*(i-1)/2)}; v
sum(v*10^-1:length(v))
sum(v*10^-(1:length(v)))
sum(v%*%10^-(1:length(v)))
paste("0",".",v)
paste(c("0",".",v))
paste(c("0",".",v),collapse='')
as.numeric(paste(c("0",".",v),collapse=''))
x<-0; d<-0.1; for (i in v){x<-x+d*i; d<-d/10}; x
x<-0; for (i in v){x<-x+i*10^(-i)}; x
v
un vecteur de taille , contenant les fréquences
empiriques des entiers entre et : vrai ou faux
et pourquoi ?
v<-table(x)/length(x)
v<-table(factor(x,levels=1:5))/length(x)
v<-as.vector(table(factor(x,levels=1:5))); v/sum(v)
v<-rep(1,5); for (i in 1:5){v[i]<-which(x=i)}; v/sum(v)
v<-rep(1,5); for (i in 1:5){v[i]<-length(which(x==i))}; v/sum(v)
mean(x)
sum(x)/length(x)
mean(table(x))
mean(as.vector(table(x))
t <- table(x); sum(as.numeric(row.names(t))*as.vector(t))/length(x)
median(x)
quantile(x,0.5)
as.numeric(quantile(x,0.5))
as.vector(quantile(x,0.5))
x[length(x)/2]
sort(x)(round(length(x))/2)
sort(x)[floor(length(x)/2)]
rbernoul(n,0.5)
rbinom(n,0.5)
rbinom(n,1,0.5)
runif(n,0,1)
floor(runif(n,0,2))
round(runif(n,0,1))
ceiling(runif(n,0,2))
ceiling(runif(n,0,2))-1
(1+sign(rnorm(10)))/2
(1+sign(rnorm(10,0,2)))/2
(1+sign(rnorm(10,2,0)))/2
ifelse(rnorm(n)<0,yes=0,no=1)
ifelse(runif(n,0,2)<0.5,yes=0,no=1)
rep(0,n); v[which(runif(n,0,1)<0.5)]=1
rep(n,0); v[which(runif(n,0,1)<0.5)]=1
ifelse(rgeom(n,0.5)>0,yes=1)
ifelse(rgeom(n,0.5)>0,yes=0,no=1)
sample(n,c(0,1))
sample(c(0,1),n)
sample(c(0,1),n,replace=TRUE)
qnorm(0.5)
qnorm(0.5,0.5)
dnorm(100)
pnorm(0.5)
pbinom(1,1,0,lower=F)
dbinom(1,1,1)
dbinom(2,1,0.5)
ppois(0,1000)
qgeom(0.6,0.5)
qgeom(0.4,0.5)
qt(0.5,3)
qchisq(0.5,3)
t.test(x)$conf.int
as.vector(t.test(x)$conf.int)
mean(x)+sd(x)*qnorm(0.975)*c(-1,1)
mean(x)+sd(x)*qnorm(0.975)*c(-1,1)/sqrt(length(x))
mean(x)+sd(x)*qnorm(0.025,0.975)/sqrt(length(x))
mean(x)+sd(x)*qnorm(c(0.025,0.975))/sqrt(length(x))
t.test(x)$p.value
t.test(x,alternative="greater")$p.value
pnorm(mean(x)/sd(x))
pnorm(sqrt(length(x))*mean(x)/sd(x))
1-pnorm(sqrt(length(x))*mean(x)/sd(x))
pnorm(sqrt(length(x))*mean(x)/sd(x),lower.tail=F)