Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
81 views

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 ...
Yolan Ankaine's user avatar
2 votes
1 answer
127 views

I have this code in which I'm trying to use scipy.optimize.curve_fit() to take a cos^2(x) function and approximate it as a sum of gaussian peaks. However, it is generating a very poor fit and I can't ...
Cody Payne's user avatar
2 votes
1 answer
83 views

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 ...
euronion's user avatar
  • 1,319
1 vote
1 answer
128 views

I’m trying to fit a logistic function to GDP data (China GDP dataset) using scipy.optimize.curve_fit. The fitting looks very good (R² ≈ 0.99, curve matches the data), but when I try to predict a ...
MSo's user avatar
  • 13
7 votes
2 answers
180 views

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 + ...
3UqU57GnaX's user avatar
0 votes
1 answer
132 views

I'm running an optimization problem using scipy MILP function. I get to the point where the solving report pops up, either through time limit or solution (see below). When the solving report pops up, ...
stackoverflowuser124112's user avatar
0 votes
0 answers
60 views

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 ...
Rakesh Balhara's user avatar
0 votes
1 answer
76 views

Given the code below, I am unable to remedy the fact that only rank 0 participates in evaluations of Objective after the first iteration of the (SciPy) minimizer. Obviously the rank!=0 workers finish ...
Sterling Butters's user avatar
1 vote
2 answers
104 views

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 ...
Sterling Butters's user avatar
3 votes
1 answer
162 views

I am trying to find the optimal projection parameters when transforming spherical coordinates into Cartesian ones for a given projection. The mathematical description of the projection is presented in ...
lukon's user avatar
  • 31
2 votes
3 answers
127 views

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 ...
trevdawg122's user avatar
0 votes
1 answer
83 views

I am trying to apply scipy optimization for an application. I am not able to monitor the progress of the optimization. Can someone help me with an example (pointer is enough) or sources from where I ...
Murali's user avatar
  • 25
2 votes
1 answer
131 views

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 ...
Tom's user avatar
  • 21
2 votes
2 answers
117 views

Let's say I have a function foo(x, a, b) and I want to find a specific one of its (potentially multiple) roots x0, i.e. a value x0 such that foo(x0, a, b) == 0. I know that for (a, b) == (0, 0) the ...
schtandard's user avatar
1 vote
1 answer
70 views

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 ...
adamskor's user avatar
1 vote
1 answer
65 views

I am trying to minimise a complex problem (non-linear) with differential_evolution method in scipy. Key syntaxes are given below a) I am creating an object assigned to differential_evolution res = ...
Murali's user avatar
  • 25
1 vote
1 answer
92 views

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 ...
Hmwat's user avatar
  • 119
1 vote
1 answer
67 views

