Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #EXO1
- a<-c(3,5,7,11)
- a[2]
- a[1:3]
- a[a>5]
- #EXO 2
- stat.log <- function (x)
- {
- n<-length(x)
- s<-0
- for (i in (1:n)) {s<-s+x[i]}
- s/n
- }
- stat.log(a)
- #EXO 3
- #a
- echantillon <- rnorm (10,0,1)
- echantillon10 <- rnorm (50,0,1)
- echantillon11 <- rnorm (500,0,1)
- echantillon
- #b
- echantillon2 <- rexp(10,0.1)
- echantillon2
- echantillon3 <- rexp(50,0.1)
- echantillon3
- echantillon4 <- rexp(500,0.1)
- echantillon4
- #c
- echantillon5 <- runif(10,0,1)
- echantillon5
- echantillon6 <- runif(50,0,1)
- echantillon6
- echantillon7 <- runif(500,0,1)
- echantillon7
- #EXO4
- produits <- c("Cancoillotte","Saucisse de Montbéliard","Edel de Clairon", "Saucisse de Morteau","Mont D'or","Vin jaune")
- chiffres <- c(1950,470,670,920,750,715)
- pie (chiffres, labels = produits)
- #EXO 5
- barplot(chiffres,names = produits)
- #EXO 6
- enfants <- c("0","1","2","3","4","5","6",">6")
- freq <- c(235,183,285,139,88,67,3,0)
- pie(freq,labels=enfants)
- #EXO 7
- #1
- echantillon8 <- c(91.6,35.7,251.3,24.3,5.4,67.3,170.9,9.5,118.4,57.1)
- echantillon9 <- sort(echantillon8)
- #2
- hist(echantillon8,prob=F,breaks=seq(3,260,50))
- #3
- h<-hist(echantillon8,prob=T,breaks=c(3,15,50,90,160,260))
- abs<-h$mids
- abs
- #4
- lines(h$mids,h$density)
- #EXO 8
- h1 <- hist(echantillon,prob=T)
- h10 <- hist(echantillon10,prob=T)
- h11 <- hist(echantillon11,prob=T)
- h2 <- hist(echantillon2,prob=T,breaks=c(1,40,5))
- h3 <- hist(echantillon5,prob=T,breaks=c(0.1,1,0.2))
- #EXO 9
- #1 et 2
- x <- summary(a)
- moyenne <- mean(x)
- variance <- var (x)
- mediane <- median(x)
- quartile <- quantile (x)
- moyenne
- variance
- mediane
- quartile
- #3
- summary (echantillon2)
- # EXO 10
- #1
- val <- 1
- x<-seq(0,10,1)
- y<- -4*x+1+ rnorm(length(x),0,val)
- plot(x,y)
- #3
- b0 <- mean(y)-cov(x,y)/var(x)*mean(x)
- b1 <- cov(x,y)/var(x)
- b0
- b1
- y1 <- b1*x+b0
- plot(x,y1)
- #4
- reg <- lm(y~x)
- summary(reg)
- abline(reg)
- coeff <- cor(x,y)
- coeff
- erreurmoyenne <- function (x)
- {
- n <- length (x)
- m <- mean(x)
- erreurmoy2 <- 0
- for (i in(1:n)) {s <- (x[i]-m)^2}
- erreurmoy <- 1/n
- }
- erreurmoyenne(x)
- erreurmoy = var(y) - (1-cor(x,y))^2
- erreurmoy
- #Exo11
- lines(density(echantillon11))
- plot(ecdf(echantillon11))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement