Skip to main content

All Questions

Tagged with
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 ...
Gage's user avatar
  • 41
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 ...
yuri kilochek's user avatar
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 ...
dddxxx's user avatar
  • 131
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 ...
FirefoxMetzger's user avatar
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 ...
Javier Camacho's user avatar
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: ...
rfguy's user avatar
  • 51
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: ...
John Smith's user avatar
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 ...
Grayscale's user avatar
  • 127
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 ...
yiping's user avatar
  • 73
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 ...
user avatar
2 votes
1 answer
7k views

Find first threshold crossing in numpy array

Given the following artificially generated data: ...
Seanny123's user avatar
  • 1,585
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 ...
user avatar
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 ...
user avatar
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/...
Seanny123's user avatar
  • 1,585
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. ...
adrienlucca.net's user avatar

15 30 50 per page