Questions tagged [numpy]
NumPy is the fundamental package for scientific computing with the programming language Python.
765 questions
4
votes
4
answers
1k
views
4
votes
1
answer
365
views
Half-hexagon neighbour identification under (novel) hierarchical hexagonal grid
Context & Background
Please let me remind you that this project may involve original research; it is important to remember that all content on this site is subject to CC BY-SA 4.0. It is a breach ...
4
votes
3
answers
387
views
numpy array/item handling functions
Recently I have been using numpy arrays, which have great utility via their broadcasting methods.
I am attempting to write a useful public facing library, and this ...
6
votes
1
answer
458
views
Implementing a joint differential equation and eigenvalue solver
I've written a Python script to solve a system of coupled differential equations and then use the results to solve an eigenvalue problem. The full problem is:
\$\frac{d^2}{dr^2} K(r) = \frac{K(r)}{r^2}...
2
votes
1
answer
87
views
Building Multi Period Linear Programming Matrices
I'm solving a linear programming problem, made of many small problems with some common shared constraints, meaning that they are all together.
Each individual unit has constraints unique to the unit ...
4
votes
1
answer
214
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 ...
6
votes
2
answers
747
views
Alternatives to iterrow loops in python pandas dataframes
I have a piece of code to calculate price sensitivity based on the product and its rating.
Below is the original data set with product type, reported year, customer’s rating, price per unit, and ...
5
votes
2
answers
319
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 ...
3
votes
5
answers
2k
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 ...
10
votes
3
answers
1k
views
Function that returns activation function, as well as its derivative
I have the following function that returns one of several functions along with their derivative for training neural networks.
Can this function be improved and made more pythonic in any way?
Are there ...
-1
votes
1
answer
63
views
Python manual SVD only working for some matrices - how to stabilize it? [closed]
I use the following code for a manual single value decomposition using numpy. Depending on the array I choose it sometimes works out well and I can verify the svd and sometimes it does not work out ...
14
votes
1
answer
1k
views
Text-mode 2048 in Python (using numpy)
Good evening. I am studying mathematics at the moment, so I have little to no formal education in actual computer engineering. However, I am trying my hands at learning Python because I will need lots ...
3
votes
1
answer
118
views
3ph 2l inverter simulation with SPWM
Here is a code for a simple model of three phase two level inverter with constant DC voltage source and three phase RL load.
...
0
votes
2
answers
161
views
Optimize a Python code which indicates duplicated values in an excel file [closed]
I wrote this code to indicate duplicated values. It actually works but I hope to know if there's another possible solution to optimize this process. Thanks.
...
5
votes
1
answer
102
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. ...
5
votes
3
answers
318
views
Fast complex absolute argmax in Cython
I'm thinking I implemented it optimally, but somehow it's much slower than what should be much slower, np.argmax(np.abs(x)). Where am I off?
Code rationale & ...
4
votes
3
answers
165
views
Calculate length of continuous gaps
I have a list with some nan values, out of which some are continuous, e.g.:
list = [1, 2, 3, np.nan, np.nan, 6, 7, np.nan, 9, np.nan,np.nan,np.nan, 12]
For some ...
3
votes
0
answers
182
views
Image generator using prime numbers in polar coordinates
Related
This is a Python script that generates images using prime numbers up to a given positive integer, it generates prime numbers using the Sieve of Eratosthenes with some rudimentary Wheel ...
6
votes
2
answers
555
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 ...
2
votes
1
answer
103
views
Readable Backprogragation calculations in Numpy Neural Network
As an exercise we should write a small Neural Network with the following structure:
There should be additionally a bias for each layer and sigmoid should be used as the activation function.
The ...
1
vote
1
answer
92
views
Fixing math library functions in Black-Scholes options pricing model
I've amended a code for the Black-Scholes formula for European pricing options found here at the bottom of the page and fixed the math functions accordingly. Unlike the code on the website, mine has ...
3
votes
1
answer
190
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 ...
2
votes
1
answer
165
views
Further optimizing the ISING model
I've implemented the 2D ISING model in Python, using NumPy and Numba's JIT:
...
2
votes
2
answers
2k
views
Poker hand valuator in Python
As you will probably notice very quickly from the code below, I'm not very experienced coder. Below is my attempt at valuating poker hands in Python. The code below may not be pretty but it seems to ...
9
votes
1
answer
4k
views