scipy

Can scipy.optimize Find Optimal Input Values When Multiple Products are Involved?

Can scipy.optimize Find Optimal Input Values When Multiple Products are Involved? Question: I’d like to find the optimal values for Input A for Product 1 and for Input A for Product 2 with the aim to maximize Total Output and subject to a given constraint. I’ve tried using Python’s Scipy minimize function and it works …

Total answers: 1

peak integration using trapz but not starting from baseline and visualization

peak integration using trapz but not starting from baseline and visualization Question: I am trying to integrate signal peaks using numpy.trapz or scipy.trapz. I do manually select the range of a peak min and max. the problem I am facing is that I think these functions integerates the AUC till the baseline. Sometimes my signal …

Total answers: 1

"ImportError: cannot import name 'triu' from 'scipy.linalg'" when importing Gensim

"ImportError: cannot import name 'triu' from 'scipy.linalg'" when importing Gensim Question: I am trying to use Gensim, but running import gensim raises this error: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.10/dist-packages/gensim/__init__.py", line 11, in <module> from gensim import parsing, corpora, matutils, interfaces, models, similarities, utils # noqa:F401 File "/usr/local/lib/python3.10/dist-packages/gensim/corpora/__init__.py", …

Total answers: 3

jit – "Failed in nopython mode pipeline" error, despite not using nopython in numba

jit – "Failed in nopython mode pipeline" error, despite not using nopython in numba Question: I am using value function iteration to solve a complex dynamic programming problem with many states. I want to use numba/jit to speed up my code (and eventually parallelize the for loops). When I use the @jit decorator in my …

Total answers: 1

Masking nan values from an xarray dataset for scikit.learn mulltiple linear regression following scipy

Masking nan values from an xarray dataset for scikit.learn mulltiple linear regression following scipy Question: I’m attempting to use scikit-learn.linear_model’s LinearRegression find the multiple linear regression coefficients for different variables at each latitude and longitude point along the time dimension like so: for i in range(len(data.lat)): for j in range(len(data.lon)): storage_dframe[i, j, :] = LinearRegression().fit(np.array((data.ivar1.values[:, …

Total answers: 2

About the inputs of the Wasserstein Distance W1

About the inputs of the Wasserstein Distance W1 Question: NOTE: I wrote the same question on https://math.stackexchange.com/questions/4765025/about-the-inputs-of-the-wasserstein-distance-w-1, and since I did not get any comment or answer, I post it here, since it can overlap with topics on stack overflow In math, you calculate the Wasserstein Distance W1 among two probability measures P and Q, …

Total answers: 1

Small value artifacts from applying scipy.signal.convolve

Small value artifacts from applying scipy.signal.convolve Question: This Python 3.11.5 script: import numpy as np from skimage.io import imread from scipy.signal import convolve image = np.flipud(imread(‘conv-test.bmp’).astype(np.float32)) con = convolve(image, np.ones((3, 3))/9, mode=’valid’) print(image.min()) print(np.logical_and(image > 0, image < 1).any()) print(np.logical_and(con > 0, con < 0.00001).any()) produces: 0.0 False True How is it possible to get …

Total answers: 1

Why is the integration not progressing with scipy.integrate.ode?

Why is the integration not progressing with scipy.integrate.ode? Question: I am integrating a function func in the complex domain using scipy.integrate.ode. I have assembled the following code structure: import numpy as np from scipy.integrate import ode def func(x, u, k): #f, g = u dfdx = k*x**2 dgdx = -x rhs_FD = [0]*2 rhs_FD[0] = …

Total answers: 1