# Least square minimisation to align points to a given function?

**URL:** <https://root-forum.cern.ch/t/least-square-minimisation-to-align-points-to-a-given-function/58323>\
**Category:** Newbie\
**Tags:** root\
**Created:** [February 28, 2024, 8:09am UTC](https://root-forum.cern.ch/t/least-square-minimisation-to-align-points-to-a-given-function/58323 "2024-02-28T08:09:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![utkarsh-2000](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/u/e47774/32.png) [@utkarsh-2000](https://root-forum.cern.ch/u/utkarsh-2000)\
**Post date:** [February 28, 2024, 8:09am UTC](https://root-forum.cern.ch/t/least-square-minimisation-to-align-points-to-a-given-function/58323/1 "2024-02-28T08:09:09Z")

</div>

Hi all,

I have a set of points (xi, yi) i ={1, 2. 3}  
I want to find the constant offset, y0 (xi, yi + y0), such that the points fit a given function f(xi).  
Basically, I am trying to minimize the residual, yi(xi) + y0 - f(xi).

I understand that this is a standard minimization problem, but as a naive user, I think the we usually fit a set of points to a curve, but the current problem is the reverse of that.

Are there any predefined functions for such minimization problems in general? Any help in his regard will be highly beneficial.

Thanks a lot !

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [February 28, 2024, 8:27am UTC](https://root-forum.cern.ch/t/least-square-minimisation-to-align-points-to-a-given-function/58323/2 "2024-02-28T08:27:28Z")

</div>

Hi,

If I understand correctly, you are looking for a best fit somehow (please correct me if I am wrong!).  
If I am right, an approach could be to change manually the value of the parameters of a function, via fitpanel or programmatically.

I hope this helps.

Cheers,  
D
