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
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