Browse Source

Script R pour lecture et statistiques sur les données

Samuel Delepoulle 3 years ago
parent
commit
cce1822fc9
2 changed files with 246 additions and 2 deletions
  1. 4 2
      README.md
  2. 242 0
      analyse/analyse.R

+ 4 - 2
README.md

@@ -1,5 +1,7 @@
 *** Sample_Analysis ***
 
-Scripts web d'analyse de path tracing.
-
+Scripts web d'analyse statistiques de path tracing.
 
+Nécessite : 
+- php 
+- R : https://cran.r-project.org/

+ 242 - 0
analyse/analyse.R

@@ -0,0 +1,242 @@
+#!/usr/bin/Rscript
+
+args <- commandArgs(TRUE)
+dist <- read.table(args[1])
+taille = args[2]
+taille = as.integer(taille)
+tailleTotale = length(dist$V1)
+
+
+#cat("taille demandée = ",taille,"\n");
+#cat("taille totale = ",tailleTotale,"\n");
+
+if (taille>tailleTotale){
+	taille = tailleTotale;
+}
+
+png("fig.png", width = 400, height = 300) 
+#pdf("fig.pdf") 
+
+#x11()
+
+#options(devices="X11")
+
+#vdist = dist$V1[1:100]
+vdist = dist$V1[1:taille]
+#vdist = dist$V1
+
+#v = ks.test(vdist,pnorm,mean(vdist),sd(vdist))
+
+n = length(vdist)
+
+#skew = mean((vdist-mean(vdist))^3)/sd.pop(vdist)^3
+m3 <- sum((vdist - mean(vdist))^3)/length(vdist)
+s3 <- sqrt(var(vdist))^3
+skew = m3/s3
+
+cat("taille de l'échantillon = ",n,"\n\n")
+
+cat("moyenne = ",mean(vdist)," ")
+cat("mediane = ",median(vdist),"\n\n")
+
+cat("min = ",min(vdist)," ")
+cat("max = ",max(vdist),"\n\n")
+
+cv = 100*sd(vdist)/mean(vdist)
+if (mean(vdist) == 0) cv=0
+
+cat("écart-type",sd(vdist),"\n")
+cat("coef. de variation = ",cv)
+
+if ( cv < 5 ) {
+	cat (" pas de bruit\n\n")
+} else if (cv<33) cat (" bruit faible\n\n")	else cat (" bruit important\n\n")
+
+
+
+	
+
+
+quant <- quantile(vdist)
+cat("quartiles ",quant,"\n");
+cat("écart semi-interquartiles ",(quant[4]-quant[2])/2,"\n");
+
+#skew = mean((vdist-mean(vdist))^3)/sd.pop(vdist)^3
+m3 <- sum((vdist - mean(vdist))^3)/length(vdist)
+s3 <- sqrt(var(vdist))^3
+skew = m3/s3
+cat("skewness = ",skew,"\n");
+
+
+hist(vdist,col = "blue",breaks = 50,freq = FALSE)
+den <- density(vdist)
+lines(den, col = "red")
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+dev.off()