You are on page 1of 6

FAKULTI SAINS

PENILAIAN 1
Assessment 1
Semester Pertama Sesi 2022/2023
(First Semester of 2022/2023)

KURSUS (COURSE) : STATISTIK BERKOMPUTASI


(COMPUTATIONAL STATISTICS)

KOD (CODE) : MTH3409

PROGRAM (PROGRAMME) : BACELOR SAINS STATISTIK DENGAN KEPUJIAN

TARIKH (DATE) : 15 NOVEMBER 2022 MASA (TIME) : 10.15 – 11.15 PAGI (AM)

TEMPAT (VENUE) : DEWAN KULIAH 1

JANGKAMASA (DURATION) : 1 JAM (1 HOURS)

ARAHAN KEPADA CALON (INSTRUCTIONS FOR CANDIDATE):

1. Jawab SEMUA soalan.


Answer ALL the questions.

* This is an open book evaluation. You may access notes and textbook. However, direct or
indirect interaction with other human beings are prohibited with regards to answering the
questions. Suspicions of foul play (cheating) will result in extreme marks reduction (you
will get 0. No negotiation).

SLIP KEHADIRAN (ATTENDANCE SLIP)

Nama (Name) :

No. Matrik (Matric No.) : Program (Programme) :

No. Meja (Desk No.) : Tandatangan (Signature) :

Kertas soalan ini mengandungi 6 halaman bercetak termasuk helaian pertama.

(This paper consists of 6 printed pages including the first sheet.)

Hak Cipta Terpelihara UPM


All Rights Reserved UPM
1. Given that two numeric vectors as follows:

X = {22.5, 31.9, 21.3, 37.2, 40.0, 37.6, 32.5, 29.9, 27.5, 38.3}
Y = {48.2, 48.2, 44.6, 55.6, 50.1, 53.3, 53.1, 49.4, 52.5, 51.2}

Provide the R coding to execute the following:


a) Create vectors X and Y in R.
[4 marks]

b) Compute the cubic root of each element in X.


[2 marks]

c) Divide elements of Y by elements of X pairwise. Hence compute the natural logarithm


(log) of each resulting element.
[2 marks]

d) Compute the mean and standard deviation for both vectors X and Y.
[4 marks]

2
e) Create a 2 × 10 matrix where Y is at the first column and X is at the second column.
Name the matrix as matrix1.
[2 marks]

f) Sort the second column of matrix1 in ascending order. Next, transpose matrix1 and
multiply it by 10.
[4 marks]

3
2. Consider the following vector variables that have been defined in R:

Month<-factor(2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6)
Ozone<-c(1, 19, 7, 89, 49, 14, 20, 7, 36, 79, 39, NA, 66, NA, NA, 78, 82, 21, NA, 84)
Wind<-c(10.3, 12.6, 6.9, 8.6, 9.7, 6.9, 6.3, 7.4, 10.3, 6.3, 14.9, 13.8, 6.3, 10.3, NA, 6.9,
10.9, 8.0, 10.9, 8.6)
Temp<-c(90, 61, 77, 79, 82, 92, 94, 82, 81, 76, 74, 69, 76, 81, 88, 84, 75, 84, NA, 86)

Write the R coding to execute the following:


a) Create a data frame consisting of all vectors above and name it metdata.
[2 marks]

b) Remove all rows with NAs in metdata and name the data frame metdata1.
[2 marks]

c) Assign the Month variable in metdata1 with the following factor labels:
[4 marks]
Month Lable of Month
2 Feb
3 Mar
4 Apr
5 May
6 June

4
d) Compute the median and range of all numeric variables in metdata1 by Month.
[4 marks]

e) Based on metdata1, construct a combination of plots given below.


[10 marks]

5
3. Write the R coding using for loop that prints out the number from 10 to 50 with increment
1, but it skips any number which is the factor of 7.
[5 marks]

You might also like