Question: use R as coding language and answer asap D Question 5 4 pts For p > 1, the p-norm (also called the LP-norm) for a

use R as coding language and answer asap

use R as coding language and answer asap D Question 5 4

D Question 5 4 pts For p > 1, the p-norm (also called the LP-norm) for a vector of numeric values x = (X1, 12, . . ., In ) is defined as 11 20 /1p = (121 10 + 12:21 + .. . + 120m / 1 ) 1/P where Ti | is the absolute value of Ti. In the special case of p - oo, the Lo-norm is the limit of | |x| | as p - co, which is equivalently defined as 1 all - max {|x1|, |x2, . ... (x]} Write a function called my_norm() that computes the p-norm given the following arguments: . x: A numeric vector of values, no default . p: A single number for the value of p, with a default of 2 Additionally, throw an error of your choosing for invalid inputs of p. Note: You may assume the input x will be a numeric vector and that p will be a length-1 numeric vector. You may also assume that there will not be missing values in either input, and therefore do not have to account for them To check your function: > my norm ( - 2 :3 ) [1] 4. 358899 > my_norm ( - 2 :3, p = 2) [1] 4. 358899 > my_norm ( -2:3, p = 1) [1] 9 > my_norm ( -2:3, p = 4. 4) [1] 3.212743 > my_norm ( -2:3, p = Inf) [1] 3 > my_norm ( - 2:3, p = 0) Error in my norm (-2:3, p = 0) : p must be at least 1 Edit View Insert Format Tools Table 12pt ~ Paragraph B I U A Q V T R V Q V E V BY BV * 99+ 1 0 2 W R

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 Mathematics Questions!