Skip to main content
1 of 5

Numerical Integration as Model for Nonlinear Fit

I'm trying to do a fit for parameters of a function within an integral but I'm getting errors when I try and run it. Essentially I want the following fit to work out:

model[a_, b_, x_] := Sum[NIntegrate[totalvLayer[p, m] (a (1 - b^-p)),{p, 0.2, 10}], {m, x - .45, x + .45, .02}]

nlm = NonlinearModelFit[data, model[a, b, x], {a,b}, x, Weights -> 1/errors^2]

Where totalvLayer is a function I defined earlier. I just want the fit values for a and b and their covariance matrix, but I'm clearly doing something wrong. Any help is much appreciated!