
stampa=TRUE

if(stampa) postscript(file="residui_da_lettura.eps",onefile=FALSE,horizontal=FALSE,height=5,width=7,pointsize=11)


n=100
x <- rnorm(n, 0, 2)        # in cm
y.d <- round(x*100)/100    # arrotondiamo al decimo di mm
sd.d = sd(y.d-x)           # scarto quadratico medio

y.m <- round(x*20)/20      # arrotondiamo al mezzo mm
sd.m = sd(y.m-x)           # scarto quadratico medio

data = matrix(c(x,y.d,y.m), c(n,3))

print(data[1:20,])

plot(x, y.d-x, ylim=c(-0.05,0.05), pch=19, col="blue",
     xlab='x (cm)', ylab='x.rounded - x (cm)')
abline(h=0, col="green")
points(x, y.m - x,  pch=19, col="red")
text(min(x), 0.04, pos=4, sprintf("std = %.3f mm", sd.d*10),
     col='blue', cex=2)
text(min(x), -0.04, pos=4, sprintf("std = %.3f mm", sd.m*10),
     col='red', cex=2)

if(stampa) dev.off()
