Thursday, December 23, 2010
Monday, May 24, 2010
Graphics:
### Normal distribution
curve(dnorm(x),xlim=c(-4,4),ylab="density",main="Normal Distribution")
# 2 normal curves
curve(dnorm(x,mean=0,sd=5), xlim=c(-20,50), col="red")
curve(dnorm(x,mean=25,sd=5), add=TRUE, col="blue")
### y^2 = 4*x
y = seq(0, 5, by=0.01)
y.upper = 2*sqrt(x)
y.lower = -2*sqrt(x)
y.max = max(y.upper)
y.min = min(y.lower)
plot(c(-2,5), c(y.min,y.max), type="n", xlab="x", ylab="y")
lines(x, y.upper)
lines(x, y.lower)
abline(v=-1)
points(1,0)
text(1,0,"focus (1,0)", pos=4)
text(-1,y.min,"directrix x = -1", pos=4)
title("The parabola y^2 = 4*x")
### x^2 - y^2/3 = 1
plot(c(-max(x),max(x)),c(-max(y),max(y)),type='n',xlab='x',ylab='y')
x = seq(1,5,by=0.01)
y = sqrt(3*x^2-3)
lines(x,y); lines(-x,y); lines(x,-y); lines(-x,-y);
abline(0,sqrt(3)); abline(0,-sqrt(3))
points(2,0); points(-2,0)
text(2,0,"focus (2,0)",pos=4)
text(-2,0,"focus (2,0)",pos=2)
text(5,8.5,"asymptote y = sqrt(3)*x", pos=2)
###
opar1 = par(las=1, mar=c(4,4,3,2))
plot(cars$speed,cars$dist,axes=FALSE,xlab="",ylab="",type="n")
points(cars$speed, cars$dist,
col=ifelse(cars$speed>9,"darkseagreen4","red"),
pch=ifelse(cars$speed>9,1,3))
axis(1);axis(2)
opars = par(las=0)
mtext("Speed (mph)",side=1,line=3)
mtext("Dist (ft)",side=2,line=3)
box()
legend(x=10,y=100,c("Low","High"),
col=c("darkseagreen3","red"),
pch=c(3,1),bty="n")
###
curve(100*(x^3-x^2)+15, from=0, to=1,
xlab=expression(alpha),
ylab=expression(100 %*% (alpha^3 - alpha^2) +15),
main=expression(paste("Function : ",
f(alpha) == 100 %*% (alpha^3 - alpha^2) + 15)))
myMu = 0.5; mySigma = 0.25
par(usr=c(0,1,0,1))
text(0.1,0.1,bquote(sigma[alpha] == .(mySigma)), cex=1.25)
text(0.6,0.6,paste("(The mean is ", myMu, ")", sep=""), cex=1.25)
text(0.5,0.9,bquote(paste("sigma^2 = ", sigma^2 == .(format(mySigma^2,2)))))
Subscribe to:
Posts (Atom)