I am defining a piecewise function for some data, def fit_jt(x, e1, e2, n1, E1, E2, N1, N2): a = 1.3 return np.piecewise(x, [x <= a, x > a], [ lambda x: 1 / e1 + (1 - np.float128(...
BaRud's user avatar
  • 3,260
0 votes
0 answers
67 views

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 ...
Pedro Andion's user avatar
3 votes
0 answers
67 views

I'm making a trajectory propagation optimiser, running into an issue where the result of SciPy optimise seems to completely ignore a non linear constraint. I've used the exact same format in a similar ...
user29521723's user avatar
4 votes
2 answers
206 views

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 ...
Materialsgirl's user avatar
-1 votes
1 answer
114 views

I’m trying to fit the function C * np.sqrt(a - x) + D (a is a number, not a parameter) to some data, and it’s really overfitting one point. I’ve plotted it on Desmos based on the popt values python ...
nhal's user avatar
  • 1
0 votes
1 answer
132 views

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 ...
onix's user avatar
  • 3
14 votes
8 answers
762 views

I have a system of equations where each equation is a linear equation with boolean constraints. For example: x1 + x2 + x3 = 2 x1 + x4 = 1 x2 + x1 = 1 And each x_i is either 0 or 1. Sometimes there ...
Salvador Dali's user avatar
1 vote
1 answer
113 views

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 ...
horlust's user avatar
  • 111
1 vote
0 answers
105 views

What is the correct way to call dual_annealing scipy optimizer? Tried both the variants, neither of them works. import scipy.optimize as spo optimizer_fn = 'spo.dual_annealing' optimizer = eval(...
madmatrix's user avatar
  • 265
0 votes
2 answers
139 views

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 -...
Achaibou Karim's user avatar
0 votes
1 answer
158 views

I have the following pandas dataframe which represents the consumption of 7 days (day_0 is today, day_-1 is yesterday etc) of 10 people (ids): import pandas as pd import numpy as np df = pd.DataFrame(...
quant's user avatar
  • 4,512
1 vote
2 answers
78 views

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 ...
Rena Kramer's user avatar
0 votes
0 answers
87 views

I'm solving a large unconstrained optimization problem and experimenting with the trust-kyrlov / trust-ncg methods in scipy.optimize.minimize. Unfortunately, these methods can be quite slow when my ...
Eric Weine's user avatar
3 votes
3 answers
215 views

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 ...
SDee's user avatar
  • 33
0 votes
1 answer
101 views

I am working on a curve-fitting optimization problem using sinusoidal wave data. I have around 16 cycles of almost identical sine wave data, but I am encountering an issue with the y-axis offset. The ...
Saul Chang Liu's user avatar
1 vote
1 answer
81 views

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 ...
Conor Carson's user avatar
3 votes
2 answers
217 views

I am attempting to use SciPy optimization to find the function that minimizes the potential energy of a hanging rope between 2 points, the catenary problem. The objective function is defined by The ...
Anik Patel's user avatar
0 votes
0 answers
102 views

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 ...
nickaaa's user avatar
1 vote
1 answer
125 views

I am trying to calculate the breakeven price for a given IRR and getting stuck in scope's root solver. A simple example: n = 10. # no of periods years = np.arange(n) + 1 initial_investment = [-1000] ...
BraveNewUniverse's user avatar
0 votes
2 answers
184 views

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 ...
Anonny's user avatar
  • 481
0 votes
0 answers
121 views

I am working with a dataset where I want to estimate the parameters of a lognormal distribution using Maximum Likelihood Estimation (MLE). The data represents observed probabilities of events (like ...
Orhun Kalyoncu's user avatar
0 votes
2 answers
111 views

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 ...
sds's user avatar
  • 60.5k
0 votes
1 answer
67 views

I asked ChatGPT and it wasn't helpful. Basically I want to implement a constraint on a Transformed vector of X, let's say T(X). How do I do that? Here is my code: def TransformFunction(X): ...
confused's user avatar
  • 187
1 vote
0 answers
74 views

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 #...
Giovanni Bugli's user avatar
0 votes
1 answer
80 views

sorry for asking low level questions. I'm a physicist and I don't know much about programming I have data want to do fit probolic on it and I have no solution to solve it example file data x y z t -2....
user avatar
0 votes
1 answer
135 views

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 ...
kriegersan's user avatar
1 vote
2 answers
121 views

I am trying to fit some data to a theoretical Laser interferometric vibrating speaker system characterization model, and I am running into some problems. Here's the mathematical model: Here's the ...
mattsal's user avatar
  • 11
0 votes
1 answer
62 views

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 ...
João Marcos Cavalcante's user avatar
0 votes
1 answer
129 views

My goal is to achieve a two dimensional curve fit using scipy curve_fit function (I'm a bit lazy and just wanted to apply my typical 1D curve fitting to a 2D surface). I begin with two lambda ...
user26794562's user avatar
0 votes
1 answer
97 views

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 ...
Alex van der Kooi's user avatar
0 votes
1 answer
98 views

I'm trying to (1) simulate data with a Weibull distribution using known parameters, and then (2) trying to fit that simulated data with a Weibull function and get parameters back. The idea is that I ...
Lyam's user avatar
  • 145
0 votes
1 answer
87 views

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 ...
qmww987's user avatar
  • 133
2 votes
1 answer
89 views

I have a Pandas dataframe that looks like the following: Race_ID Date Student_ID feature1 1 1/1/2023 3 0.02167131 1 1/1/2023 4 ...
Ishigami's user avatar
  • 592

1
2 3 4 5
24