Problem 12. Create a random k x k symmetric matrix whose entries are integers between 0 and 10. In []: k = 5 # Write your code below Problem 13. Find the average values of X in all 3x3 sliding windows. In []: X=np.arange(25).reshape(5,5) # Write your code below Problem 14. Delete the repeated rows from X. In []: np.random.seed(0) X = np.random.randint(0,3, (10,2)) #print(X) # Write your code below Problem 15. Delete the repeated rows from X without changing the oder in which each row appears. In []: np.random.seed (0) X = np.random.randint(0,3,(10,2)) # Write your code below Problem 16. Create a r X r matrix with values 1, 2, ..., r 1 just below the diagonal. In []: r = 6 # Write your code below Problem 17. Each row of X is the coordinates of a point in 3D-space. Find the distances between these points and the center of the these points. In []: import numpy as np X=np.random.randn(10) def f(i,j): return np.sqrt(np.sum ((X[i]-X[j])**2,1)) # Write your code below
Added by Peggy B.
Close
Step 1
Step 1: Import the necessary libraries ```python import numpy as np ``` Show more…
Show all steps
Your feedback will help us improve your experience
Akash M and 93 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Write a Python function that, given a square matrix of size $n imes n$, computes the sum of the two diagonals. The matrix only contains integers. If the dimension of the square matrix is odd, make sure that you are not double-counting the value at the center of the matrix.
Akash M.
Given the matrix X whose rows represent different data points, you are asked to perform a k-means clustering on this dataset using the Euclidean distance as the distance function. Here k is chosen as 3. The Euclidean distance d between vector X and vector y both in RP is defined as d = sqrt(sum((Xi - Yi)^2)). All data in X were plotted in Figure 1. The centers of 3 clusters were initialized as C1 (6.2, 3.2) (red), C2 (6.6, 3.7) (green), and C3 (6.5, 3.0) (blue). 5.9 3.2 4.6 2.9 6.2 2.8 4.7 3.2 5.5 1.2 5.0 3.0 4.9 3.1 6.7 5.1 3.8 6.0 3.0 What is the center of the first cluster (red) after one iteration? Answer in the format of [x1, x2] and round your results to three decimal places. What is the center of the second cluster (green) after two iterations? What is the center of the third cluster (blue) when the clustering converges? How many iterations are required for the clusters to converge?
Dominador T.
Supreeta N.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD