# arrivtel bis:
par( mai = c(0.5,0.5,0.1,0.1) )
ttel <- 14; ntel <- 0
plot(c(14,16),c(0,500),type="n")
abline(v=seq(14,16,1/6),h=seq(0,500,20),lty=3,col="grey")
abline(v=14,h=0)
text(14.8,450,"simulazione arrivo telefonate alla",cex=0.9,col="red")
text(14.8,420,"Ventel che ha comparse televisive",cex=0.9,col="red")
text(14.8,390,"tra 14 e 14:20, 15:10 e 15:30",cex=0.9,col="red")
v <- c(12,10,12,17,32,12,9,12,26)
w <- c(14.03,14.33,14.4,14.6,15.17,15.2,15.5,15.55,16)
for(i in 1:9) v[i] <- v[i]/3600
i <- 1; t <- 14; n <- 1
while(t <= w[9]) {
  d <- -v[i]*log(runif(1))/20; t <- t+d
  if(t <= w[9] & t >= w[i]) i <- i+1
  if(t < w[i]) n <- n+1/20; r <- (floor(n/50)-n/50)
  ttel <- c(ttel,t); ntel <- c(ntel,n)
  points(t,n,pch=".")  }
lines(ttel,ntel, col="blue")
length(ttel)
#
# uno zoom
text(15,80,"Clicca un qualunque punto")
{P <- locator(1)}
plot(c(15,16),c(200,400),type="n")
abline(v=seq(14,16,1/12),h=seq(0,500,20),lty=3,col="grey")
lines(ttel,ntel, col="blue")
text(15.55,240,"Clicca i due estremi del segmento")
text(15.55,225,"che approssima il tratto di maggiore")
text(15.55,210," pendenza per avere il valore di questa")
P <- locator(2)
P$x; P$y
lines(P$x,P$y,col="brown",lwd=3)
(P$x[2]-P$x[1])*60*60/(P$y[2]-P$y[1])
#
#