Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 1 (10 marks) An affine function g from the plane to the plane is defined by 6 numbers a, . .., f and has
Question 1 (10 marks) An affine function g from the plane to the plane is defined by 6 numbers a, . .., f and has the form: g(r, y) = (ar + by + e, cx + dy + f). The provided Q1. RData file specifies 4 different affine functions through vectors, a, . . ., f, each of which has 4 entries. Additionally there is a vector of probabilities, p, with 4 entries that gives the discrete probability distribution 0.02, 0.80, 0.09, 0.09 on the integers 1, 2, 3, 4. Write a function in R. with argument n = 1, 2, . . . that (a) sets up a vector of n x-values and another of n y-values all initially 0. (b) sets up a random vector i having n values 1, 2, 3, 4 chosen independently with probabilities p (Hint: the sample command may be helpful.) (c) successively computes x[j], y[j], j = 1, 2, . .. ,n as the affine transformation of x[j -1], ylj- 1] using the values a[k], . . ., f[k] where k = i[j] (so that (x[j], y[j]) is a random pick, using probabilities p, from the four possible transforms of (x[j - 1], ylj - 1]) ). (d) plots the n points (r1, y1), . .. , (In, yn), using the options cex=0. 2 and col="green". Run the function with n = 10, 000. Display the output.Values a num [1:4] 0 0. 85 0.2 -0.15 num [1:4] 0 0.04 -0.26 0.28 num [1:4] 0 -0. 04 0.23 0.26 num [1:4] 0 0. 85 0.22 0.24 num [1:4] 0 0 0 0 num [1:4] 0 1.6 1.6 0.44 num [1:4] 0. 02 0.8 0. 09 0.09
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started