SciPy is an open source library of algorithms and mathematical tools for the Python programming language.
6
votes
3answers
101 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:
...
3
votes
0answers
32 views
2D disease problem modeling [closed]
I'm modeling a disease problem where each individual in a 2D landscape has a transmissibility described by a (radial basis) kernel function. My goal is to convolve the kernel with the population ...
1
vote
1answer
74 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 ...
2
votes
1answer
91 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 ...
1
vote
0answers
58 views
Iterated root-finding and optimization
I am quite new to Python and I have trouble finding the roots of a function.
The ultimate goal is to find $$y=(a_1,p_0,\theta)$$ such that they minimize the function $$-\sum\limits_{j=1}^{n} ...
0
votes
2answers
126 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 ...
2
votes
1answer
120 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 ...
2
votes
1answer
96 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 ...
3
votes
1answer
366 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 ...
2
votes
1answer
115 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:
...
10
votes
1answer
79 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 ...