Fitting a function with weight?

I have an histogram which I want to fit to a linear function. However, the points at the extremities of the histogram are a lot less relevant than the points at the middle. For the fit, how can I give more weight to the points in the middle ? I already know what weight to give to each point, I just don’t know how to give them a weight that will be used for the fitting procedure.

Thank you

Assign errors to each bin. The larger the errors the smaller the weight (usually weight=1/sigma^2). In fact I understand that the values at the extremities have much larger uncertainty = less relevant :question:



Yes, you must assign errors to your bins via TH1::SetBinError(bin).
To exclude a bin, set its error to 0.
By default errors are sqrt(bin content).
You can also specify equal weights by giving the fit option “w”