# \#curve-fitting

**URL:** https://discourse.julialang.org/tag/curve-fitting/314.md

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

---

## [ScientificFitting.jl v0.1: explicit uncertainties, diagnostics, profiles, and Makie figures](https://discourse.julialang.org/t/scientificfitting-jl-v0-1-explicit-uncertainties-diagnostics-profiles-and-makie-figures/139223)

<div class="topic-metadata">

**Author:** [@Amin-El-Sayed](https://discourse.julialang.org/u/Amin-El-Sayed)\
**Replies:** 2\
**Last updated:** [September 10, 2026, 12:24pm UTC](https://discourse.julialang.org/t/scientificfitting-jl-v0-1-explicit-uncertainties-diagnostics-profiles-and-makie-figures/139223 "2026-09-10T12:24:21Z")

</div>

Hi everyone, I’ve just released ScientificFitting.jl v0.1, my first public Julia package. It aims to make statistically careful scientific fitting fast to write and enjoyable to use, without hiding uncertainty models or…

---

## [Parameter estimation in mathematical models of common functions (sine, cos, exp and other special functions)](https://discourse.julialang.org/t/parameter-estimation-in-mathematical-models-of-common-functions-sine-cos-exp-and-other-special-functions/130325)

<div class="topic-metadata">

**Author:** [@Geegee](https://discourse.julialang.org/u/Geegee)\
**Replies:** 15\
**Last updated:** [August 28, 2025, 10:25am UTC](https://discourse.julialang.org/t/parameter-estimation-in-mathematical-models-of-common-functions-sine-cos-exp-and-other-special-functions/130325 "2025-08-28T10:25:44Z")

</div>

Hello all glad to have arrived here. I have recently picked up Julia, but am quite excited about it! I have many data sets that follow the same model but the parameters change widely from dataset to dataset. In our la…

---

## [Best-fit parameter error bar using Optimization.jl?](https://discourse.julialang.org/t/best-fit-parameter-error-bar-using-optimization-jl/103186)

<div class="topic-metadata">

**Author:** [@abehersan](https://discourse.julialang.org/u/abehersan)\
**Replies:** 18\
**Last updated:** [July 2, 2025, 10:18pm UTC](https://discourse.julialang.org/t/best-fit-parameter-error-bar-using-optimization-jl/103186 "2025-07-02T22:18:01Z")

</div>

Specifically in the context of local solvers with and without constraints. What is the standard way people report error bars on fitting parameters while using Optimization.jl? In principle this can be calculated if the…

---

## [Is \`LsqFit.jl\` abandoned?](https://discourse.julialang.org/t/is-lsqfit-jl-abandoned/125192)

<div class="topic-metadata">

**Author:** [@cocoa1231](https://discourse.julialang.org/u/cocoa1231)\
**Replies:** 2\
**Last updated:** [January 25, 2025, 6:03pm UTC](https://discourse.julialang.org/t/is-lsqfit-jl-abandoned/125192 "2025-01-25T18:03:28Z")

</div>

As the title says, is the package abandoned? There’s PRs that go back to 2020. Is LsqFit.jl no longer maintained? If so what’s the preferred way to do curve fitting similar to scipy.optimize.curve\_fit?

---

## [Replicating power law distribution](https://discourse.julialang.org/t/replicating-power-law-distribution/125021)

<div class="topic-metadata">

**Author:** [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Replies:** 4\
**Last updated:** [January 21, 2025, 10:24pm UTC](https://discourse.julialang.org/t/replicating-power-law-distribution/125021 "2025-01-21T22:24:08Z")

</div>

Hi, I am trying to generate a power law degree distribution using barabasi\_albert from Graphs.jl. I am having trouble replicating the figure 4 on page 7 of this resource. Please forgive me in advance if I am doing somet…

---

## [Curve fitting with NonlinearSolve.jl](https://discourse.julialang.org/t/curve-fitting-with-nonlinearsolve-jl/119238)

<div class="topic-metadata">

**Author:** [@garrek](https://discourse.julialang.org/u/garrek)\
**Replies:** 9\
**Last updated:** [December 24, 2024, 1:34am UTC](https://discourse.julialang.org/t/curve-fitting-with-nonlinearsolve-jl/119238 "2024-12-24T01:34:14Z")

</div>

I am trying to familiarize myself with the NonlinearSolve ecosystem for curve fitting and am having difficulty getting a simple fit to an exponential function. I have seen other discussions on doing this here, but I’m no…

---

## [How to fit a function to measurements with error?](https://discourse.julialang.org/t/how-to-fit-a-function-to-measurements-with-error/65369)

<div class="topic-metadata">

**Author:** [@DaWa](https://discourse.julialang.org/u/DaWa)\
**Replies:** 12\
**Last updated:** [September 8, 2024, 8:28pm UTC](https://discourse.julialang.org/t/how-to-fit-a-function-to-measurements-with-error/65369 "2024-09-08T20:28:27Z")

</div>

Hi all, I am currently using Measurements.jl for error propagation and LsqFit.jl for fitting functions to data. Is there a simple way to fit a function to data with errors? It would be no problem to use an other package…

---

## [Fitting gaussian to spectral data has unexpected results](https://discourse.julialang.org/t/fitting-gaussian-to-spectral-data-has-unexpected-results/118961)

<div class="topic-metadata">

**Author:** [@Amnesian](https://discourse.julialang.org/u/Amnesian)\
**Replies:** 3\
**Last updated:** [September 4, 2024, 11:58am UTC](https://discourse.julialang.org/t/fitting-gaussian-to-spectral-data-has-unexpected-results/118961 "2024-09-04T11:58:54Z")

</div>

My data Trying to fit a gaussian (not Normal, because it has arbitrary amplitude) on a peak in my data produces very bad parameter values. Expected should be close to my initial guesses, but it outputs \[14936.1701885188…

---

## [Moving Horizon Estimation](https://discourse.julialang.org/t/moving-horizon-estimation/115921)

<div class="topic-metadata">

**Author:** [@MarcoDellOro](https://discourse.julialang.org/u/MarcoDellOro)\
**Replies:** 8\
**Last updated:** [June 24, 2024, 11:39am UTC](https://discourse.julialang.org/t/moving-horizon-estimation/115921 "2024-06-24T11:39:08Z")

</div>

Hello everybody, I am having some issues with the Moving Horizon Estimation (MHE) code I am writing. To me, the task and the code seem quite easy, but I cannot obtain the desired results for some reason. I attach here …

---

## [Linear/Poly Fit on a set of data](https://discourse.julialang.org/t/linear-poly-fit-on-a-set-of-data/114168)

<div class="topic-metadata">

**Author:** [@S\_Han](https://discourse.julialang.org/u/S_Han)\
**Replies:** 4\
**Last updated:** [May 12, 2024, 8:52pm UTC](https://discourse.julialang.org/t/linear-poly-fit-on-a-set-of-data/114168 "2024-05-12T20:52:29Z")

</div>

HI I’m trying to fit a curve on this dataset. im using CurveFit.curve\_fit() to find a linear/poly fit to this dataset. However, when I am using Polynomial, fit = CurveFit.curve\_fit(Polynomial,gamma\_k\[1:21\],tau\_opt\[1…

---

## [Curvefit using nonlinearsolve](https://discourse.julialang.org/t/curvefit-using-nonlinearsolve/114076)

<div class="topic-metadata">

**Author:** [@Stephen](https://discourse.julialang.org/u/Stephen)\
**Replies:** 2\
**Last updated:** [May 10, 2024, 8:29am UTC](https://discourse.julialang.org/t/curvefit-using-nonlinearsolve/114076 "2024-05-10T08:29:01Z")

</div>

Com-langmuir model: qi = Hi \* Ci / (1 + Σ(bi \* Ci) i = 2, q and C was obtained from experiment, here is the data df: Column 1 Column 2 Column 3 Column 4 C\_EA C\_EC q\_EA\_303K q\_EC\_303K 3.46 0.34 7 0.51 5.19 0…

---

## [Multi variables in lsqfit](https://discourse.julialang.org/t/multi-variables-in-lsqfit/112210)

<div class="topic-metadata">

**Author:** [@Stephen](https://discourse.julialang.org/u/Stephen)\
**Replies:** 6\
**Last updated:** [May 1, 2024, 2:08am UTC](https://discourse.julialang.org/t/multi-variables-in-lsqfit/112210 "2024-05-01T02:08:27Z")

</div>

using XLSX, DataFrames, LsqFit df = DataFrame(XLSX.readtable("SMB.xlsx","平衡吸附量", infer\_eltypes = true)) function Com\_Langmuir(p, x) Ha, bA, bC, Hc = p CA = @view x\[:, 1\] CC = @view x\[:, 2\] @. qA = Ha\*CA…

---

## [Parameter bounds and confidence intervals in LsqFit.jl?](https://discourse.julialang.org/t/parameter-bounds-and-confidence-intervals-in-lsqfit-jl/113366)

<div class="topic-metadata">

**Author:** [@PeX](https://discourse.julialang.org/u/PeX)\
**Replies:** 1\
**Last updated:** [April 23, 2024, 7:40am UTC](https://discourse.julialang.org/t/parameter-bounds-and-confidence-intervals-in-lsqfit-jl/113366 "2024-04-23T07:40:03Z")

</div>

HI all, I’m trying to use LsqFit.jl to fit a model in the form of: model(t, p) = @. p\[1\] \* t^3 + p\[2\] \* t + p\[5\]\*sin(2\*π\*p\[3\]\*t + p\[4\]) However, I need p\[4\] to be strictly between 0 and pi. Is it possible to do it? I…

---

## [Least square with multi-value function](https://discourse.julialang.org/t/least-square-with-multi-value-function/47943)

<div class="topic-metadata">

**Author:** [@Bernard\_GODARD](https://discourse.julialang.org/u/Bernard_GODARD)\
**Replies:** 3\
**Last updated:** [March 28, 2024, 4:33am UTC](https://discourse.julialang.org/t/least-square-with-multi-value-function/47943 "2024-03-28T04:33:46Z")

</div>

I have a model which takes 3 independent variables, 4 parameters and returns 2 values. I am trying to fit the parameters to a certain dataset. LsqFit does not seem to like multivalues function but maybe I am not using …

---

## [Lsqfit Nonlinear Regression Using Two Parameters: One Parameter Is Stuck At The Initial Parameter Value](https://discourse.julialang.org/t/lsqfit-nonlinear-regression-using-two-parameters-one-parameter-is-stuck-at-the-initial-parameter-value/108001)

<div class="topic-metadata">

**Author:** [@HNormanW](https://discourse.julialang.org/u/HNormanW)\
**Replies:** 0\
**Last updated:** [December 24, 2023, 8:53am UTC](https://discourse.julialang.org/t/lsqfit-nonlinear-regression-using-two-parameters-one-parameter-is-stuck-at-the-initial-parameter-value/108001 "2023-12-24T08:53:48Z")

</div>

Hi, I’m trying to run a nonlinear regression fit for a perturbation function, but it seems to only fit one of my two parameters. The perturbation function is for modeling grating efficacy curves, with wavelength as the …

---

## [Alternatives to LsqFit for nonlinear curve fitting?](https://discourse.julialang.org/t/alternatives-to-lsqfit-for-nonlinear-curve-fitting/107685)

<div class="topic-metadata">

**Author:** [@PeX](https://discourse.julialang.org/u/PeX)\
**Replies:** 12\
**Last updated:** [December 21, 2023, 4:48pm UTC](https://discourse.julialang.org/t/alternatives-to-lsqfit-for-nonlinear-curve-fitting/107685 "2023-12-21T16:48:52Z")

</div>

Hi! I’m trying to use Julia to make a curve fit with the functional form: model = ( p\[1\] / x ) \* exp( -p\[2\] / x ) to a data-set I have. I tried LsqFit, however, if I’m not making really good initial guesses for the p…

---

## [Calculating angular velocity using incremental encoder data](https://discourse.julialang.org/t/calculating-angular-velocity-using-incremental-encoder-data/105180)

<div class="topic-metadata">

**Author:** [@thomasj](https://discourse.julialang.org/u/thomasj)\
**Replies:** 4\
**Last updated:** [November 22, 2023, 6:18am UTC](https://discourse.julialang.org/t/calculating-angular-velocity-using-incremental-encoder-data/105180 "2023-11-22T06:18:43Z")

</div>

I’m trying to measure the angular velocity of a rotating shaft using an encoder. An encoder delivers the angular position at certain time. If the time is known you can in theory calculate the angular velocity by dividi…

---

## [Modeling with a spline a signal peak's shape from multiple datasets that captured the same event](https://discourse.julialang.org/t/modeling-with-a-spline-a-signal-peaks-shape-from-multiple-datasets-that-captured-the-same-event/104795)

<div class="topic-metadata">

**Author:** [@oniehuis](https://discourse.julialang.org/u/oniehuis)\
**Replies:** 7\
**Last updated:** [October 23, 2023, 9:00am UTC](https://discourse.julialang.org/t/modeling-with-a-spline-a-signal-peaks-shape-from-multiple-datasets-that-captured-the-same-event/104795 "2023-10-23T09:00:46Z")

</div>

I have time series data in which the recorded values capture a signal (i.e., peak) that emerges from an elevated noise floor (i.e., baseline; can be modeled as a straight line). The shape of the peak in the various time …

---

## [\[ANN\] LinearSegmentation.jl: segmented linear regression](https://discourse.julialang.org/t/ann-linearsegmentation-jl-segmented-linear-regression/101248)

<div class="topic-metadata">

**Author:** [@Elmo](https://discourse.julialang.org/u/Elmo)\
**Replies:** 7\
**Last updated:** [September 15, 2023, 7:50pm UTC](https://discourse.julialang.org/t/ann-linearsegmentation-jl-segmented-linear-regression/101248 "2023-09-15T19:50:35Z")

</div>

I have made a small package that does segmented linear regression, i.e. it fits piecewise linear functions to data and automatically identifies the optimal break points, see the readme for more details: LinearSegmentatio…

---

## [Custom nonlinear curve fitting package?](https://discourse.julialang.org/t/custom-nonlinear-curve-fitting-package/103468)

<div class="topic-metadata">

**Author:** [@PeX](https://discourse.julialang.org/u/PeX)\
**Replies:** 1\
**Last updated:** [September 2, 2023, 10:31pm UTC](https://discourse.julialang.org/t/custom-nonlinear-curve-fitting-package/103468 "2023-09-02T22:31:34Z")

</div>

Hi all! I have a dataset that I want to fit a function to in the form of: y = a x^4 + b x^3 + c x^2 + dx + e + f sin(gx + h) I was trying to use LsqFit.jl , but the results are not great (unless I guess the parameters…

---

## [How to use the 'LsqFit.curve\_fit'?](https://discourse.julialang.org/t/how-to-use-the-lsqfit-curve-fit/97546)

<div class="topic-metadata">

**Author:** [@manu\_han](https://discourse.julialang.org/u/manu_han)\
**Replies:** 0\
**Last updated:** [April 16, 2023, 2:18pm UTC](https://discourse.julialang.org/t/how-to-use-the-lsqfit-curve-fit/97546 "2023-04-16T14:18:59Z")

</div>

To fit the non-linear function with other data, I am trying to use the ‘LsqFit.curve\_fit’ which was introduced by the following link: GitHub - JuliaNLSolvers/LsqFit.jl: Simple curve fitting in Julia here is toy example: …

---

## [How to find equation when i have points?](https://discourse.julialang.org/t/how-to-find-equation-when-i-have-points/96240)

<div class="topic-metadata">

**Author:** [@Sergey\_Novak](https://discourse.julialang.org/u/Sergey_Novak)\
**Replies:** 7\
**Last updated:** [March 17, 2023, 2:31pm UTC](https://discourse.julialang.org/t/how-to-find-equation-when-i-have-points/96240 "2023-03-17T14:31:51Z")

</div>

I have points and need to get equation of these points. I try to use wolfram and another online services and all result is bad.

---

## [\[ANN\] Package for sinusoidal regressions](https://discourse.julialang.org/t/ann-package-for-sinusoidal-regressions/95703)

<div class="topic-metadata">

**Author:** [@mbaz](https://discourse.julialang.org/u/mbaz)\
**Replies:** 0\
**Last updated:** [March 7, 2023, 11:17pm UTC](https://discourse.julialang.org/t/ann-package-for-sinusoidal-regressions/95703 "2023-03-07T23:17:54Z")

</div>

SinusoidalRegressions.jl is a package that focuses on fitting data to sinusoidal models. Source and docs. It has been submitted to the general registry but it’s on the 3-day waiting period. Main features are: Implement…

---

## [Piecewise-constant fitting](https://discourse.julialang.org/t/piecewise-constant-fitting/94091)

<div class="topic-metadata">

**Author:** [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Replies:** 21\
**Last updated:** [February 9, 2023, 12:40am UTC](https://discourse.julialang.org/t/piecewise-constant-fitting/94091 "2023-02-09T00:40:42Z")

</div>

Is there an example or a Julia package for piecewise-constant fitting of 1D series? See a Matlab example of expected results here. Thanks.

---

## [How to fit a polynomial with a pre-determined degree to a set of points?](https://discourse.julialang.org/t/how-to-fit-a-polynomial-with-a-pre-determined-degree-to-a-set-of-points/91981)

<div class="topic-metadata">

**Author:** [@Hugo](https://discourse.julialang.org/u/Hugo)\
**Replies:** 7\
**Last updated:** [December 27, 2022, 7:44pm UTC](https://discourse.julialang.org/t/how-to-fit-a-polynomial-with-a-pre-determined-degree-to-a-set-of-points/91981 "2022-12-27T19:44:06Z")

</div>

Hi, all I want to approximate a function to a vector v of 99 values so I can evaluate that function over other values. This can be a simple linear interpolation of the 99 values, but I’d fit a polynomial in case other v…

---

## [Using LsqFit on complex data](https://discourse.julialang.org/t/using-lsqfit-on-complex-data/79620)

<div class="topic-metadata">

**Author:** [@PazzyBoardman449](https://discourse.julialang.org/u/PazzyBoardman449)\
**Replies:** 7\
**Last updated:** [December 15, 2022, 7:32am UTC](https://discourse.julialang.org/t/using-lsqfit-on-complex-data/79620 "2022-12-15T07:32:30Z")

</div>

I’m trying to use LsqFit.jl to fit data that is complex (in the form x + im\*y). For purposes of showing the problem, I’m using the example provided on GitHub for LsqFit but I’m changing the model such that it has an imag…

---

## [Python lmfit takes weights into account, but Julia LsqFit package seems not to](https://discourse.julialang.org/t/python-lmfit-takes-weights-into-account-but-julia-lsqfit-package-seems-not-to/90679)

<div class="topic-metadata">

**Author:** [@humbleclaw](https://discourse.julialang.org/u/humbleclaw)\
**Replies:** 9\
**Last updated:** [November 23, 2022, 11:26pm UTC](https://discourse.julialang.org/t/python-lmfit-takes-weights-into-account-but-julia-lsqfit-package-seems-not-to/90679 "2022-11-23T23:26:35Z")

</div>

Hello everyone. Using Python I have been able to do non-linear fits with lmfit creating a residual function for a potential mathematical function to fit, just as follows def pow\_res(pars, E, data, sig): values = p…

---

## [How do I get lower and upper bounds for a confidence band using LsqFit.jl?](https://discourse.julialang.org/t/how-do-i-get-lower-and-upper-bounds-for-a-confidence-band-using-lsqfit-jl/88519)

<div class="topic-metadata">

**Author:** [@ultrapoci](https://discourse.julialang.org/u/ultrapoci)\
**Replies:** 8\
**Last updated:** [October 11, 2022, 5:00pm UTC](https://discourse.julialang.org/t/how-do-i-get-lower-and-upper-bounds-for-a-confidence-band-using-lsqfit-jl/88519 "2022-10-11T17:00:04Z")

</div>

I’m fitting a three parameters non-linear function using LsqFit.jl. I know I can get confidence intervals using confidence\_interval(fit), but how do I actually get lower and upper bound for the confidence band? I believe…

---

## [How do I use LsqFit to fit points with an associated error?](https://discourse.julialang.org/t/how-do-i-use-lsqfit-to-fit-points-with-an-associated-error/88291)

<div class="topic-metadata">

**Author:** [@ultrapoci](https://discourse.julialang.org/u/ultrapoci)\
**Replies:** 2\
**Last updated:** [October 5, 2022, 8:32pm UTC](https://discourse.julialang.org/t/how-do-i-use-lsqfit-to-fit-points-with-an-associated-error/88291 "2022-10-05T20:32:07Z")

</div>

I have these points I want to fit: x y err 24.0 0.0386341 4.29118e-5 24.33 0.03952 2.10541e-5 24.66 0.0398329 1.76137e-5 25.0 0.0399503 1.75643e-5 25.33 0.0399654 1.63191e-5 25.66 0.0398724 …

---

## [Quadratic (paraboloid) model fitting](https://discourse.julialang.org/t/quadratic-paraboloid-model-fitting/88007)

<div class="topic-metadata">

**Author:** [@bertulli](https://discourse.julialang.org/u/bertulli)\
**Replies:** 0\
**Last updated:** [September 29, 2022, 7:37pm UTC](https://discourse.julialang.org/t/quadratic-paraboloid-model-fitting/88007 "2022-09-29T19:37:47Z")

</div>

Hi, this is a off-branch topic from this other thread of mine about multiple linear regression. This is not the solution to the original question, but I thought it’s useful, so I’m making a recap here. Turned out, linea…

[Next page](https://discourse.julialang.org/tag/curve-fitting/314.md?match_all_tags=true&page=1&tags%5B%5D=curve-fitting)
