Skip to main content

All Questions

Tagged with
4 votes
2 answers
108 views

Srivastava multivariate Fox H function in MATLAB

I was trying to rewrite the Python code in MATLAB. The result is consistent. But, the MATLAB code is so slow. Any help would be appreciated. Ref python code link The MATLAB code written by me is as ...
138 Aspen's user avatar
  • 169
3 votes
5 answers
1k views

How do I speed up this simulation program

This is a program to solve a differential equation numerically using Euler method. As of now, it is very slow, and I need to run 10000 Monte Carlo simulations. The differential equation is called ...
Jonathan Wick's user avatar
4 votes
2 answers
166 views

NumPy script to convert BGR to HSL and back

This is a NumPy script that converts BGR arrays to HSL arrays and back, without using OpenCV. Input and output values are arrays of 3 dimensions with values ranging from 0 to 1, the shape of the ...
Ξένη Γήινος's user avatar
5 votes
1 answer
82 views

Generating Abelian sandpile "zeros" in python

Here is some code that generates the zero element of an Abelian sandpile model (ASM), for any given model dimensions, and then plots the result as a colormesh. Here is a wiki page explaining the ASM. ...
Eden Laika's user avatar
0 votes
1 answer
207 views

Find the first value bigger than a threshold

This function takes two inputs: A is 2D (N,5) while B is 1D (N). It tries to find the smallest ...
Sanyou's user avatar
  • 13
2 votes
1 answer
179 views

Is this the right implementation for Linear Programming (puLP) on python?

I have created a LP function to help maximize a set of features. My first time playing with this library and also conducting LP. Variables: Number of features => X Number of Categories => Y ...
Kale 's user avatar
  • 23
6 votes
1 answer
135 views

basic Hartee-Fock program to compute the total energies and some properties of a molecule

I am trying to write a basic Hartee-Fock program that computes the total energies and some properties of a molecule given as an input. The code uses Cython to statically compile the computationally ...
Hemanth Haridas's user avatar
6 votes
2 answers
482 views

Means square displacement (MSD)

I have written a code to calculate the MSD of some molecules. The code averages over multiple time origins (sliding time window) and over all the molecules. I have also made it do one extra thing: do ...
mjksho's user avatar
  • 61
8 votes
2 answers
525 views

Fourier Series of a given function

This is a very simple code that expresses a function in terms of Trigonometric Fourier Series and generates a animation based on the harmonics. I would like to know some ways to improve the ...
Lipe's user avatar
  • 83
3 votes
1 answer
161 views

Solve an option pricing PDE in Python - Part 1 [closed]

The Github repository NM-Heston solves call option prices under the Heston 2-factor model using ADI splitting schemes. I am adapting the code to price options under the 3-factor Heston-Hull-White ...
Ruan's user avatar
  • 101
3 votes
0 answers
103 views

E-car-sharing problem with charging between the bookings

I am writing code that, at some later point, will be part of an academic multi-agent simulation of the learning process of car-sharing users and grid stability. This code deals with finding the price ...
Andreas Schuldei's user avatar
1 vote
1 answer
136 views

Further optimizing the ISING model

I've implemented the 2D ISING model in Python, using NumPy and Numba's JIT: ...
Amirhossein Rezaei's user avatar
3 votes
1 answer
118 views

Create a forecast matrix from time series samples

I would like to create a matrix of delay from a time series. For example, given y = [y_0, y_1, y_2, ..., y_N] and W = 5 I need to create this matrix: ...
graille's user avatar
  • 133
1 vote
1 answer
499 views

Create normals from triangulated surface

Objective I have a 3D face mesh triangulated. I have computed the midpoint of each triangle in the mesh, and I have the normal vector (n1, n2,n3) for each triangle. The objective is to create a 2D ...
Joker's user avatar
  • 111
3 votes
2 answers
195 views

Intercolumn statistics between columns in a dataframe

I have a df and need to count how many adjacent columns have the same sign as other columns based on the sign of the first column, and multiply by the sign of the ...
jaried's user avatar
  • 177
0 votes
0 answers
140 views

Algorithm to generate splats from point clouds

I am trying to write a program to generate splats from point clouds from following this paper and this paper. The function I have to generate 1 splat is here: ...
Aayush's user avatar
  • 61
4 votes
1 answer
75 views

Optimising compatibility-conflict graph solution - python recursive routine

Background I'm implementing an algorithm which localises overlapping sound sources using the time-difference-of-arrivals across 3 sensors [1]. Compatible 'triples' (e.g. with only 2 common sensors) ...
Thejasvi's user avatar
  • 143
2 votes
1 answer
412 views

Improving the speed of one-hot encoding a list of strings

I've recently developed two functions to functions to essentially convert a list of strings that look something like this (these strings are 101 characters long in my case): ...
KLM117's user avatar
  • 123
2 votes
1 answer
235 views

Integration loop over multiple doping and temperature levels

I want to perform some calculations on a large dataset. The code can be found below, where I want to calculate the values for 'results_nr' over a large loop (1000 x 910) values. Can you help me out ...
thimoooh's user avatar
1 vote
1 answer
75 views

Generate new column based on two columns of dataframe

I need to generate column a_b based on column a and column b of ...
jaried's user avatar
  • 177
2 votes
1 answer
255 views

Replace nested for loops when assigning intial conditions in a 4-dimensional array

I create a 4-dimensional (x, y, z, t) array of zero values. I then set the initial values at t = Tmax. To do this, I use a nested for loop. I attempted to improve ...
Ruan's user avatar
  • 101
3 votes
1 answer
206 views

Numerical integration in Python involving four dimensions

I'm trying to obtain the following S2 from a given S1, $$ S2(i, j) = \sum _{k=0} ^i \sum _{l=0} ^j S1(k, i-k, j, l) e^{ -\sqrt{...
user16308's user avatar
5 votes
1 answer
929 views

Laser physics simulation

This is for a computation for laser physics. The speed is quite slow, which seems to be delayed a lot by the three nested for loops with indices j,k, and l (with comments below). And the computation ...
user16308's user avatar
1 vote
1 answer
700 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
1 vote
0 answers
128 views

Solving a linear system with Gaussian Elimination

I decided to implement a solver for linear systems of equations based on the gaussian elimination and reduction to upper triangular form. The gaussian elimination is quite simple to implement but the ...
Caridorc's user avatar
  • 27.5k
4 votes
3 answers
411 views

Pairwise Euclidean distance search algorithm

x and y are two-dimensional arrays with dimensions (AxN) and (BxN), i.e. they have the same number of columns. I need to get a matrix of Euclidean distances between each pair of rows from x and y. I ...
Никита Михалков's user avatar
2 votes
1 answer
208 views

Generating a matrix with each row having normalized weights

I just asked this question over Stack Over Flow on how to improve my code and reposting it here as someone on Stack Overflow recommended this platform. I have written two python functions and they are ...
AulwTheo's user avatar
3 votes
0 answers
66 views

Implementation of a crypto formula in Python

I need to implement in Python the formula in the image. The set B is a set of real numbers \$-1 \le t \le 1\$. Also, \$\mathbb{F}_2\$ is a set with the elements 0 and 1. \$y_i\$ is the \$i\$-th ...
juaninf's user avatar
  • 139
2 votes
0 answers
139 views

Convolution layer using numpy in python

I'm trying to make a CNN in python using numpy. I have a finished product but it seems that it can be improved. On testing the convolutional layer is the biggest bottleneck ...
Rohith's user avatar
  • 21
1 vote
0 answers
157 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

15 30 50 per page
1
2 3 4 5
8