Skip to main content

Questions tagged [scipy]

SciPy is an open source library of algorithms and mathematical tools for the Python programming language.

Filter by
Sorted by
Tagged with
4 votes
0 answers
710 views

Find the closest parametric values corresponding to a BSpline's control points

On a curve generated by scipy.interpolate.BSpline I want to find the closest parameters relative to each control point, so that the given parametric range is ...
Fnord's user avatar
  • 383
3 votes
0 answers
450 views

Applying Scikit-Learn Linear Kernel with a generator for low memory pressure

matrix = # a sparse matrix of TFIDF vectors - 28458x3218988 My aim was to create a similarity matrix comparing all documents to all documents using ...
James Allen-Robertson's user avatar
4 votes
0 answers
4k views

Calculate relationship between 2 categorical variables in a pandas Dataset with chi square test

I'm working on a Machine Learning project and I'm in Data Exploration step, and my dataset has both categorical and continuous attributes. I decided to compute a chi square test between 2 categorical ...
Espoir Murhabazi's user avatar
2 votes
1 answer
219 views

Multidimensional matrix exponentiation

Is there a more efficient way of exponentiating a multidimensional matrix? This is how I am currently doing it: ...
Hia3's user avatar
  • 81
2 votes
0 answers
57 views

MCMC Metropolis Hastings for German Tank Puzzle

I have implemented the following MCMC algorithm for the german tank puzzle found here I just want to make sure everything is legit and that I am not getting the right answer by chance. ...
user2879934's user avatar
8 votes
1 answer
185 views

Root finding and integration [closed]

I am trying to implement the modified Next Reaction Method with time varying propensities as mentioned in sections IV and V of this paper. At one step in the process this expression must be evaluated: ...
Patrickens's user avatar
9 votes
1 answer
1k views

Fitting multiple piecewise functions to data and return functions and derivatives as Fortran code

Background For a future workshop I'll have to fit arbitrary functions (independent variable is height z) to data from multiple sources (output of different ...
StefanS's user avatar
  • 143
2 votes
0 answers
636 views

Single-pass clustering algorithm for sparse matrices

I have written single pass clustering algo for reading sparse matrices passed from scikit tfidfvectoriser but the speed is king of average for medium size matrix. How can I scale for large size ...
gaurus's user avatar
  • 131
3 votes
1 answer
262 views

Cython code for adaptive binning

Here is my Cython code used for adaptive binning. The calcAdaptiveBinnedRateMap function is called from another Python script. The script is compiled using Cython ...
raj's user avatar
  • 31
7 votes
1 answer
248 views

Raster processing for climate change model

I am working on a project on how climate change may affect the development of spruce budworm larvae throughout each year (historical and projected) using different climate change models and emission ...
bobby12345's user avatar
6 votes
1 answer
2k views

Calculating T-Test within Large Pandas Dataframes

The below code runs a t-statistic within a large dataframe (rnadf) based on masked values from another dataframe (cnvdf_maked). ...
Thomas Matthew's user avatar
2 votes
1 answer
6k views

Polynomial curve-fitting over a large 3D data set

I have a list of 4 images, called listfile.list, which looks like this: image1 image2 image3 image4 Each image has 10 frames containing a 2000 x 2000 array of ...
A. Cremins's user avatar
5 votes
2 answers
495 views

Runge-Kutta 4th order using Python numexpr.evaluate()

I am implementing an ODE solver, where the user provides rates and coefficients as a string. ODE solver has to work with vectors. The best implementation I got so far is the following: ...
Igor Markelov's user avatar
3 votes
2 answers
883 views

Crank-Nicolson. Advection - Diffusion

I am writing an advection-diffusion solver in Python. I am quite experienced in MATLAB and, therefore, the code implementation looks very close to possible implementation in MATLAB. I implemented the ...
Igor Markelov's user avatar
4 votes
2 answers
222 views

Temporal kernel filtering on video frames coming in a loop

I have a video which I read in a loop frame by frame. For every frame, I want to do temporal kernel filtering, the coefficients of which come from the input variable model (a dictionary). The temporal ...
GKS's user avatar
  • 159
8 votes
2 answers
1k views

Epidemic simulation

