Question: Need a function named minkowskiDistance in R that takes two vectors v and w as arguments and returns |1 1 | 3 + |2 2

Need a function named minkowskiDistance in R that takes two vectors v and w as arguments and returns |1 1 | 3 + |2 2 | 3 + + | | 3 3 , where k is the length of v and w. You are not allowed to use built-in functions for computation. You should use your absoluteValue and cubeRoot function to compute the absolute value and cube root. You should firstly check whether v and w are numeric vectors and their lengths are equal. Otherwise, print an appropriate error message and stop execution of the function. Then, using a loop, compute and return their distance. For instance, minkowskiDistance(1:3,4:6) should return 4.326749, minkowskiDistance(c(4,9,6), c(5,7,6)) should return 2.080084.

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!