1,151 questions
0
votes
0
answers
78
views
Standard deviations of fit parameters suspiciously small
I am attempting to perform a nonlinear curve fit to some experimental data obtained from an oscilloscope. The time signal is a sinusoidal voltage over time and I want to evaluate the phase of the ...
2
votes
1
answer
83
views
Use `curve_fit` with `partial` using named parameters instead of positional parameters
I'm trying to use curve_fit on a function for which I want to freeze one or more parameters using partial.
E.g. this pattern, which is working:
from scipy.optimize import curve_fit
from functools ...
7
votes
2
answers
179
views
When using scipy.optimize.curve_fit what is the optimal formulation of the function being fitted?
I noticed that the formulation matters when trying to fit a non-linear equation of the form y = a + b * x ** c and I wonder which formulation in general results in the best fit?
Formulation 1
y = a + ...
0
votes
0
answers
60
views
SHGO optimisation ending upon None. Tried all three sampling methods: sobol, halton, simplicial. Evaluation variability reason for None output?
I am minimising the objective function which is -100 * fill rate(floors) together with L2 penalty on epsilon and gamma:
-100 * fill_rate(floors) + l1 * ||epsilon|| + l2 * ||gamma||
I have constraints ...
1
vote
2
answers
100
views
mpi4py deadlock with scipy.minimize
I am trying to do something similar as described in Parallelize a function call with mpi4py
But there are some things there that make me skeptical of the provided answer. Additionally, I have a class ...
2
votes
3
answers
124
views
Multiprocessing with SciPy Optimize
Question: Does scipy.optimize have minimizing functions that can divide their workload among multiple processes to save time? If so, where can I find the documentation?
I've looked a fair amount ...
2
votes
1
answer
129
views
Is it possible to increase precision in scipy's least squares optimization?
I am trying to use SciPy's scipy.optimize.least_squares to solve a system of 35 non linear equations related to multilateration.
For context :
There are 5 "reference points" which are fixed ...
1
vote
1
answer
68
views
Scipy Minimize throwing bounds error when constraint is added
I am trying to optimize a matrix given some bounds and constraints. When I run the minimize function with only the bounds everything works fine, but when adding the constraints I get the following ...
1
vote
1
answer
84
views
Access scipy differential evolution object through custom strategy
A recent addition to scipy's differential_evolution implementation is to allow custom strategies, which should be a callable. Here is a simplistic example.
from scipy.optimize import ...
0
votes
0
answers
61
views
sc.minimize ignoring the constraints
I'm having some troubles with this optimization below. x0 is an array with -1 and 1, the result i'm trying to achieve is that the code choose to let the number as +/- 1 or change to 0, the main ...
4
votes
2
answers
206
views
Curve-fitting a non linear equation
I'm trying to fit my thermal conductivity into the Debye-Callaway equation. However, one of my parameters is coming back negative. I've tried different initial guesses. So I'm attaching a code with ...
0
votes
1
answer
132
views
Differential evolution fails when worker argument is added
To set up my differential_evolve curve-fit function, I borrowed heavily from https://bitbucket.org/zunzuncode/ramanspectroscopyfit/src/master/RamanSpectroscopyFit.py. My implemented function works ...
1
vote
1
answer
113
views
Why is curve_fit giving me different results in different computers?
I have the following model:
-dc/dt = kc(t) - k'n(t)
I compute c(t) and n(t) from a simulation trajectory with CuPy. I then compute k and k' with curve_fit, through the following code:
# compute dc/dt
...
0
votes
2
answers
138
views
solve Sympy functions in Scipy (optimize.root)
I'm trying to find the roots with the root function in Scipy for functions/variables created in Sympy.
sympy:
AllEquations = [x1 - 5, y1 - 5, z1 - 5, ((x1 - x2)**2 + (y1 - y2)**2 + (z1 - z2)**2)**0.5 -...
1
vote
2
answers
77
views
curve_fit popt is only returning one parameter when my function has two
I am trying to understand why my curve_fit is only producing one optimized parameter when I have created the function using two, td and tr. The number is it producing also does not make sense as I am ...
3
votes
3
answers
206
views
Scipy Curve_fit: how would I go about improving this fit?
I've been working on a standard potential which I am trying to fit with a given model:
ax2 - bx3 + lx4
The x and y values for the fit are generated from the code as well, the x values are generated by ...
1
vote
1
answer
80
views
Scipy.optimize not respecting constraints
I'm trying to create a script that will minimize the maximum distance between the ends of two lines at three different orientations. The first line, A, has a fixed origin and length, while line B's ...
0
votes
0
answers
101
views
How to make the scipy minimization function multithread?
I try to use scipy minimize to solve a minimization functions. My objective function and gradient function require multi-threaded computation. However, when calling these functions, there is no ...
0
votes
2
answers
178
views
fmin_slsqp taking too long
I am using fmin_slsqp to find the weights that minimize mean squared error. The weights need to be positive. For each pair of X and y, it takes ~10 seconds. (Each X is (10, 1000) and y is (10,)). I ...
0
votes
2
answers
109
views
Multi-dimensional scipy.optimize.LinearConstraint?
My linear constraint for scipy.optimize.minimize is
ones = np.ones_like(x)
np.outer(x, ones) - np.outer(ones, x) > something
where something is a given matrix.
(Mathematically, a_ij < x_i - x_j ...
1
vote
0
answers
71
views
Scipy.optimize.minimize with constraints
I need to minimize a two variables function and I have a constraint to respect.
I wrote the following code
def deflection_constraint(inputs):
#return value must come back as 0 to be accepted
#...
0
votes
1
answer
134
views
SciPy Minimize Constrain Around Internal Parameter, Not Input
EDIT 1: This question has been completely modified for improved clarity and to better state my intent. The original post is at the end.
I think a lot of people are confused by my example code. It was ...
0
votes
1
answer
62
views
Fitting a curve with sin(atan)
I'm trying to fit a curve using the curve_fit from scipy, but I'm getting RuntimeError. I have an input data (x,y) and I'd like to fit it to an equation defined in the y_fit function. Does anyone know ...
0
votes
1
answer
96
views
Scipy minimize to optimize ODE parameters
I have defined an ode function, langmuir_ode, as follows:
def langmuir_ode(t, AL, Rmax, kon, koff):
A = np.interp(t, time, concs)
L = Rmax - AL
return kon * A * L - koff * AL
t is some ...
0
votes
1
answer
83
views
Python scipy.optimize gives wrong answer, how to deal with semidefinite positive condition?
The goal is to calculate an optimization problem using python scipy.optimize.
Suppose C is a given 4-dimension matrix (in the code I use a random matrix to denote that). The optimized variables are A0 ...