# Tag: curve-fitting

## fit multiple parametric curves with scipy python

I am trying to fit two curve into one equation. y = (a * exp(b * (T^-1)))cexp(d100)(x^0.5) for y1, T =10, for y2, T =25. how do a get a,b,c,d I have a code that simplified to fit one data. I don’t know how to do both. I find a similar question with solution but I can’t follow.. fit multiple

## How to add x offset to LMFIT models

i am trying to use LMFIT to fit a power law model of the form y ~ a (x-x0)^b + d. I used the built in models which exclude the parameter x0: DATA Data Plot: This brings up an error because my data starts at about x = 57000. I was initially offsetting my x-axis by x-57923.24 for all x

## Plotting the decay envelope for dampening function without the usual “fit with a decaying sinusoidal first” method?

To be more clear, by the decay rate of a dampening function I mean fitting the exponential curve to the amplitude of the damped oscillations and see how it decays. Something like the following : Damped Sine wave but for my graph which is certainly not smooth like the above and whose picture I still cannot upload due to my

## Curve_Fit returrns error “Result from function Call is not a proper array of floats”

I am trying to call scipy curve_fit(), with the proper: model function xdata (float numpy 1D Array) ydata (float numpy 1D Array) p (float numpy 1D Array, initial values) However I am getting the error: ValueError: Object too deep for desired Array Result from function Call is not a proper array of floats. the model function I am computing is

## curve fitting sine to the power of python

I want to fit a signal into a cos or sine function: reference signal: And this signal must fit into model: By doing: I am getting: params a = 11.9; b = 0.97 and n=1 This doesn’t match at all… Answer putting these suggestions together gives the following: which recovers your parameters. the bounds enforces positivity, while the p0 gives

## How to implement a constrained linear fit in Python?

I’m trying to fit a linear model to a set of data, with the constraint that all the residuals (model – data) are positive – in other words, the model should be the “best overestimate”. Without this constraint, linear models can be easily found with numpy’s polyfit as shown below. example1 Is there an efficient way to implement a linear

## Gaussian curve fitting in physics

I have this data, I tried to fit by a Gaussian function but I can’t found an appropriate function, I tried using curve_fit from scipy.optimize : I used this code : this is the result of this fit : Very bad fit The error message : Answer First, you’re not fitting a Gaussian function, you’re fitting the sum of a

## Two parameter non-linear function for modeling a 3-D surface

I’m interested in modeling this surface with a simple equation that takes in two parameters (x,y) values and produces a z value. Ideally an equation that has a simple form. I have tried Monkey Saddle, …

## Fitting data to a complementary error function with multiple variables in Python

I am having trouble to fit experimental data to a complementary error function in Python 3.7.4. import matplotlib.pyplot as plt import math import numpy as np from scipy import optimize from scipy …

## How to write a function to fit data to a sum of N Gaussian-like peaks without explicitly defining the expression for every possible N?

I am trying to fit a progression of Gaussian peaks to a spectral lineshape. The progression is a summation of N evenly spaced Gaussian peaks. When coded as a function, the formula for N=1 looks like …