KEMBAR78
Stat 291 Homework Guide | PDF | Matrix (Mathematics) | Array Data Structure
0% found this document useful (0 votes)
63 views4 pages

Stat 291 Homework Guide

This document provides instructions for homework assignment 1 in Stat 291 that is due on November 14, 2020 at 11:59 PM. It includes 5 questions to complete involving creating sequences using functions like seq() and rep(), performing calculations with functions like sum(), creating matrices and vectors, combining and manipulating vector and matrix elements, and performing operations on matrices like finding determinants, merging matrices, and replacing diagonal elements. The submission must be organized with question numbers and codes/outputs and be saved as the student's name and ID in an .R and .doc file. No outside help is allowed and late submissions will not be accepted.

Uploaded by

Seyar Najm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views4 pages

Stat 291 Homework Guide

This document provides instructions for homework assignment 1 in Stat 291 that is due on November 14, 2020 at 11:59 PM. It includes 5 questions to complete involving creating sequences using functions like seq() and rep(), performing calculations with functions like sum(), creating matrices and vectors, combining and manipulating vector and matrix elements, and performing operations on matrices like finding determinants, merging matrices, and replacing diagonal elements. The submission must be organized with question numbers and codes/outputs and be saved as the student's name and ID in an .R and .doc file. No outside help is allowed and late submissions will not be accepted.

Uploaded by

Seyar Najm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Stat 291 Homework - 1

Due: 14/11/2020, 11:59 P.M.

README:
1. There are 5 Questions in this assignment. Please read them carefully and perform
your best !
2. If you need to ask something about homework you can contact me anytime you
want. Please don’t get help from anyone else.
3. Late submissions will not be accepted. You must upload your homework folder to
OdtuClass before the deadline.
4. Do organize all your answers by question number and do not forget to write the
question number. Be kind to the person who is going to read your assignment and try
to send the most organized version of your assignment.
5. Make sure your submission file is named as your name and surname and consists
- yourNameSurnameID.R file includes your R codes, which is not going to be graded,
- yourNameSurnameID.doc (or .pdf), which is going to be graded, has to include your
codes, comments and outputs.

Question 1 (16 pts, 2 pts each)


Create the following sequences by using seq( ) or rep( ) functions.
Part A: {20 40 60 80 100}
Part B: {-10.0 -9.5 -9.0 -8.5 -8.0 -7.5 -7.0 -6.5 -6.0 -5.5 -5.0 -4.5 -4.0 -3.5 -3.0 -2.5 -2.0
-1.5 -1.0 -0.5 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0}
Part C: {12 9 6 3 0 -3 -6}
Part D: {0.01 0.03 0.05 0.07 0.09}
Part G: {10 20 30 40 10 20 30 40 10 20 30 40 10 20 30 40}
Part H: {1 1 1 1 1 1 1 2 2 2 2 2 2 2 3 3 3 3 3 3 3}
Part I: {10 20 20 30 40 40 50 60 60}
Part J: {1 1 2 2 3 3 4 4 1 1 2 2 3 3 4 4 1 1 2 2 3 3 4 4}

1
Question 2: (20 pts, 5 pts each)
Compute the following with sum() function;
Part A:

50
∑𝑖
𝑖=1

Part B:

20
1

𝑖=10
𝑖

Part C:

10
𝑒−0.5 ∗ 0.5𝑖

𝑖=1
𝑖!

Part D:

20
∑(−1)𝑖 ∗ 𝑖2
𝑖=1

Question 3: (14 pts, Part A and C 5 pts, Part B 4


pts)
Part A:
Create the following matrix by using all commands in ‘one code’.

Part B:

2
Create a new vector called newRow, consisting of last 4 digits of your student ID and
then append the newRow vector to the matrix you created in part A. Then, print the
new matrix.
Part C:
Multiply 4th row from the matrix in part B with -1 then make it your 5th column.

Question 4: (25 pts, 5 pts each)


Assume that there are 4 vectors;
• vec1 = {1 2 3 4 5 6 7 8 9 10}
• vec2 = {10 20 30 40 50 60}
• vec3 = {“Red”, “Blue”, “Yellow”, “Green”, “Black”}
• vec4 = {-1 -2 10 20 -3 -4 30 40 -5 50}
Part A: Combine vec1 and vec2 and assign to a new vector called ‘q4.a’, print q4.a.
Part B: Create another vector called ‘q4.b’ which consists of the elements which are
divisible by 3 in ‘q4.a’ vector.
Part C: Combine the negative elements in vec4 and all the elements in vec3 in a vector
called ‘q4.c’.
Part D: From vec1 and vec3 form a new vector ‘q4.d’ whose entries are the entries of
vec1 with odd index (first, third, fifth …) and vec3 with even index (second, forth, sixth
…);
Part E:
Count how many ’Red’s in vec3, do not use any type of loops.

Question5: (25 pts, 5 pts each)


Assume there are 4 matrices A, B, C and D. Create 4 matrices

4 −5 8 1 0 1 2 1
𝐴=[ ],𝐵 = [ ],𝐶 = [ ],𝐷 = [ ]
3 −1 1 −6 −2 4 2 0

Part A: Find 𝐴𝑡 + 𝐵 ∗ 𝐶 −1
Part B: Calculate determinant values for each matrix, store those values in a vector
and print those values in descending order.
Part C: Merge those 4 matrices and obtain the following 4x4 matrix and call it E.

3
𝐴 𝐷
[ ]
𝐵 𝐶

Part D: From Matrix E, get the third column, and find the mean of it.
Part E: Replace diagonals of matrix E with zeros.

You might also like