Skip to main content

All Questions

Tagged with
0 votes
1 answer
40 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
83 views

Analogue of numpy indices for lua multidimensional array

In numpy any ndarray can be accessed by specifying a tuple of integers. So if we build an array with arbitrary dimensions and populate it using a formula that is based on the indices of an element, ...
Ted Black's user avatar
  • 180
-4 votes
0 answers
47 views

How does np.s_[86:87, 86:87] work? What do the parameters mean?

I have code where I take latitude, longitude, and height from a landing site on the moon. I get all my data but after I slice it all my data is gone. I don't really know how to use the parameters for ...
rakhee goel's user avatar
0 votes
0 answers
19 views

Abstracting and generalizing spectogram function that accept sample_rate from the wavelet function and arbitrary signal

I'm trying to understand wavelet transform from scratch, that's why I don't want use any libraries/packages except numpy and matplotlib. Import import numpy as np import matplotlib.pyplot as plt ...
Muhammad Ikhwan Perwira's user avatar
0 votes
1 answer
53 views

Self differencing function for 2D numpy array (correlation?)

I have a 2D array mat of shape ~ (3000, 5). Now I want to subtract every column from the others and ignore the self subtraction. This is what I have right now and what works. I just want a more ...
ZohanPolis's user avatar
0 votes
1 answer
56 views

Efficiently recalculating dependent values in real-time data streams using NumPy in Python

I'm currently working on a real-time data processing system for financial securities, where I need to perform calculations as soon as new data comes in. Each financial security has multiple data ...
Harry Spratt's user avatar
0 votes
3 answers
73 views

Numpy Unique - how to make array with counts?

So, basically, I have a txt file like this: I read it and this is my code: name_k, let_k = np.loadtxt(path + 'known_mass_period.txt', skiprows = 1, unpack = True, usecols = (0,1), dtype = str) m_k, ...
Alessandro Ruggieri's user avatar
1 vote
2 answers
67 views

create polars array series sharing data with numpy array, with unpredictable offsets

I'm working with "records" that are represented by ~1,000 sample arrays. I have millions of these records, so they take up a fairly significant amount of memory, often exceeding what is ...
gggg's user avatar
  • 2,376
1 vote
2 answers
73 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
1 vote
2 answers
90 views

Create new matrix with sum of all n*n submatrixes sum without using loops

I have a starting array (a) and I'm using loops to create a new matrix (b) where every element represents the sum of every unique subarray n*n (0+1+5+6=12, 1+2+6+7=16, ...). Can I achieve the same ...
yan's user avatar
  • 13
0 votes
1 answer
68 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
0 votes
2 answers
48 views

Performance degradation of matrix multiplication involving integer-array-indexed arrays in numpy

I'm working on a project where I have to perform some row and/or column permutaion before (broadcasted) matrix multiplication. While the implementation is straightforward with numpy, I noticed that ...
jinzx10's user avatar
  • 33
0 votes
1 answer
59 views

In NumPy arrays, is there a syntax to set a value in the last dimension based on the first dimension?

I've Googled and asked ChatGPT and looked through NumPy docs and can't find any way to do this, so thought I'd ask here. Suppose I have a 4-dimensional array -- in this case, of shape (3, 2, 2, 2): a =...
crazygringo's user avatar
  • 1,365
0 votes
1 answer
76 views

Numpy: Move values according to another array

I've tried searching for it for a few hours now, but couldn't find a solution, so I hope someome can help me. Assuming I have two numpy arrays that look like this: data_arr = [[0 1 2] [1 0 ...
killer's user avatar
  • 11
1 vote
2 answers
155 views

Error in cv2.rectangle after flipping image with slicing: 'Layout of the output array img is incompatible with cv::Mat'

I am using OpenCV to draw a rectangle on a binary image. My goal is to draw the rectangle on both the original image and its vertically flipped version. However, I encounter an issue when flipping the ...
meysam's user avatar
  • 51

15 30 50 per page
1
2 3 4 5
1329