I thought I did these well, but my professor said there's an error with my number 3
Fantastic news! We've Found the answer you've been seeking!
Question:
I thought I did these well, but my professor said there's an error with my number 3 and it is because distance - r can give a negative number and then this is what would be returned by
Transcribed Image Text:
3. (15) Given a numpy array A1 which has shape (m,n) interpret the rows as points in n-dimensional Euclidean space, R". Let v be a 1 xn array, which will also be interpreted as a point in n-dimensional Euclidean space, and let r be a positive number. The hypersphere centered at v with radius r consists of all points (xo,..., n-1) such that r = (xovo) +...+(Xn-1 Vn-1), where vo, , Un-1 are the components of v. Create a function called closest_point that will take as input arrays A1, and v as described above and a positive number r, and returns the row index of A1 such that when the rows are interpreted as points in R", this row is the closest point of A1 to the the surface of the hypersphere centered at v with radius r. 4. (20) Given two numpy arrays A1 and A2 of shapes (m, n) and (m2, n) interpret the rows of the arrays as points of R. Define a function, called number_of_pairs, which will carry out the following steps. For each row of Al determine the row of A2 that is closest to it. Store the row index of the closest points in a array. Now carry out the same step but with the arrays reversed. Now return the number of pairs (a, a2) where a is a row of A1, a2 is a row of A2, the closest point of A2 to a is a2 and the closest point of Al to a2 is a. You may assume that for a given row there will only be one row in the corresponding array which is at the minimum distance. As a hint, once you have obtained arrays which give the indices of the closest points you may want to use one of these arrays as an index into the other array of indices. What is returned from this operation could be useful although a few additional operations may still be required. 3. (15) Given a numpy array A1 which has shape (m,n) interpret the rows as points in n-dimensional Euclidean space, R". Let v be a 1 xn array, which will also be interpreted as a point in n-dimensional Euclidean space, and let r be a positive number. The hypersphere centered at v with radius r consists of all points (xo,..., n-1) such that r = (xovo) +...+(Xn-1 Vn-1), where vo, , Un-1 are the components of v. Create a function called closest_point that will take as input arrays A1, and v as described above and a positive number r, and returns the row index of A1 such that when the rows are interpreted as points in R", this row is the closest point of A1 to the the surface of the hypersphere centered at v with radius r. 4. (20) Given two numpy arrays A1 and A2 of shapes (m, n) and (m2, n) interpret the rows of the arrays as points of R. Define a function, called number_of_pairs, which will carry out the following steps. For each row of Al determine the row of A2 that is closest to it. Store the row index of the closest points in a array. Now carry out the same step but with the arrays reversed. Now return the number of pairs (a, a2) where a is a row of A1, a2 is a row of A2, the closest point of A2 to a is a2 and the closest point of Al to a2 is a. You may assume that for a given row there will only be one row in the corresponding array which is at the minimum distance. As a hint, once you have obtained arrays which give the indices of the closest points you may want to use one of these arrays as an index into the other array of indices. What is returned from this operation could be useful although a few additional operations may still be required.
Expert Answer:
Related Book For
International Marketing And Export Management
ISBN: 9781292016924
8th Edition
Authors: Gerald Albaum , Alexander Josiassen , Edwin Duerr
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...
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
ZA Berhad is an investment holding company located in Malaysia. Property development, building, property investment, and management services are the primary activities of the corporation and its...
-
For the machine element shown, locate the y coordinate of the center of gravity. r 40 mm 60 mm 50 mmo 10 mm 10 mm 50 mm r-30 mm 60 mm 10 mm
-
A box contains 24 different colored chips that are identical in size. Six are black, 4 are red, 5 are white, and 9 are yellow. If five chips are randomly chosen, without replacement, what is the...
-
For the adiabatic flash operation shown in Figure 10.34, calculate the following: (a) Change in availability function \(\left(T_{0}=100^{\circ} \mathrm{F} ight)\) (b) (b) Lost work (c) Thermodynamic...
-
On January 1, 2005, the Klinefelter Company purchased a building for $520,000. The building had an estimated life of 20 years and an estimated residual value of $20,000. The company has been...
-
You are a helping professional working with a 15 year old female name Rosa. Rosa is Hispanic and lives with her mother, father, and two younger brothers. Rosa is bright, high-achieving, and friendly....
-
In the beginning of 2012 most EU countries signed a fiscal compact. In practice for most of them this meant that they had to embark on a policy of fiscal consolidation (meaning a decrease in budget...
-
Which nations have a nonconvertible currency?
-
Define signaling content, and explain how it affects dividend policy.
-
Define the clientele effect, and explain how it affects dividend policy.
-
What adjustments might be made due to exchange rate risk and political risk to the domestic cost of capital for a foreign investment?
-
What have been the results of empirical tests of the dividend theories?
-
A rigid tank initially contains air at 60 bar. A valve is opened and the pressure in the tank falls rapidly to 35 bar. To calculate the air temperature at the final state, it is convenient to choose...
-
Fred Farmer needs to prepare a balance sheet for his bank. He spent the day getting the following information. Fred needs your help to build a balance sheet and evaluate it. The information was...
-
In the decade of the 2010s, the plans and operations of Avon Inc. in marketing, research, and manufacturing throughout Asia are still being affected by actions taken after a 1998 meeting. The US...
-
In August 2010, Britains GlaxoSmithKline PLC (GSK) was facing the possibility that its highly profitable diabetes drug Avandia would have to be withdrawn from the US market. Sales of Avandia had...
-
Export motives may be classified as internal or external, and reactive or proactive. What is meant by these terms with respect to export marketing? Give examples of each of the combinations of export...
-
With reference to Exercise 10.55, find a large sample 95% confidence interval for the true difference of probabilities. Data From Exercise 10.55 10.55 As a check on the quality of eye glasses...
-
As a check on the quality of eye glasses purchased over the internet, glasses were individually ordered from several different online vendors. Among the 92 lenses with antireflection coating, 61...
-
Two bonding agents, \(A\) and \(B\), are available for making a laminated beam. Of 50 beams made with Agent \(A, 11\) failed a stress test, whereas 19 of the 50 beams made with Agent \(B\) failed. At...
Study smarter with the SolutionInn App