scipy-optimize

Can i use the Newton-Raphson method of scipy.optimize with a multiple variable system?

Can i use the Newton-Raphson method of scipy.optimize with a multiple variable system? Question: I wanted to do the Newton-Raphson method with scipy with a multivariable system. So, i followed this documentation. And here is an example code where i tried to solved my problem: import numpy as np from scipy.optimize import newton def f(x): …

Total answers: 1

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

Possible unbalanced tuple unpacking with sequence in scipy optimization curve_fit

Possible unbalanced tuple unpacking with sequence in scipy optimization curve_fit Question: I got error from pylint from my code. I don’t know how to fix that. can you please help me? The code is here: import numpy as np import matplotlib.pyplot as plt from scipy.optimize import curve_fit # Define the two points x1, y1 = …

Total answers: 2

How to build an expanding mathematical expression in Python?

How to build an expanding mathematical expression in Python? Question: I have a problem where I need to solve a polynomial of a degree that increases with each iteration (loop). The expression is (1/(1+x)^1) + (1/(1+x)^2) + (1/(1+x)^3) + (1/(1+x)^4) + (1/(1+x)^5) As you can see, the exponential grows with each iteration and this expression …

Total answers: 4

Curve.fit optimization error: 'Covariance of the parameters could not be estimated

Curve.fit optimization error: 'Covariance of the parameters could not be estimated Question: I’m trying to fit some data into a function, but scipy curve_fit gives me the following message: "OptimizeWarning: Covariance of the parameters could not be estimated" and won’t plot or print the parameters of the fit. I believe the power inside the exp …

Total answers: 1

Find the value of a variable that maximizes a multivariable function

Find the value of a variable that maximizes a multivariable function Question: I have a function like this: def objective(x, y, z, q): theta1 = f(x, y) theta2 = f(x, z) rho = q – (theta1 + theta2) return rho * x and I would like to find the value of x that maximizes the …

Total answers: 1

How to pass shared variable in scipy differential evolution with worker > 2

How to pass shared variable in scipy differential evolution with worker > 2 Question: I want to pass a shared variable in python scipy "differential_evolution" to keep track of experiment number. I can do this with worker=1 , but i am unable to keep track of experiment number with worker > 2. Here is my …

Total answers: 1

Is there a faster optimization algorithm than SLSQP for my problem?

Is there a faster optimization algorithm than SLSQP for my problem? Question: I have a medium sized optimization problem that I have used scipy optimize with the SLSQP method to solve. I am wondering if there is a faster algorithm? Here is my code: from scipy.optimize import minimize, Bounds import pandas as pd import numpy …

Total answers: 1

scipy curve_fit incorrect for large X values

scipy curve_fit incorrect for large X values Question: To determine trends over time, I use scipy curve_fit with X values from time.time(), for example 1663847528.7147126 (1.6 billion). Doing a linear interpolation sometimes creates erroneous results, and providing approximate initial p0 values doesn’t help. I found the magnitude of X to be a crucial element for …

Total answers: 2

Constrained optimisation in scipy enters restricted area

Constrained optimisation in scipy enters restricted area Question: I am trying to solve multivariate optimisation problem using Python with scipy. Let me define environment I am working in: Searched parameters: and the problem itself: (In my case logL function is complex, so I will substitute it with the trivial one, generating similar issue. Therefore in …

Total answers: 1