Assignment 2 l Memorial University of Newfoundland STAT 3585
Stat 3585: Computational Statistics
Assignment # 2: Due 22 Oct 2013 (in class)
Note: You should submit a printout that show answers / plots to all the questions together with the R codes. If you need any help, please contact the instructor.
Question 1: The (Euclidian) length of a vector v = (a0; a1; : : : ; ak) is the square ro
...[Show More]
Assignment 2 l Memorial University of Newfoundland STAT 3585
Stat 3585: Computational Statistics
Assignment # 2: Due 22 Oct 2013 (in class)
Note: You should submit a printout that show answers / plots to all the questions together with the R codes. If you need any help, please contact the instructor.
Question 1: The (Euclidian) length of a vector v = (a0; a1; : : : ; ak) is the square root of
the sum of squares of its co-ordinates, that is qa2 0 + a2 1 + : : : + a2 k. Write a function that
returns the length of vector.
Questions 2: In class, we wrote a program for finding out the number of months required
to repay the loan amount of $5000 at the interest rate of $3:6% per year. Write a general
function that take the argument of loan amount, monthly repayment and interest rate
such that it returns the monthly interest paid for the required number of months.
Question 3: Consider the following program.
# clear the workspace
rm(list=ls())
random.sum<-function(n){
x[1:n] <- ceiling(10*runif(n))
cat("x:",x[1:n],"\n")
return(sum(x))
}
set.seed(3585)
x=rep(100,10)
show(random.sum(10))
show(random.sum(5))
When you cut and paste the above program, following results obtained.
[Show Less]