To match people, companies use trigonometry. Assume you have a list of people (po. p... Pm]....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
To match people, companies use trigonometry. Assume you have a list of people (po. p... Pm]. we find the two different people who have the smallest angle. The way we calculate this is to assume each person is a list (mathematically vector) of Os and 1s. We need three basic functions: inner product, magnitude, and cos¹. We assume two lists = [...]. = [30.31] of Os and 1s of the same length: inner_prod(x,y)=00+13++ mag(z) Vinner prod(1,1) For the last function (where we calculate the angle), we know that: cos(9) inner_prod(x,y) mag(z)mag(y) In class we learned that we can invert a function and the inverted function is denoted as f-¹. So we can: inner_prod(z,y) mag(z)mag(y) inner_prod(x,y) mag(x)mag(y) The math module has math.acos() for cos(). Further, Python returns & in radians. We have: #radians 180 degrees (29) Thus, to convert from radians to degree, you must multiply your answer by 10. The task is to write two functions. The match function takes a list of people p, where each person is a list of Os 1s, and returns all unique pairs with the angle in degrees. The function best match takes the result from match and retums the pair with the "best" match-the smallest degree. We can assume there's only one best match. Here is a run (with some extra output) for your perusal. cos(cos(0)) 1 people0 [[0,1,1],[1.0.0],[1.1.1]] 2 print(match(people0)) 3 print (best_match (match(people0))) gives an output 1 [[[0, 1, 1], [1, 0, 0], 90.0], [[0, 1, 1], [1, 1, 1], 35.26], 2 3 [[1, 0, 0], [1, 1, 1], 54.74]] 4 ([0, 1, 1], [1, 1, 1], 35.26) COS (24) (25) cos ( (26) (27) (28) To match people, companies use trigonometry. Assume you have a list of people (po. p... Pm]. we find the two different people who have the smallest angle. The way we calculate this is to assume each person is a list (mathematically vector) of Os and 1s. We need three basic functions: inner product, magnitude, and cos¹. We assume two lists = [...]. = [30.31] of Os and 1s of the same length: inner_prod(x,y)=00+13++ mag(z) Vinner prod(1,1) For the last function (where we calculate the angle), we know that: cos(9) inner_prod(x,y) mag(z)mag(y) In class we learned that we can invert a function and the inverted function is denoted as f-¹. So we can: inner_prod(z,y) mag(z)mag(y) inner_prod(x,y) mag(x)mag(y) The math module has math.acos() for cos(). Further, Python returns & in radians. We have: #radians 180 degrees (29) Thus, to convert from radians to degree, you must multiply your answer by 10. The task is to write two functions. The match function takes a list of people p, where each person is a list of Os 1s, and returns all unique pairs with the angle in degrees. The function best match takes the result from match and retums the pair with the "best" match-the smallest degree. We can assume there's only one best match. Here is a run (with some extra output) for your perusal. cos(cos(0)) 1 people0 [[0,1,1],[1.0.0],[1.1.1]] 2 print(match(people0)) 3 print (best_match (match(people0))) gives an output 1 [[[0, 1, 1], [1, 0, 0], 90.0], [[0, 1, 1], [1, 1, 1], 35.26], 2 3 [[1, 0, 0], [1, 1, 1], 54.74]] 4 ([0, 1, 1], [1, 1, 1], 35.26) COS (24) (25) cos ( (26) (27) (28)
Expert Answer:
Answer rating: 100% (QA)
import math def innerprodxy total0 for i in rangelenx totalxiyi return total def getMagx return in... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
4. Suppose X, Y are two discrete RV's with joint p.m.f. given by the table: XY 1 1/2 0 1/12 1/8 1/8 1/12 2 3 1 0 1/12 1/9 1/9 6 1/12 1/12 0 1/9 (a) Calculate the marginal p.m.f. of X and of Y. (b)...
-
The purpose of this project is to work more with lists, looping, file I/O, functions, and dictionaries. For this assignment, you will work with real data from the web. Background Major solar storms...
-
Assume that you have a list of 80 managers of research and development departments, who are numbered from 1 to 80. Further, you want to talk to a random sample of seven of them. Use the following...
-
According to Michel Foucault, while it is an advancement to no longer torture persons, modern forms of disciplinary punishment are sinister because they strive for _____________. a. routines. b....
-
Write the structure of the aldol condensation product of each of the aldehydes in Problem 18.10. One of these aldehydes can undergo aldoladdition, but not aldol condensation. Which one? Why?
-
1. What advantages do the mutual funds offer compared to the company stock? 2. Assume that you invest 5 percent of your salary and receive the full 5 percent match from S&S Air. What EAR do you earn...
-
Compare the export rankings of the top ten leading exports of 1999 with the rankings of the top ten leading exports in 2010 (see Table 1.3). Discuss some of the reasons why these rankings have...
-
The records of Grade A Steak Company list the following selected accounts for the quarter ended April 30, 2012: Requirements 1. Prepare a multi-step income statement. 2. M. Davidson, manager of the...
-
Six months after the triple homicide patrol officers get a call of a suspicious subject at 3:00 am. The complainant observes the suspect walking down the street and disappear behind a neighbors...
-
Today is May 15, 2000, and the current, semi-annually compounded yield curve is in Table 3.6. Compute the duration for the following securities: (a) 3-year zero coupon bond (b) 3 1/4-year coupon bond...
-
On 1 June 2021, ABC Ltd entered into a non-cancellable purchase commitment with a supplier, to purchase an inventory of cardboard boxes for US$100,000 on 1 August. The purchase is on credit which is...
-
Solve the formula 7x - 8y = -12 for y.
-
In the book the Goal, the main focus in on better utilizing the bottleneck resource(s) in different ways potentially requiring additional investment. To justify such additional investment, one needs...
-
Solve the following equations by factoring. a. 5x-6x=7x+28 b. 36x4425x Solution(s) Solution(s)
-
Discuss briefly the importance of incorporating sensitivity and scenario analysis in capital investment decision-making in the healthcare sector. Highlight how these techniques can lead to more...
-
On some apps, I curate what I post more carefully than others. Think about 2 different apps or accounts you u se... how do you curate your posts differently on them?
-
Explain false negative COVID tests and what the significance
-
Phosgene, COCl2, is a toxic gas used in the manufacture of urethane plastics. The gas dissociates at high temperature. At 400oC, the equilibrium constant Kc is 8.05 104. Find the percentage of...
-
Go to www.greatplacetowork.com and click on Worlds Best Multinationals under Best Companies. Take a look at the list for this year. What criteria are used to select the great places to work? Do you...
-
Go to the website of the Center for Creative Leadership ( www.ccl.org ). Spend some time browsing through the site to learn more about this organization, which specializes in leadership. Then click...
-
Think about your current organization or one for which you worked in the past. To what extent would a ROWE (Results-Only Work Environment) fit the organizational culture? Explain.
-
Describe the working of a Carnot cycle.
-
Define thermal efficiency of a heat engine.
-
What are the limitations of Carnot cycle?
Study smarter with the SolutionInn App