Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

R Programming: Use preexisting functions in R to write a function called ourhist that produces a pro- portion histogram of a numerical vector x such

R Programming:

  1. Use preexisting functions in R to write a function called ourhist that produces a pro- portion histogram of a numerical vector x such that the number of breaks is determined by the Scott method and the histogram is overlaid with the density line. Test it on 100 randomly generated observations from the Exp(3) distribution.

  2. Without using the ifelse() function, write a function that adds 1 to all the positive entries of a vector and subtracts one from all the non-positive entries. Test it on 100 randomly generated observations from the N(0,1) distribution, and use the function from the previous problem to create a histogram of the modified sample.

  3. Write the same function as in the previous problem, only this time use the ifelse()function.

  4. The classic Fibonacci sequence is defined such that the first two numbers are 0 and 1, and each subsequent number in the sequence is the sum of the two numbers preceding it. I.e.,

    a1 = 0 a2 = 1 ak = ak1 + ak2.

    Its easy to see that the first nine numbers in the sequence are 0,1,1,2,3,5,8,13,21,.... Write a recursive function that returns the nth Fibonnacci number.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions