# Exercice 2

v0 = c(51.4 ,64,71,82,98.7,pi)
v1 = rep(c(5,6,3))
v2 = rep(1:10,1:10)
k = seq(1,10,2)
v3 = c("jolie","john","moi")
v4 = c(1i,8+5i,9-7.5i)

#Exercice 4

x = c(2,3,4,5,6)
print(x)
a = c(x[1:3])
a
b= c(x[1],x[3],x[5])
b
a+b
x+a
x*2
a*b
# ind <-which(x%%2 ==0)
x[which(x%%2 ==0 & x%%3 ==0)]
x[which(x%%2 ==0 | x%%3 ==0)]
ind = which(x%%2 ==0)
ind
ls()

#Exercice 5

y = rep(0:10,2)
matrix(y,nrow = 2)
matrix(y,nrow = 2,ncol=11)
matrix(y,nrow = 2,byrow=TRUE)
c = seq(0,20,2)
A = matrix(c,nrow = 4,ncol=3,byrow=TRUE)
A
B = matrix(1:12,nrow = 3,ncol=4,byrow=TRUE)
B
C = rbind(A[2,],A[4,])
C
E = cbind(A[2,],A[4,])
E
colSums(A)
rowSums(A)
A%*%B
#A*B

#Exercice 8
v = c(68,119,33,15,54,24,25,113,141)
X = matrix (v,nrow= 3,ncol=3,byrow=TRUE)
X
nomligne = c("Marrons","Noisette","Bleus")
nomcol= c("Bruns","Chatains","Blonds")
dimnames(X)= list(nomligne,nomcol)
X



#Exercice 9

A = matrix(0,nrow=5,ncol=5)
A
B= abs(col(A)-row(A))+1
B
det(B)
solve(B)%*%B

c = c(1,2,2,3,2)
solve(B,c)


# Eexercice 14

k = c(1:6)
k
pk = rep(1/6,6)
pk
df = data.frame(k,proba=pk)
print(df)
df$proba[1:4]
max(df$proba)
summary(df)
weighted.mean(k,pk)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: