Skip to main content

Questions tagged [numpy]

NumPy is the fundamental package for scientific computing with the programming language Python.

2 votes
0 answers
71 views

backward induction algorithm computation

Is there a way to significantly speed-up this code? I'm solving a dynamic programming model using a backward induction algorithm. A crucial step is to calculate the current-period value function (VF), ...
manifold's user avatar
  • 121
4 votes
3 answers
329 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 ...
Konchog's user avatar
  • 237
-2 votes
1 answer
78 views

Intersect two arrays in python

I have two unidimensional numpy arrays in python, gs and ni. I want to intersect them but preserving the order in gs. When they have high cardinality this operation becomes so costly. Is there any ...
phyAlph's user avatar
5 votes
1 answer
413 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}...
Amirhossein Rezaei's user avatar
8 votes
2 answers
476 views

Correctly sum pixel values into bins of angle relative to center

A quick way to try to do this would be to use scipy.ndimage.map_coordinates, mapping radius to one axis of a rectangular array, and angle to the other, then summing along the radius axis. But, I think ...
uhoh's user avatar
  • 593
2 votes
1 answer
69 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 ...
AReubens's user avatar
2 votes
2 answers
250 views

Infinite 2d block world (2d minecraft) with chunk system, physics and slower loading

Follow up from this question. I have added a slower loading system that allows the main game to run faster but I still get under 30 fps with caves even if I allow the player to outrun the loading. I ...
coder's user avatar
  • 241
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
83 views

Replace iterrow loops in pandas matrices with something else to shorten the running time

This post is modified from this one: https://codereview.stackexchange.com/posts/292885/edit (Alternatives to iterrow loops in python pandas dataframes). I have a piece of code to calculate price ...
Laura's user avatar
  • 91
7 votes
2 answers
693 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 ...
Laura's user avatar
  • 91
2 votes
1 answer
46 views

Maintain a log containing values if certain conditions are met

I'm trying to capture profits and set a stop loss in my trading strategy. I want the stop loss to be set daily based on the past data and if the current price, i.e., price for the date falls below the ...
driver's user avatar
  • 222
5 votes
2 answers
227 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
  • 411
4 votes
1 answer
78 views

Array Math to Calculate Ice Thickness -- Need Help Simplifying

I posted this on Stack but since it's working code, it was suggested I post it here. I wrote this code to calculate ice thickness using the following equation from Stephenson, 2011. It's a daily ...
emmahaggerty's user avatar
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 ...
Jonathan Wick's user avatar
3 votes
1 answer
101 views

"Flattening" a 2D STM image by subtracting an Nth order polynomial without typing out all the terms for each N?

I have some scanning tunneling microscopy (STM) topography images that I need to flatten. I have found that for some data I need a 4th order polynomial, but in other cases a lower order works better. ...
uhoh's user avatar
  • 593

15 30 50 per page
1
2 3 4 5
51