You are on page 1of 7

1. Suppose X ~ Exp(3). (a) Find the .95-quantile of X. (b) Find the .95-quantile for Y = X4 + 2. (c) Find the .

95-quantile of Z = 1/X. a) The CDF of the exponential random variable is F(x) = P(X <= x) = 1-e-x Here = 3, and we are interested in the value of x when CDF = 0.95. Hence, we equate CDF = 1-e-3x = 0.95. 1-e-3x=0.95, e-3x = 0.05, x = (-1/3)ln(0.05) x = 0.998577

Code in R: > qexp(p = 0.95,rate = 3) >0.998577

b) Y=X2+2 is given and hence we need to find y where P(Y<=y) = 0.95. Hence, P(X2+2<=y) = P(X<=(y-2)1/4) = 1-exp(-3(y-2)1/4) = 0.95 exp(-3(y-2)1/4) = 0.05 (y-2)1/4 = (-1/3)ln(0.05) y = 2 + (0.998577)4 = 2.99432.

c) Z=1/X is given and hence we need to find z where P(Z<=z) = 0.95. Hence, P(1/X<=z) = P(X>=1/Z) = 1-P(X<=1/Z) = 1- (1-e-3/z) = 0.95 1-e-3/z = 0.05 1/z = 0.017098 Z = 58.46.

2. Carmona 1.2 Part 1 and Part 2. 1. Generate a sample of size N = 1024 from the exponential distribution with parameter (rate) = 0.2. Call X the vector containing the sample values. > X = rexp(1024,rate=0.2) 2. Plot on the same graph, the exact (theoretical) density of the distribution of X, and a histogram of X. It is recommended to try several values for the numbers of bins, and to report only the result found most satisfactory. > Z = dexp(X,rate = 0.2) > hist(X,breaks = 30,probability = T,ylim = c(0,0.2),xlim = c(0,40), main = Density and Histogram of X) > points(X,Z,type = p)

3. a) Generate plots of closing price as a function of time-do this for both sets and give brief summary what plots show.

> X = read.csv("DJIA_Jan1950_Sept2007_wk.csv",header=TRUE) > DJ_Close_wk <- rev(X$Close) > windows() > par(mfrow=c(2,1)) > plot(DJ_Close_wk,xlab= 'Week',ylab = 'Closing Price',type = 'l') > Y = read.csv("DJIA_Jan1950_Sept2007_day.csv",header=TRUE) > DJ_Close_day <- rev(Y$Close) > plot(DJ_Close_day,xlab= 'Day',ylab = 'Closing Price',type = 'l')

b) Generate plots of log(Closing Price Return) as a function of time-do this for both data sets.

> DJ_close_LR_wk = diff(log(DJ_Close_wk)) > DJ_close_LR_day = diff(log(DJ_Close_day)) > windows() > par(mfrow=c(2,1)) > plot(DJ_close_LR_wk, xlab= 'Week', ylab = 'Weekly Log Return',type ='l') > plot(DJ_close_LR_day, xlab= 'Day', ylab = 'Daily Log Return',type ='l')

c) Generate summary statistics, histogram and boxplot of the log(closing price return)give a brief summary of interesting data features discovered based on this analysis. Summary Statistics: > summary(DJ_close_LR_wk) Min. 1st Qu. Median Mean 3rd Qu. Max. -0.153900 -0.009685 0.002494 0.001394 0.012960 0.118600 > summary(DJ_close_LR_day) Min. 1st Qu. Median Mean 3rd Qu. Max. -0.2563000 -0.0043130 0.0004185 0.0002897 0.0050270 0.0966600 Histogram: > hist(DJ_close_LR_wk,breaks = 75) > hist(DJ_close_LR_day,breaks = 150)

Boxplot:

> boxplot(DJ_close_LR_wk,range = 1.5) > title('Dow Jones Weekly Log Returns') > boxplot(DJ_close_LR_wk,range = 1.5) > title('Dow Jones Daily Log Returns')

You might also like