Homework 1

Published

January 23, 2024

Due 6/14/24 @ 11:59 PM

You must comment all your code to receive credit.

Submit the *.html file to canvas.

For all problems, you must use at least one for or while loop.

Problem 1

Using the following code:

x <- matrix(rnorm(1500), nrow = 10)

Write the code to produce the output if you use the rowMeans() on the R object x.

Problem 2

Using the following code:

y <- matrix(sample(1:400, 100, replace = T), nrow = 10)

Find the median value for each column of the matrix y.

Problem 3

Write the code that will generate the first 1000 numbers of the Fibonacci Sequence.

Problem 4

Write a function for the following equation:

\[ f(x, y, z) =\left\{\begin{array}{cc} x^2+\sqrt y & z = 0 \\ x^2+2x+3+ \log(y) & z = 1 \end{array}\right. \]

Include any error messages if necessary.

Problem 5

Create a function that will give you the first x Fibonacci numbers. You must use a for loop.