Question: . I should be able to copy and paste the code straight into R and then execute the functions with my own data / parameters

. I should be able to copy and
paste the code straight into R and then execute the functions with my own data/parameters without
having to track down any bugs myself. A very common mistake that students make is that they make
use of global variables without realizing it, and when I copy/paste the code into my R, which doesn't
have these global variables present, it won't work. So (a) make sure you aren't utilizing global variables,
and (b) when you think you have everything written and finalized, completely close R then start R again
(this will completely wipe out any variables/data you've been working with) and copy/paste your code
and attempt to use it.
Write a function called "myrweibull" to generate n realizations from the Weibull distribution using
the probability integral transform method. The Weibull cdf is given by:
(,|)=1-e-(x);x>0,>0,>0
(This is the parameterization I want you to use. Also note that the cdf is 0 if x0.)
The function's name must be "myrweibull".
It must take the following arguments (named as such):
n-The sample size; i.e. the number of realizations to generate.
Include error checking to be sure that n is a numeric scalar and greater than or
equal to 1.
If it is not an integer, then coerce into the nearest integer less than the value
given.
No default value.
shape - This is the value of . It is named "shape" because is a shape parameter.
Include error checking to be sure that shape is a numeric scalar and greater than
No default value.
scale - This is the value of . It is named scale because is a scale parameter.
Include error checking to be sure that scale is a numeric scalar and greater than
0.
The default value is 1.
It must return the vector of n realizations from the desired Weibull distribution.
Additional details:
You may use the default R function "runif" to generate realizations from the U(0,1)
distribution, but do not use "rweibull", "qweibull", or any other built-in Weibull-related
functions.
Do not attempt to modify or set R's seed value for random number generation
Please follow all instructions carefully and then attempt
. I should be able to copy and paste the code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!