# Minimizing chi-squared to find unknown value of parameters

X=
Sum[(events[[i]] - f[x, a, b])^2/
events[[i]], {i, 1, 40}]


I want to minimize X to find the value of a and b. How will i do it?

• Look at FindFit, NonlinearModelFit, and related functions. – Bob Hanlon Aug 31 '18 at 17:30
• You're not using the usual chi-square statistic. The denominator ought to be the "expected value" which I assume is f[a, a, b] (with the observed counts being events). In other words, what happens when events[[i]] == 0 and f[x, a, b] > 0 ? – JimB Sep 13 '18 at 13:13

Do not write the function definition, write the real function and summation would also include x. Then use the function FindMinimum[X,{a,b}]