# Nonlinear curve fitting with weights with LsqFit

**URL:** <https://discourse.julialang.org/t/nonlinear-curve-fitting-with-weights-with-lsqfit/78478>\
**Category:** General Usage\
**Tags:** question, package, curve-fitting, lsqfit\
**Created:** [March 25, 2022, 5:31pm UTC](https://discourse.julialang.org/t/nonlinear-curve-fitting-with-weights-with-lsqfit/78478 "2022-03-25T17:31:08Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [March 26, 2022, 11:06am UTC](https://discourse.julialang.org/t/nonlinear-curve-fitting-with-weights-with-lsqfit/78478/4 "2022-03-26T11:06:54Z")

</div>

Sorry, please provide a piece of code that is completely defined. I tried your code and get the message:

```julia

julia> @. model(t, p) = p[1]*(0.5)^(t/p[2])
model (generic function with 1 method)

julia> fit = curve_fit(model, x, y, weights, [0.1, 60])
ERROR: UndefVarError: x not defined
Stacktrace:
 [1] top-level scope
   @ REPL[3]:1

```

What are x, y and the weights?

> [@Please read: make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757):
>
> Welcome to the Julia Discourse! We are enthusiastic about helping Julia programmers, both beginner and experienced. This public service announcement (PSA) outlines best practices when asking for help. Following these points makes it easier for us to help you and more likely you’ll get a prompt, useful answer. Keywords are highlighted to make it easier to refer to specific points. Choose a descriptive title that captures the key part of your question, eg “plots with multiple axes” instead of …

In particular:  
"  
Do your best to make your example **self-contained** (“minimal working example”, **MWE** ), so that it runs (or gets to the error that you want help with) as is. This means including package loading (e.g. `using ThatPackage` ) and any **data** that the code operates on. If your data is large or proprietary, generate **example data** if possible and include that. [This StackOverflow answer](https://stackoverflow.com/questions/61723347/how-to-provide-reproducible-sample-data-in-julia/61724167#61724167) explains how a DataFrame can be turned into a string representation that can be copy/pasted.  
"

---

_[View the full topic](https://discourse.julialang.org/t/nonlinear-curve-fitting-with-weights-with-lsqfit/78478)._
