FIN312 (b) Given the following 5 test cases, print the results from your function using this...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
FIN312 (b) 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}") No. 1. 2. 3. 4. 5. P 1 2 2 3 4 A (-10, 20) (-6, 6) (2, -1, 6) (-3, 8, -1, 8) (2, -4, 1, 0, 6) Tutor-Marked Assignment B (20, -30) (18,-4) (-1, 3, -6) (2,2,0,9) (-2, 4, 7, 4,-2) (5 marks) Question 2 (a) Let A = (a, a,..., an) and B = (b,b,..., b) be two points in the n-dimensional space R". 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: D(A,B) = la: - b; P 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, D(A,B) = proximity (1, (1,1), (5,4)) = 7. When p = 2, we get the familiar 'Euclidean distance from Pythagoras Theorem. In this case, D (A,B) = proximity(2, (1,1), (5,4)) = 5. 5 3 2 1 A = (1, 1) D(A, B) 5 B=(5, 4) D(A, B)=7 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 D (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.) (20 marks) FIN312 (b) 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}") No. 1. 2. 3. 4. 5. P 1 2 2 3 4 A (-10, 20) (-6, 6) (2, -1, 6) (-3, 8, -1, 8) (2, -4, 1, 0, 6) Tutor-Marked Assignment B (20, -30) (18,-4) (-1, 3, -6) (2,2,0,9) (-2, 4, 7, 4,-2) (5 marks) Question 2 (a) Let A = (a, a,..., an) and B = (b,b,..., b) be two points in the n-dimensional space R". 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: D(A,B) = la: - b; P 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, D(A,B) = proximity (1, (1,1), (5,4)) = 7. When p = 2, we get the familiar 'Euclidean distance from Pythagoras Theorem. In this case, D (A,B) = proximity(2, (1,1), (5,4)) = 5. 5 3 2 1 A = (1, 1) D(A, B) 5 B=(5, 4) D(A, B)=7 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 D (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.) (20 marks)
Expert Answer:
Related Book For
Posted Date:
Students also viewed these programming questions
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
Q1. You have identified a market opportunity for home media players that would cater for older members of the population. Many older people have difficulty in understanding the operating principles...
-
The following sample data have been collected from two independent samples from two populations. Test the claim that the second population median will exceed the median of the first population. a....
-
Data for Kicked-Back Tennis Shop are presented in P5-4B. In P5-4B At the beginning of the current tennis season, on April 1, 2012, the general ledger of Kicked-Back Tennis Shop showed Cash $4,000;...
-
A college chemistry instructor thinks the use of embedded tutors (tutors who work with students during regular class meeting times) will improve the success rate in introductory chemistry courses....
-
To prevent weeds from growing in a clean earthen-lined canal, it is recommended that the velocity be no less than \(2.5 \mathrm{ft} / \mathrm{s}\). For the symmetrical canal shown in Fig. P10.66,...
-
1. Data on the amount of the customers' shopping by using an account card and whether they decided to upgrade their account from silver status to platinum status after receiving the upgrade offer is...
-
(d) Write a PHP script to find the first non-repeated character in a given string. Example #1 Sample Input: apple Sample Output: a Example #2 Sample Input: abcab Sample Output: c Example #3 Sample...
-
Setia Nyawa Company has three products Product C, Product G and Product K. income statements of the three product lines for the latest month are given below: Product Sales Variable costs Contribution...
-
One of the most essential things you can do as a speaker is to establish your credibility. In other words, it is important what makes you "qualified" to be giving your speech. Please watch this...
-
Superior Company provided the following data for the year ended December 31 (all raw materials are used in production as direct materials): Selling expenses Purchases of raw materials Direct labor...
-
Alice visited her local police station in response to Detective Barker's request that Alice meets with him at her convenience. The Detective wanted to discuss a series of burglaries that had occurred...
-
Riddle Ltd (Riddle) operates a gold mine in Western Australia. It has four members who are Harold (who holds 30% of the shares), Gary (who holds 30% of the shares), Marie (who holds 30% of the...
-
QUESTION TWO (20 MARKS) The data below gives the concentration of copper in tissues of a given plant: (a) (b) Leave 35 42 60 22 39 75 52 78 56 36 17 69 25 32 48 5 46 3 S Roots 40 51 71 29 49 89 62 77...
-
On January 1, 2017, the Z Corporation acquired a 20% interest in D Company by purchasing 4,800 shares of its 24,000 outstanding shares of common stock. The acquisition price was $32 per share. On the...
-
Prairie Outfitters, Inc., a retailer, accepts paymnent through credit cards. During August, credit card sales amounted to $12,000. The processor charges a 3% fee. Assuming that the credit card...
-
Use the right triangle shown below. Then, using the given information, solve the triangle. a = 2, c = 5; find b, A, and B a
-
A Major League baseball diamond is actually a square 90 feet on a side. The pitching rubber is located 60.5 feet from home plate on a line joining home plate and second base. (a) How far is it from...
-
The graph of a quadratic function is called a(n) __________.
-
Why do organizations conduct marketing research?
-
Discuss an ethical issue in marketing research that relates to each of the following stakeholders: (1) client, (2) the supplier, and (3) the respondent.
-
What are some of the reasons for the increased need for marketing research?
Study smarter with the SolutionInn App