Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Proofs And Fundamentals A First Course In Abstract Mathematics

Authors: Ethan D Bloch

2nd Edition

1441971270, 9781441971272

More Books

Students also viewed these Mathematics questions

Question

What is Larmors formula? Explain with a suitable example.

Answered: 1 week ago

Question

2. How do I perform this role?

Answered: 1 week ago