All Questions
Tagged with numpy vectorization
32 questions
4
votes
1
answer
195
views
Finding specific promotions from two columns [closed]
I'm trying to build a function that identifies those who are promoted into a list of jobcodes, or are promoted within that list of jobcodes.
Initially I was using ...
1
vote
1
answer
711
views
Exponentially-weighted moving mean and standard deviation of an irregularly-spaced weighted time series
The following numpy/python function computes exponentially-weighted moving mean and standard deviation of an irregularly-spaced weighted time series. I want to make it faster by getting rid of the ...
3
votes
1
answer
108
views
Vectorizing a working custom similarity function further using numpy
I am new to python, and even more new to vectorization. I have attempted to vectorize a custom similarity function that should return a matrix of pairwise similarities between each row in an input ...
2
votes
1
answer
190
views
Computing the angle between two vectors (vectorized) for small angles and with few copies
I am implementing a function that computes the angle between two vectors when given two n-dimensional arrays and an axis along which to operate. I want to do this with as few copies as possible, and ...
5
votes
2
answers
219
views
Snake game from the viewpoint of the snake
I wrote a little game of Snake where you can see the field in which the snake moves fixed and you can also see the "viewpoint" of the snake, which is basically calculating the positions of ...
5
votes
1
answer
237
views
Implement vectorization instead of nested loops on dataframe
I have a dataset ('sample_data.csv') of the form below:
...
4
votes
1
answer
96
views
Can this numpy code be vectorized?
I've written the following function to produce n realizations of a CIR process for a given set of parameters:
...
1
vote
0
answers
206
views
condensed nearest centroid classifier in numpy
This is my attempt to write a numpy-optimized version of a nearest centroid classifier to classify some images from the MNIST data set of handwritten digits. I am ...
4
votes
2
answers
1k
views
PyTorch Vectorized Implementation for Thresholding and Computing Jaccard Index
I have been trying to optimize a code snippet which finds the optimal threshold value in a n_patch * 256 * 256 probability map to get the highest Jaccard index ...
1
vote
1
answer
506
views
Vectorized N-Dimensional Random Walk in Cartesian Coordinates
I have written a random-walk routine that I hope to build upon in the future. Before doing so, I was hoping to get some critique.
I believe the implementation is correct. I noticed that many other ...
2
votes
1
answer
7k
views
Find first threshold crossing in numpy array
Given the following artificially generated data:
...
6
votes
2
answers
8k
views
Compute a numerical derivative
Since I could not get numpy.gradient() to compute a derivative successfully, I wrote a script to compute it manually. Running the script below will output a plot of ...
3
votes
0
answers
314
views
Merging bin-data via a bin count threshold
When performing a chi-squared test, one takes the square of the differences of the expected counts per bin and observed counts per bin, and divides these per-bin differences by the expected counts per ...
1
vote
1
answer
978
views
Normalise list of N dimensional numpy arrays
I have a list of N dimensional NumPy arrays.
num_vecs = 10
dims = 2
vecs = np.random.normal(size=(num_vecs, dims))
I want to normalize them, so the magnitude/...
6
votes
2
answers
3k
views
Remove outliers from a point cloud
This function accepts a cloud of points, and returns those points that are within delta distance of the average (mean) position.
...