```# grafica, in particolare, applicata a statistica

x<-rnorm(1000)
plot(x)
plot(x, type="l")
plot(x, type="l", main='Rumore gaussiano', xlab='t', ylab='f(t)')
hist(x, nclass=50)
hist(x, nclass=50, col='yellow', main='Gaussiana', xlab='x', ylab='f', prob=TRUE)

n<-10; p=0.3
x<-0:n
fx<-dbinom(x,n,p)
Fx<-pbinom(x,n,p)
plot(x,fx)
plot(x,fx, type='h')
plot(x,Fx, type='s')
plot(x,fx, type='h',col='grey',lwd=10)

curve(dnorm(x),-3,3)
x<-rnorm(100000)
hist(x, nclass=50, col='yellow', main='Gaussiana', xlab='x', ylab='f', prob=TRUE)

x<-0:10                 #simuliamo delle coppie di punti legati deterministicamente
a<-0.1; b<-0.6
y<-a + b*x
plot(x,y)

y<-y+rnorm(x)           # aggiungiamo noise gaussiano sigma unitaria
# notare cosa fa rndm(x)
plot(x,y)

fit <- lm(y~1+x)
abline(fit\$coefficients[1],fit\$coefficients[2])

# per fare istogrammi su scala log, e altro, vedi ad es.
# info seguenti (prese da http://old.nabble.com/Histograms-on-a-log-scale-td24566433.html):
# Re: Histograms on a log scale
# Click to flag this post
# by Richard Cotton Jul 20, 2009; 12:00pm :: Rate this Message: - Use ratings to moderate (?)

# > I would like to be able to plot histograms/densities on a semi-log or
# > log-log scale.

# Get a random log-normal distribution
r <- rlnorm(1000)

# Get the distribution without plotting it using tighter breaks
h <- hist(r, plot=F, breaks=c(seq(0,max(r)+1, .1)))

# Plot the distribution using log scale on both axes, and use
# blue points
plot(h\$counts, log="xy", pch=20, col="blue",
main="Log-normal distribution",
xlab="Value", ylab="Frequency")

# This is very close to what I need, but how can I have filled rectangles
# in the plot, so that it looks more like a traditional histogram?
#  [hide part of quote]

#You can use type="h" to specify histogram-like plotting.  You probably
#also want to use a linear y-scale to make frequencies easier to compare.
#Change the last line to:

plot(h\$mids, h\$counts, log="x", pch=20, col="blue",
main="Log-normal distribution",
xlab="Value", ylab="Frequency", type="h")

#Alternatively, plot a histogram of the log data, and draw your own axes:

logr <- log(r)
par(las=2)
h2 <- hist(logr, axes=FALSE, breaks=seq(min(logr)-1, max(logr)+1, .5))
Axis(side=2)
Axis(side=1, at=h2\$mids, labels=format(exp(h2\$mids), digits=1), lty=NULL)

# Or, even better, install the ggplot2 package and try something like:

qplot(r, geom="histogram") + scale_x_continuous(trans="log10")

#Regards,
#Richie.```