Write a Python function that takes as input three integers MN and r and returns an MN matrix of

Write a Python function that takes as input three integers, M, N, and r, and returns an MN matrix of rank r. Create matrices of different sizes and ranks, and use numpy.linalg.matrix_rank() to verify the returned matrices have the desired rank. Why should you expect a randomly generated matrix to have the rank you prescribe? What happens if you set r > min(M, N), and why does that happen? def randrank(M, N, r): A = random.randn(M, r) B = random.randn(N, r) return A.dot(B.T) R = randrank(32, 41, 7) print(R.shape, 'n') print(LA.matrix_rank(R), 'n') (32, 41) 7 (a) Use the function in Exercise #1 to generate a 5020 random matrix of rank r = 20, and visualize it. (b) Find the SVD of the matrix in part (a) using numpy.linalg.svd(). (c) Reconstruct the MN 2D array s with the entries of along its diagonal and zeros everywhere else: S = [s100000, s200000, sN00] if M > N, or S = [s1000, s2000, sM000000] if M < N (d) Verify that U.dot(S.dot(Vt)) recovers the matrix created in part (a). (e) Repeat (a) - (d) for a randomly generated 2050 matrix of rank r = 20.

Write a Python function that takes as input three integers, M, N, and r, and returns an MN matrix of rank r. Create matrices of different sizes and ranks, and use numpy.linalg.matrix_rank() to verify the returned matrices have the desired rank. Why should you expect a randomly generated matrix to have the rank you prescribe? What happens if you set r > min(M, N), and why does that happen? def randrank(M, N, r): A = random.randn(M, r) B = random.randn(N, r) return A.dot(B.T) R = rand

Read More

Write a program that determines the total amount for a set of tickets based off the following

Write a program that determines the total amount for a set of tickets based on the following prices. Create a function that accepts the class type (as its letter) and the number of tickets of that class. The function should return the total price for that number of tickets. The main function should ask the user for the number of tickets of each type that was purchased and then call the function for each ticket type to calculate the subtotal of each type. The total price should be outputted in the main function.

Write a program that determines the total amount for a set of tickets based on the following prices. Create a function that accepts the class type (as its letter) and the number of tickets of that class. The function should return the total price for that number of tickets. The main function should ask the user for the number of tickets of each type that was purchased and then call the function for each ticket type to calculate the subtotal of each type. The total price should be outputted in th

Read More

You are working on problem set Unit 4 Task Coding Part 1 OPause medianof3 0 LanguageType

You are working on problem set: Unit 4 - Task| Coding Part 1 (Pause) median_of_3 Language/Type: Python Errors: if/else return string The following function attempts to return the median (middle) of three integer values, but it contains logic errors. In what cases does the function return an incorrect result? How can the code be fixed? Determine what is wrong with the code, and submit a corrected version that works properly. def median_of_3(n1, n2, n3): if n1 < n2: if n2 < n3: return n2 else: return n3 else: if n1 < n3: return n1 else: return n3

You are working on problem set: Unit 4 – Task| Coding Part 1 (Pause) median_of_3 Language/Type: Python Errors: if/else return string The following function attempts to return the median (middle) of three integer values, but it contains logic errors. In what cases does the function return an incorrect result? How can the code be fixed? Determine what is wrong with the code, and submit a corrected version that works properly. def median_of_3(n1, n2, n3): if n1 < n2: if n2 < n

Read More

Please design and code a Python program that will solve a problem Any problem is ok Please

Please design and code a Python program that will solve a problem (Any problem is ok). Please include arrays, Stacks and Queues, Linked Lists, Binary Trees, AVL and Red-Black Trees, and Hash Tables in the program.Please prepare a PowerPoint file that describes at a very high level (no technical) the project. The audience of this file will be non-technical people but interested to hear what kind of problems your project will solve.

Read More

Write a C program that uses scanf to read in rows and columns and declares a 2D array using those

Write a C program that uses scanf to read in rows and columns and declares a 2D array using those values. The main program also uses scanf to read in the values to store in the 2D array. Then, create a function Transpose to print both the original matrix and the transpose of the matrix. NOTE: The transpose of a matrix is an operator which flips a matrix over its diagonal, i.e., it switches the row and column indices of the matrix. This matrix: 492 715 382 After being transposed, becomes this matrix: 473 918 252 Output example:

Write a C program that uses scanf to read in rows and columns and declares a 2D array using those values. The main program also uses scanf to read in the values to store in the 2D array. Then, create a function Transpose to print both the original matrix and the transpose of the matrix. NOTE: The transpose of a matrix is an operator which flips a matrix over its diagonal, i.e., it switches the row and column indices of the matrix. This matrix: 492 715 382 After being transposed, becomes this mat

Read More

1 The Collatz sequence is generated with the following algorithm Start with an integer n If n is

The Collatz sequence is generated with the following algorithm. 1. Start with an integer n. 2. If n is even, divide by 2. 3. If n is odd, multiply by 3 and add 1. 4. Repeat this process with the new value of n, terminating when n = 1. For example, starting with n = 11, the following sequence of numbers will be generated: 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1. Write a MIPS program that prompts the user to enter the starting value n and prints the Collatz sequence. An example run is shown below: Enter starting n = 22 Bonus: Implement a recursive version of the Collatz program without using any loops.

The Collatz sequence is generated with the following algorithm. 1. Start with an integer n. 2. If n is even, divide by 2. 3. If n is odd, multiply by 3 and add 1. 4. Repeat this process with the new value of n, terminating when n = 1. For example, starting with n = 11, the following sequence of numbers will be generated: 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1. Write a MIPS program that prompts the user to enter the starting value n and prints the Collatz sequence. An example run i

Read More

Write a Python program to print the sum addition multiply subtract and division of two numbers

Write a Python program to print the sum (addition), multiply, subtract, and division of two numbers of your choice.Start your assignment by creating your program/code in a text editor of your choice. Notepad is an example of a text editor.Download Python from the following website: Download PythonLinks to an external site.Run/execute the Python program you created in a Python window (downloaded in step 2).Add the Python program you created in Step 1 to your Word document. Take screenshots of eac

Read More