Get premium membership and access revision papers, questions with answers as well as video lessons.
Got a question or eager to learn? Discover limitless learning on WhatsApp now - Start Now!

Sta 2202: Introduction To Computer Interactive Statistics Question Paper

Sta 2202: Introduction To Computer Interactive Statistics 

Course:Bachelor Of Science In Actuarial Science

Institution: Dedan Kimathi University Of Technology question papers

Exam Year:2013



Page 1 of 3
DEDAN KIMATHI UNIVERSITY OF TECHNOLOGY
University Examination 2013/2014
SECOND YEAR FIRST SEMESTER EXAMINATION FOR THE DEGREE OF
BACHELOR OF SCIENCE IN ACTUARIAL SCIENCE
STA 2202: INTRODUCTION TO COMPUTER INTERACTIVE STATISTICS
DATE: 15TH AUGUST 2013 TIME: 8.30AM – 10.30AM
Instruction: Answer Question ONE and any other TWO
Question One
a. What do you understand by the term program/script as used in programming; hence discuss
its four parts. [5 marks]
b. In order to write programs that implement mathematical algorithms, we need to be able to
make choices and repeat operations. These tasks are achieved using the “if”, “for” and
“while” commands. Explain the use of each while giving the syntax. [6 marks]
c. Explain each line of the following code. [9 marks]
1. x <- 7
2. n <- 5
3. result <- 1
4. cat("Powers of", x, "\n")
5. cat("exponent result\n\n")
6. for (i in 1:n) {
7. result <- result * x
8. cat(format(i, width = 8),format(result, width = 10),"\n", sep = "")
9. }
d. The Fibonacci sequence is a famous sequence in mathematics. The first two elements are
defined as [1, 1].subsequent elements are defined as the sum of the preceding two elements.
By using the right looping command, write R-code that obtains a Fibonacci number greater
than 200. [5 marks]
e. Discuss the concept of recursive programming. [2 marks]
f. Suppose that X has a normal density truncated to (0, 1).
Find the constant c; [3 marks]
2 0.5 0 1
( )
0
x ce x
f x
otherwise
?? ? ? ?
????
Page 2 of 3
Question Two
a. Briefly discuss a function, give the syntax and explain the meaning of every argument
including how to call a function. [5 marks]
b. Consider a quadratic function 2 a1x ? a2x ? a0. By using the concept of functions and the
“if” commands, write R code that calculates the roots of the quadratic equation. [10 marks]
c. Discuss good programming habits. [5 marks]
Question Three
a. Consider the standard formula for the sample variance of a sample 1 2 3 1 , , ,..., , n n x x x x x ? ,
2 2
1
1
( )
1
n
i
i
S X X
n ?
? ?
? ? Where X is the sample mean,
Show that 2 2 2 2
1 1
( 1) ( )
n n
i i
i i
n S X X X nX
? ?
? ?? ? ?? ? [4 marks]
b. Suppose that CIC insurance company requests you to do data analysis for them. If you were
given a file named “claim.csv”; as a statistical analyst in charge, give the R-code that you
would use to get the data into R-editor stored in drive G, determine its mean, variance,
standard deviation and the histogram. [5 marks]
c. Explain the concept of Pseudo-random number generators hence generate 6 pseudorandom
numbers based on the multiplicative congruential generator;
Take m=7, b=3 and 0 X ? 2 . [11 marks]
Question Four
a. Write a program that calculates the value of n! [6 marks]
b. Consider the following R code. Explain the meaning of each line. [10 marks]
1 x <- 3
2 for (i in 1:3) {
3 show(x)
4 if (x %% 2 == 0) {
5 x <- x/2
6 } else {
7 x <- 3*x + 1
8 }
9 }
10 show(x)
c. Suppose traffic accidents occur at an intersection with a mean rate of 3.7 per year. Simulate
the annual number of accidents for a 10-year period assuming a Poisson process. [2 marks]
Page 3 of 3
d. Suppose the service time at a bank teller can be modelled as an exponential random variable
with a rate of 3 per minute. What is the probability of a customer being served in less than 1
minute? [2 marks]
Question Five
a. Suppose a car dealer promotes two options for the purchase of a new $20,000 car. The first
option is for the customer to pay upfront and receive a $1,000 rebate. The second option is
0% interest financing where the customer makes 20 monthly payments of $1,000 beginning
in one month’s time. [10 marks]
b. Write R-code that minimizes and plots the function 2 f (x) ?| x ?3.5 | ?(x ? 2) on the
interval [0,5] [5 marks]
c. Let x and y be 2x3 matrices. Explain the R-output for each command line when executed.
>t(y)
>crossprod(y,x)
>y%*%x
>y+x
>t(y)+x
[5 marks]






More Question Papers


Popular Exams



Return to Question Papers