Question: Write a function to generate customized clusters. ( 1 5 % ) - There are two clusters, both contain ( n )

Write a function to generate customized clusters. (15\%)
- There are two clusters, both contain \( n \) samples.
- One cluster is the frame of a square with size \(=2 r \).
- Another cluster is the frame of a rhombus with size \(=\sqrt{2} r \).
Hint: In generating a square, you can obtain 2 random numbers, in which the first random number determines one out of the four sides, while the second random number determines the location of the point on the side.
This problem is about clusters.
Note: In application, you can add some random noise to make the cluster thicker.
Code:
```
# Problem 5
import random
def problem_5(n=100, r=1, output="q5.jpg"):
# write your logic here
random.seed(4320) # for reproducibility
plt.savefig(output) # do not show the plt
```
Execution:
> problem_5(n=200, r=5)
q5.jpg:
Write a function to generate customized clusters.

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 Programming Questions!