In this question, we will look at a location-scale transformation based on a user-defined function. (i) Write a R function g to implement the following function for the location-scale transformation: x-a g(x) = b Your function accepts a vector x and returns the transformed vector and has three arguments: the input value x, location parameter a, and scale parameter b. (ii) To transform x to the interval [0, 1], we can use the following arguments in the g function: g(x, a = min(x), b = max(x) min(x)) Use the function g to transform the following sample x to the interval [0,1]: set.seed(10);x<-rnorm (100,-1,3). To check the result, plot two histograms for the original and transformed samples with relevant titles. (iii) In Statistics, we frequently standardize a variable in the following way: where 8 for 1,2,..., 100, and s are the sample mean and the sample standard deviation of x,'s.¹ Use the function g to standardize the sample 2. To check the result, plot a histogram for the standardized samples with a vertical reference line at 0 and a relevant title.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter13: Structures
Section: Chapter Questions
Problem 4PP
icon
Related questions
Question

Using R language

In this question, we will look at a location-scale transformation based on a user-defined function.
(i) Write a R function g to implement the following function for the location-scale transformation:
x-a
g(x) =
b
Your function accepts a vector x and returns the transformed vector and has three arguments: the
input value x, location parameter a, and scale parameter b.
(ii) To transform x to the interval [0, 1], we can use the following arguments in the g function:
g(x, a = min(x), b = max(x) min(x))
Use the function g to transform the following sample x to the interval [0,1]:
set.seed(10);x<-rnorm (100,-1,3).
To check the result, plot two histograms for the original and transformed samples with relevant titles.
(iii) In Statistics, we frequently standardize a variable in the following way:
where
8
for 1,2,..., 100,
and s are the sample mean and the sample standard deviation of x,'s.¹
Use the function g to standardize the sample 2. To check the result, plot a histogram for the
standardized samples with a vertical reference line at 0 and a relevant title.
Transcribed Image Text:In this question, we will look at a location-scale transformation based on a user-defined function. (i) Write a R function g to implement the following function for the location-scale transformation: x-a g(x) = b Your function accepts a vector x and returns the transformed vector and has three arguments: the input value x, location parameter a, and scale parameter b. (ii) To transform x to the interval [0, 1], we can use the following arguments in the g function: g(x, a = min(x), b = max(x) min(x)) Use the function g to transform the following sample x to the interval [0,1]: set.seed(10);x<-rnorm (100,-1,3). To check the result, plot two histograms for the original and transformed samples with relevant titles. (iii) In Statistics, we frequently standardize a variable in the following way: where 8 for 1,2,..., 100, and s are the sample mean and the sample standard deviation of x,'s.¹ Use the function g to standardize the sample 2. To check the result, plot a histogram for the standardized samples with a vertical reference line at 0 and a relevant title.
Expert Solution
steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Operations Research : Applications and Algorithms
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:
9780357392676
Author:
FREUND, Steven
Publisher:
CENGAGE L