matrix

How to take a whole matrix as a input in Python?

How to take a whole matrix as a input in Python? Question: I want to take a whole matrix as an input in Python and store it in a dataframe. Pandas can do it automatically with read_csv function but it requires a CSV file. I want to input/copy-paste a matrix directly at the input, without …

Total answers: 1

Generate specific covariance matrix

Generate specific Toeplitz covariance matrix Question: I want to generate a statistical sample from a multidimensional normal distribution. For this I need to generate one specific kind of covariance matrix: 1 0.99 0.98 0.97 … 0.99 1 0.99 0.98 … 0.98 0.99 1 0.99 … 0.97 0.98 0.99 1 … … … … … Is …

Total answers: 2

how can a write a 2-d array without any imports?

how can a write a 2-d array without any imports? Question: Anyone know how to write a 2d array? The result: [[0,1,0] [0,2,0] [0,3,0]] And with no imports or any library: a=[] for y in range (3): row=[] for x in range (3): row.append(0) a.append(row) I’ve come up this far. The answer should contain these …

Total answers: 2

Plot `semilogx` graph for Euclidean distances matrix

Plot `semilogx` graph for Euclidean distances matrix Question: I am struggling to make a semilogx plot for the Euclidean distances matrix. I want a single line to show the differences, but the Euclidean distances matrix lists different items. When making the plot using the distance = np.arange(0.05, 15, 0.1) ** 2, the line appears as …

Total answers: 1

Calculating sequential move order from position matrix for Connect4 puzzle

Calculating sequential move order from position matrix for Connect4 puzzle Question: I wanted to know weather we can calculate the move order for a given Connect4 board, such that if the moves are played out sequentially from an empty board, we get the current position on board. Example: I have this position matrix for the …

Total answers: 2

How to add a 4X4 matrix values into a 6×6 matrix using numpy

How to add a 4X4 matrix values into a 6×6 matrix using numpy Question: suppose i have multiple 4×4 matrices which i want to add to a final 6×6 zero matrix by adding some of the values in the designated coordination. how would i do this. I throughout of adding slices to np.zero 6×6 matrix …

Total answers: 3

Memory efficient dot product between a sparse matrix and a non-sparse numpy matrix

Memory efficient dot product between a sparse matrix and a non-sparse numpy matrix Question: I have gone through similar questions that has been asked before (for example [1] [2]). However, none of them completely relevant for my problem. I am trying to calculate a dot product between two large matrices and I have some memory …

Total answers: 3

Why doesn't Sympy's row_del() method work (example from geeksforgeeeks website)?

Why doesn't Sympy's row_del() method work (example from geeksforgeeeks website)? Question: TL;DR There is an inconsistency when using Sympy’s [Matrix].row_del() method and websites seem to be reporting its use wrongly. Note from the following link from the geeksforgeeks website for an example of deleting matrix rows using sympy: from sympy import * # use the …

Total answers: 1

findHomography producing inaccurate transformation matrix

findHomography producing inaccurate transformation matrix Question: I have the coordinates of the four corners of a table in my image frame as well as the actual dimensions of that table. What I want to do is find the transformation matrix from the table in the frame (first image) to the actual table (second image). The …

Total answers: 1