Question

In: Computer Science

Using Python: Normalize a 5x5 random matrix hints: use numpy create a random matrix X apply...

Using Python:

Normalize a 5x5 random matrix

hints:

  • use numpy
  • create a random matrix X
  • apply Normalization: (X - Mean) / Deviation

Solutions

Expert Solution

Code

import numpy as np #import numpy
matrix = np.random.random((5,5)) #matrix of 5x5
minimum=matrix.min()
maximum=matrix.max()
print("Before Normalization: ")
print(matrix)
print()
matrix=(matrix-minimum)/(maximum-minimum) #normalization
print("After Normalization: ")
print(matrix)

Terminal Work

.


Related Solutions

Using Python : Create a 4×5 4 × 5 array ? X with random value. Print...
Using Python : Create a 4×5 4 × 5 array ? X with random value. Print out ? X , as well as the largest value of each column.
wrote a code in mathlab to find the inverse of a matrix (5x5), USING CoFACTOR method....
wrote a code in mathlab to find the inverse of a matrix (5x5), USING CoFACTOR method. use numbers 1-15 as variables
Use NumPy to create a My_Array; a 3 by 3 array where in,m = n +...
Use NumPy to create a My_Array; a 3 by 3 array where in,m = n + m. (e.g., the first row first column would be 0+0=0, second row first column would be 1+0=1, etc). complete the following using NumPy: Compute the mean, median, range, and variance of this array Find the inverse or pseudo inverse Find the determinant Perform the following operations on My_Array Create My_1D_Array by reshaping My_Array into a 1-dimensional array Create a new array that is the...
#Python program using loop instead of numpy or pandas. Write a function to enter n student...
#Python program using loop instead of numpy or pandas. Write a function to enter n student scores from 0 to 100 to represent student score, Count how many A (100 - 90), B(89-80), C(79-70), D(69-60), F(<60) We will use numpy array OR pandas later for this problem, for now use loop Invoke the function with 10 student scores, show the result as follow: Test Enter 10 scores Enter a student score: 99 Enter a student score: 88 Enter a student...
Create a random matrix of size 10x10, of integers between 1 and 1000, and use nested...
Create a random matrix of size 10x10, of integers between 1 and 1000, and use nested for loops over the elements of the matrix to find the number of prime elements , as well as the sum of the prime elements in the matrix. You can use MATLAB's built-in function isprime to check if an element is a prime number. You should have these variable: cnt (counts the number of prime elements) sm (sum of prime elements) In the command...
Using Python, Establish random centroids according to the k , and create your own algorithm to...
Using Python, Establish random centroids according to the k , and create your own algorithm to make clusters: create a functions kmeans() that accepts a dataframe and k as parameters, and returns the clusters created.
2. Using matrices, create an algorithm that takes a matrix of dimension N x N and...
2. Using matrices, create an algorithm that takes a matrix of dimension N x N and feed it in a spiral shape with the sequential number from 1 to N^2. Then do an algorithm in PSEint
In python find matrix M I have the matrix X X=[5.8 3.0 3.7 1.9] and need...
In python find matrix M I have the matrix X X=[5.8 3.0 3.7 1.9] and need to create a matrix M that is 4x150 that has the the values of matrix X inside it for every row M= 5.8 3.0 3.7 1.9 5.8 3.0 3.7 1.9 5.8 3.0 3.7 1.9 5.8 3.0 3.7 1.9 5.8 3.0 3.7 ect 5.8 ect ect 5.8 ect 5.8
Using Python coding language (with or without Pandas and/or NumPy), 1. Can you define function sleep...
Using Python coding language (with or without Pandas and/or NumPy), 1. Can you define function sleep to tell whether the participant are of the ages through 18 to 60 and sleep less than 6 hours per day? 2. Develop codes to check whether the sleep function you defined can make correct judgement. Make sure you write comments or create informative vairable name so that I can understand how you check the sleep function. (Hints: You can create toy data/dataframe to...
I'm working on a scatter-plot program in Python using Pandas, Matplotlib, Numpy, etc. I'm pulling data...
I'm working on a scatter-plot program in Python using Pandas, Matplotlib, Numpy, etc. I'm pulling data from a CSV file, which has no names, just numbers. All I did was to read a .csv file. How do I pull data from three columns which contains about 1500 rows with just numbers and make a scatter plot with two in the x-axis and the third in the y-axis?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT