scipy

From Mathcad Minimize to SciPy Minimize

From Mathcad Minimize to SciPy Minimize Question: I tryed to convert this Mathcad code into the SciPy Python. My code in Python: from scipy.optimize import minimize from scipy.optimize import LinearConstraint import numpy as np A=[[1,1,0,1],[-1,-1,1,0],[0,0,-1,-1]] V=[[1000, 1000], [0, 0],[-1000, -1000]] linear_constraint = LinearConstraint (A, V[0],V[1],V[2]) x0 = np.array([0.1,0.1,0.1,0.1]) f = [5*10**-9,2*10**-9,6*10**-8,2*10**-8] def func(x): sum=0 for …

Total answers: 1

How to crop an audio file based on the timestamps present in a list

How to crop an audio file based on the timestamps present in a list Question: So, I have an audio file which is very long in duration. I have manual annotations (start and end duration in seconds) of the important parts which I need from the whole audio in a text file. I have converted …

Total answers: 1

Scipy – Ks2samps statistic location

Scipy – Ks2samps statistic location Question: I follow this official doc to conduct the two-sample Kolmogorov-Smirnov test. I would like to ask how to get the statistic_location (i.e., the location of maximum difference between the two CDFs). In the documentation, it specifies that the ks_2samp function can return the statistic_location but in fact it only …

Total answers: 1

Python print every unique combination of list items

Python print every unique combination of list items Question: What is the cleanest (most "pythonic") way of printing every unique combination of three items in the following list? strats = ["1","2","3","4"] The solution needs to avoid duplicates: 1 and 1 and 1 No (not unique) 1 and 1 and 2 No (not unique) 1 and …

Total answers: 1

Cannot install scipy (1.9.1) on 32-bit Windows 10 using pip (ERROR: ResolutionImpossible)

Cannot install scipy (1.9.1) on 32-bit Windows 10 using pip (ERROR: ResolutionImpossible) Question: I’ve been installing python 3.10 packages on 32-bit Windows 10. I had no problems with numpy or pandas but cannot seem to install scipy. I’ve been researching on the matter and found out scipy version 1.9.1 seems to have 32-bit wheels available. …

Total answers: 1

Multiply scipy sparse matrix with a 3d numpy array

Multiply scipy sparse matrix with a 3d numpy array Question: I have the following matrices a = sp.random(150, 150) x = np.random.normal(0, 1, size=(150, 20)) and I would basically like to implement the following formula I can calculate the inner difference like this diff = (x[:, None, :] – x[None, :, :]) ** 2 diff.shape …

Total answers: 2

Problems with scipy minimize

Problems with scipy minimize Question: I’m trying to use the minimize function to optimize two parameters for a power law fit. I am getting these errors so far. I already obtained variables that I wanted using curve fit, but I specifically wanted to use the minimize function on a chi_square function. Here is the code: …

Total answers: 1

Adapt von Mises KDE to Seaborn

Adapt von Mises KDE to Seaborn Question: I am attempting to use Seaborn to plot a bivariate (joint) KDE on a polar projection. There is no support for this in Seaborn, and no direct support for an angular (von Mises) KDE in Scipy. scipy gaussian_kde and circular data solves a related but different case. Similarities …

Total answers: 2

Different results when computing integral analytically/with scipy VS approximating integral

Different results when computing integral analytically/with scipy VS approximating integral Question: I’m trying to calculate the integral of a variant of the Hill Equation shown here. When I try implementing this with the integrate function in SciPy, I get the following: from scipy import integrate Top = 0.9015038230670139 Bottom = 0.5972679490151096 ic50 = 17561.998143066336 Coef …

Total answers: 1

failed to hear audio on jupyter with librosa but can with scipy – sampling rate issues?

failed to hear audio on jupyter with librosa but can with scipy – sampling rate issues? Question: I can hear audio in jupyter if loaded with scipy. However, I can hear untill 192000 sampling rate. If I set to 192001 or above, I cannot hear anything. from IPython.display import Audio from scipy.io.wavfile import read wave_filename …

Total answers: 1