The best way to get acquainted with any software package is to run it through its paces. If the tasks specified in the first three sections were not enough of a work out, you can try some of the commands given below. Again, the tasks below are 100% optional. They are included only as a source of possibly interesting things to do to gain familiarity with S.
X rexp(100)
(remember that when X has exponential distribution with scale parameter 1, then 3X has exponential distribution with scale parameter 3). Next, sort the sample using sort. Next, create a new vector yp as you did in Section I, except this time, let p contain 100 equally spaced values strictly between 0 and 1. Finally plot the sorted sample against this yp. What do you find?
X<- rexp(100)
Use the command hist to construct a histogram of Y. Keeping in mind that a histogram can be used to get an idea of what the density of a distribution looks like, what curve do you expect to see from this plot? (Hint: See the solution to Problem 7 in Section 1.7 of your text). Plot this curve within the range of the horizontal axis of the histogram.
Try this problem again, but set Y = exp(X) and consult Problem 8 of Section 1.7 of your text.
p<-p/sum(p)
These commands will give you a vector of positive numbers that sum to one. Let X
denote a random variable such that , where
is the ith element of
.