# 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,V,V) 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 …

## 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 …

## 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 …

## 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 …

## 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. …

## 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 …

## 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: …

## 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 …