2012-2013/1ES/DS/DS_130214/DM.R
2017-06-16 09:45:50 +03:00

73 lines
1.9 KiB
R
Executable File

#!/usr/bin/env Rscript
arondis = function(num, precision){
floor(num*10^precision)*10^(-precision)
}
# Exo 68p174
catta = c(3.1, 4, 3.2, 3.9, 4, 3)
vari = c(4.8, 5.4, 4.6, 5.3, 4.4, 5.7)
study68 = function(data){
print(c("Données", data))
print(c("Moyenne: ", arondis(mean(data), 2)))
print(c("Ecrat-type: ", arondis(sd(data),3)))
print(c("Coef varia", arondis(sd(data)/mean(data),3)))
}
print("Les cattas")
study68(catta)
print("Les varis")
study68(vari)
# # Exo 70p175
# garcon_pix = c(1001121,1038437,965353,904858, 955466,1079549,924059,945088,889083, 905940, 955003, 935494, 1062462,949589,997925,879987,949395,930016,935863,892420)
# garcon_QI = c(150,123,129,93,114,150, 129, 96, 77, 107, 145, 145, 96, 145, 96, 96, 150, 90, 89, 83)
# fille_pix = c(816932,951545,928799,991305,854258,833868,856472,878897,865363,852244,808020,790619,831772,798612,793549,899662,857782,834344,948066,893983)
# fille_QI = c(132,132,90,136,90,129,120,100,71,132,112,129,86,90,83,126,126,90,129,86)
#
# myquartile = function(data){
# print(sort(data))
# len = length(data)
# print(paste("longueur",len))
# print(paste("1 quart (",ceiling(len/4),"ieme valeur)", (data[ceiling(len/4)])))
# if (len %% 2) {
# med = data[(len-1)/2]
# print(paste("Median (", (len-1)/2, "): ",med))
# }
# else {
# med = (data[len/2] + data[len/2+1])/2
# print(paste("Mediane: (moyenne de la", len/2, "->", data[len/2], "et", len/2 + 1, "->", data[len/2+1],"):" ,med))
# }
# print(paste("3 quart :", (data[ceiling(3*len/4)])))
# }
#
#
# study70_1 = function(data){
# print(summary(data))
# }
#
# compare70 = function(data1, data2){
# boxplot(list(a = data1, b=data2))
# }
#
# print("Garçons")
# myquartile(sort(garcon_pix))
# myquartile(sort(garcon_QI))
#
#
# print("Filles")
# myquartile(sort(fille_pix))
# plop = myquartile(sort(fille_QI))
#
# boxplot(list(a = garcon_pix, b=fille_pix))
# boxplot(list(a = garcon_QI, b=fille_QI))
# 68 p 149