The purpose of this code is to simulate epidemics across a population. There are 625 (pop) individuals at random locations. The epidemic parameters are infectious period (inf_period), trans (...
StatsSorceress's user avatar
4 votes
1 answer
4k views

Compute Gini Coefficient

Recently, I was given a math assignment to calculate Gini Indexes for a table of percent distributions of aggregate income. The table takes the form of: ...
Dando18's user avatar
  • 319
4 votes
1 answer
912 views

Python script to store nd array into images

I am trying to write a generic Python script that do the following types of tasks: Load .npy file (the .npy file is of shape (m_samples, channels, row, column), which corresponds to ...
user288609's user avatar
0 votes
1 answer
4k views

Cosine similarity computation

I have a matrix of ~4.5 million vector [4.5mil, 300] and I want to calculate the distance between a vector of length 300 against all the entries in the matrix. I got some great performance time ...
ajaanbaahu's user avatar
4 votes
1 answer
51 views

Accessing an unreturned list within a function in Python without disturbing Scipy [closed]

Here is the code I'm working on. I'm trying to find the optimum alpha value to get the minimum MAE/MAD. With scipy.optimize, it works quite well. However, when <...
Umut C.'s user avatar
  • 41
1 vote
1 answer
95 views

Counts instances for each category for many Matlab files

This is for machine learning. I have 5 matlab files: AWA, REM, S1, S2, SWS. Each one has 2 arrays: x and y. ...
Aizzaac's user avatar
  • 207
4 votes
1 answer
333 views

Surface Density Profile

I am trying to compute the surface density profile, given the spherical density profile in 3D for different parameters in order to interpolate and have it as a function of them to use later on for ...
Sketos's user avatar
  • 53
4 votes
1 answer
6k views

Conditional removal of columns in sparse matrix

I have a large dataset (78k instances x 490k features) that is loaded as a scipy.sparse.csr_matrix format. From this dataset I want to filter certain features (i.e. ...
GJacobs's user avatar
  • 43
8 votes
2 answers
185 views

20+ functions for generating different waveforms

I added a guard clause to the functions in scipy.signal.windows, but the way they are currently written means the same 11 lines are now repeated in every function. ...
endolith's user avatar
  • 181
2 votes
1 answer
241 views

Measuring the distance between NumPy matrixes

This takes two sets of five random points stored as a NumPy matrix, and then calculates the NumPy matrix between a point of the first set and a point of the second set. While the code works, I feel it'...
Pietro Speroni's user avatar
6 votes
3 answers
249 views

Energy curve plotter

I am not much experienced in Python, just write some small script. All my codes are procedural. They work fine, and I always check them with pep8. One of them is: ...
BaRud's user avatar
  • 197
8 votes
3 answers
2k views

Python differential analysis of heat loss across a pipe

I made a differential equation solver to forecast heat loss through a pipe with heat loss coefficient contours. It does what I want it to do but I had to use global variables to change the outputs of ...
kilojoules's user avatar
2 votes
1 answer
5k views

Converting an image from polar to cartesian coordinates

I have the following code which has too many loops inside it (almost 13 billion). This code is actually for image processing. I am first making a matrix of dimension 1024*360. This is the value of the ...
PRAKRITI KUMARI VISHOK KUMAR e's user avatar
14 votes
5 answers
49k views

Chi Square Independence Test for Two Pandas DF columns

I want to calculate the scipy.stats.chi2_contingency() for two columns of a pandas DataFrame. The data is categorical, like this: ...
Klaster's user avatar
  • 243
3 votes
1 answer
817 views

Plotting non continuous functions and a real scatter example with Bokeh

I've written a python 3 code using Bokeh. With this code you can learn howto to plot math functions and a scatter plot with regression linear functions in a webpage. The target is how to plot ...
Tobal's user avatar
  • 308
0 votes
2 answers
802 views

Changing algorithm to avoid looping with iterrows

I am new to Python. I wrote a code that works but the algorithm is obviously not efficient at all. I am stuck in the loop on iterrows and I do not see how to get rid of it. First a little bit on the ...
Ariane's user avatar
  • 3
3 votes
1 answer
761 views

Lattice lotka-volterra

Can anyone comment on the efficiency of my code? I am new with Python using NumPy/SciPy and I am trying to program a lattice biological model where a certain (one and only one) species (represented by ...
djorrel's user avatar
  • 31
7 votes
1 answer
7k views

Obtaining prediction bands for regression model

I'm trying to generate prediction bands for an exponential fit to some 2-dimensional data (available here). The data (blue points), best fit found by ...
Gabriel's user avatar
  • 575
6 votes
1 answer
8k views

Divide all elements in the column of a sparse matrix

Using Python Scipy, I am trying to divide all numbers in all columns of a sparse matrix (400K × 500K, density 0.0005), by the sum of the squares of all numbers in a column. If a column is ...
Avisek's user avatar
  • 195
2 votes
1 answer
1k views

SciPy sparse: optimize computation on non-zero elements of a sparse matrix (for tf-idf)

I have a sparse matrix (term-document) containing integers (word counts/tf) and I am trying to compute the tf-idf, for every non-zero value in the sparse-matrix. The formula for tf-idf I am using is: ...
Avisek's user avatar
  • 195
11 votes
1 answer
146 views

Class used for stochastic epidemic simulations

I've developed a class used for some epidemic simulations I'm doing. Individuals are 'S' (susceptible), 'I' (infected), or 'R' (recovered). These are standard abbreviations in the research community....
Joel's user avatar
  • 365
7 votes
1 answer
156 views

Catalogue manipulation

I have a catalogue of 56000 objects and I want to replace some columns with new values for instance replace NaN with -99 and <...
Dalek's user avatar
  • 133

1
2