Question: Please help with this: Answer the following question by writing python codes: 1. Randomly place 20 points within a unit square. 2. Find the two

Please help with this:

Answer the following question by writing python codes:

1. Randomly place 20 points within a unit square.

2. Find the two points that are closest to each other and compute their distance. Find the two points that are farthest from each other and compute their distance. Code these calculations from scratch; do not use a packaged function.

3. Repeat (1) to (2) r=100 times. Collect the closest and farthest pairs. Plot all pairs on a scatter plot, with blue points for closest pairs and red points for farthest pairs. Report the average closest- and farthest-pair distances on the scatter plot.

For number 1, I have come up with followings:

import numpy as np n = 20 y = np.random.uniform(0,1,n) x = np.random.uniform(0,1,n)

Please help on number 2 & 3! Thank you!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!