Answered step by step
Verified Expert Solution
Question
1 Approved Answer
a) Let A=(a1,a2,,an) and B=(b1,b2,,bn) be two points in the n-dimensional space Rn. We can think of each point as a tuple of n real
a) Let A=(a1,a2,,an) and B=(b1,b2,,bn) be two points in the n-dimensional space Rn. We can think of each point as a tuple of n real numbers. Define the promixity- p metric between A and B using the formula: Dp(A,B)=(i=1naibip)p1 where the symbol x represents the absolute value of x. The proximity- p metric is a generalized way to measure 'distance' between A and B. Example: Suppose A=(1,1) and B=(5,4) in the 2-dimensional plane. - When p=1, we get the distance to travel along the lines of a square grid. In this case, D1(A,B)= proximity (1,(1,1),(5,4))=7. - When p=2, we get the familiar 'Euclidean distance' from Pythagoras Theorem. In this case, D2(A,B)= proximity (2,(1,1),(5,4))=5. Task: Implement the function proximity (p,A,B) that takes in an integer p, point A and point B (each represented as a tuple of n real numbers). The function should compute and return the value of Dp(A,B) using the given formula. (Note: the value of dimension n is implicit in the lengths of A and B so there is no need to pass it in as a separate argument.) Given the following 5 test cases, print the results from your function using this code: for p,A,B in cases: print(f'Result: {proximity(p,A,B):.3})
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