Experimenting with R
Generate random samples from a pdf or a pmf
Here is a sample program for generating random samples of size 100 from
a normal distribution with mean 0 and variance=4.
y <- rnorm(mean=0,sd=2,n=100)
A few procedures can produce summary"statistics, 5-points summary,
stem-and-leaf plot and histograms.
summary(y)
fivenum(y)
stem(y)
hist(y)
Shape of pdf, pmf
Next program sketches the pdf of N(0,1).
x <- seq(-3,3, by=.2)
y<- dnorm(x,mean=0,sd=1)
plot(x,y)
For other common pdf's and pmf's, you are referred to probability
distributions section (p 34--36) on An introduction to R
is available online in Rgui window or at
Reference Desk.
Updated 030930 by Andy Tsao