Skip to main content

All Questions

Tagged with
0 votes
1 answer
50 views

numpy.cov() Giving Incorrect Answer

I'm trying to use Python and NumPy to calculate a covariance matrix. Here is the matrix: [[0.69, 0.49], [-1.31, -1.21], [0.39, 0.99], [0.09, 0.29], [1.29, 1.09], [0.49, 0.79], [0.19, -0.31], [-...
marbledcrystals's user avatar
0 votes
1 answer
29 views

Python - How do I automate the creation of row and column headers (in line with a table's dimension)?

How do I automate the creation of row and column headers? I would like to randomly generate a matrix, and then add row and column headers aligned with the indices, i.e. R1, R2, R3… for the rows and C1,...
user23487612's user avatar
2 votes
2 answers
96 views

Apply function for lower triangle of 2-d array

I have an array: U = np.array([3, 5, 7, 9, 11]) I want to get a result like: result = np.array([ [ np.nan, np.nan, np.nan, np.nan, np.nan], [U[0] - U[1], np.nan, np....
IzaeDA's user avatar
  • 397
3 votes
1 answer
58 views

Numpy array does not correctly update in Gaussian elimination program

I am trying to write a function gaussian_elim which takes in an n x n numpy array A and an n x 1 numpy array b and performs Gaussian elimination on the augmented matrix [A|b]. It should return an n x (...
Leonidas's user avatar
  • 745
-3 votes
1 answer
48 views

Concatenate a few row vectors into a matrix

Four 1X3 row vectors, trying to concatenate them into a 4X3 martrix. Here is my code that is not working: ul = np.array([-320, 240, 1]) ur = np.array([320, 240, 1]) br = np.array([320, -240, 1]...
Nick X Tsui's user avatar
  • 2,912
0 votes
1 answer
58 views

numpy giving wrong matrix results?

I am doing some matrix calculations and I am getting some wrong values. import numpy as np np.set_printoptions(formatter={'float': lambda x: "{0:0.2f}".format(x)}) #deltaT arr1 = np.array([[...
fender's user avatar
  • 11
1 vote
2 answers
77 views

How can I set a specific value on an array (matrix) of booleans per True/False without using loops in python?

I am trying to make two random generated matrices mat1 and mat2 with random integer values between 0, 255 and check which cells are equal. and I know this much import numpy as np mat1 = np.random....
The nd's user avatar
  • 13
0 votes
1 answer
151 views

How to Generate a Random Complex Symmetric Unitary Matrix in Python?

I am trying to optimize a complex symmetric unitary matrix 𝐴 with dimensions N*N using Python. First of all, how to generate matrix 𝐴 that should satisfies the two conditions: 𝐴=𝐴^{T} (...
learning statistics 's user avatar
1 vote
1 answer
111 views

algorithm to detect pools of 0s in a matrix

I'm writing an algorithm that detects regions of contiguous empty cells that are completely surrounded (orthogonally) by filled cells and do not extend to the edge of the grid. Let's call such regions ...
chocojunkie's user avatar
0 votes
0 answers
50 views

Raising a Numpy Array to a large power [duplicate]

I am using Numpy to raise a 2 X 2 array (matrix), with positive elements, to an integer power. But if I use a high enough power, I get negative values in the result: A = np.array([[1, 1], [1, 0]]) B = ...
Radu Valasutean's user avatar
0 votes
1 answer
42 views

How to reorder rows of a numpy array according to another array [duplicate]

I have a matrix A whose rows have to be reordered or shuffled according to the sequence in array b. The actual size of a Matrix A is more than 100 rows. The suggested answer need to be scalable. A = ...
M.Patil's user avatar
  • 81
0 votes
2 answers
156 views

How to reproduce `kneighbors_graph(include_self=True)` using `KNeighborsTransformer` in sklearn?

My ultimate goal is replace some methods that use kneighbors_graph with transformers from the sklearn-ann package. All the methods in sklearn-ann are implemented as sklearn-compatible transformer ...
O.rka's user avatar
  • 30.8k
0 votes
1 answer
42 views

Update a Column of a Matrix where each MongoDB document is a Row

I'm storing matrices in MongoDB where each document is a row of values. Example of two small matrices but assume there are thousands of rows and columns: [ { matrix_id: 123, row_id: 0, values: [1, 2,...
aneroid's user avatar
  • 16.4k
0 votes
1 answer
99 views

How to fix : TypeError: 'numpy.ndarray' object is not callable

I'm currently working on implementing a Newton-Raphson algorithm to solve a statistical problem. However, I'm encountering an issue with matrix multiplication that is resulting in the following error: ...
Gabriel Ligabô's user avatar
0 votes
3 answers
80 views

How to (idiomatically) read indexed arrays from a delimited text file?

I have text files from an external source that are formatted like so: 0 0 -0.105961 0.00000 1 0 -1.06965 0.00000 1 1 -0.0187213 -0.240237 ...
rigel's user avatar
  • 489

15 30 50 per page
1
2 3 4 5
84