support@w4writers.com +44 7743 307695
Jun 11, 2024

Assignment Task

STA 3100 Homework

  1. Your cell phone bill varies from month to month. Suppose your year has the following monthly amounts:

     
    46 33 39 37 46 30 48 32 49 35 30 48

Explore the function scan() and use it to read the data. How much did you spend this year on the cell phone? What is the smallest amount you spent in a month? What is the largest? How many months was the amount greater than 40? What percentage was this? Answer all questions using R.

  1. Create a vector of four 2s, then three 3s, then two 5s using the rep() function once. Next, create a vector where each of (1, 3, 5, 7, 9) is replaced by two repeats of itself using the rep() and seq() functions, first with the argument each, then with the argument times.

  2. For a nonnegative integer k, k! can be computed using the command factorial(k). Print out the vector (1! 2! 3! 4! 5!) using the function factorial() once. Do this again using the function cumprod().

  3. Let x = (1!, 2!, 3!, 4!, 5!) from Problem 3. Compute the sample mean and standard deviation of x using only the sum() and length() functions. Verify your results using the built-in mean and standard deviation functions.

  4. Compute log xi (natural logarithm) and log3 xi for xi, i = 1, . . . , 5, where x = (1!, 2!, 3!, 4!, 5!). Also, verify the equality log (∏5i = 1 xi) = Σ5i=1 log xi.

  5. Compute the geometric and harmonic means of x = (1!, 2!, 3!, 4!, 5!), where the sample mean is the arithmetic mean of x. Verify your results using the functions geometric.mean() and harmonic.mean() in the package psych. Is there an equality/inequality relating the three means?

  6. Assign the vector (2, 8, 3, 7, 4, 1, 9) to an object. Using one single command, find the elements of the vector that are even or greater than 7, multiply those elements by −1, and use them to replace the original elements.

Recent Post

Order this Assignment now

Total: GBP

fables template