# How to fit one parametric array to another numerical array?

I have two arrays of length n. One of them is obtained by experiment, so every element of

the array is a number. The other array is parametric, each element is a combination of a

parameter and numbers. There are 8 parameters. In theory, arrays one and two must be the same.

I want to find the best possible set of 8 parameters which fit the parametric array to the

experimental one.

How can I do that in Mathematica? FindFit needs an array and a function. I do not know how

to fit the two arrays.

I tried to subtract the two arrays and use NMinimize to minimum the new array with respect

to the parameters. It didn't work. It returns:

NMinimize::bcons: The following constraints are not valid: {0.004 -4 (E^(-

(0.002/Subscript[<<2>>])) Subscript[a, 1]+E^(-(0.002/Subscript[<<2>>])) Subscript[a,

2]+E^(-(0.002/Subscript[<<2>>])) Subscript[a, 3]+E^(-(0.002/Subscript[<<2>>]))

Subscript[a, 4]),4-4 (E^(-(0.002/Subscript[<<2>>])) Subscript[a, 1]+E^(-

(0.002/Subscript[<<2>>])) Subscript[a, 2]+E^(-(0.002/Subscript[<<2>>])) Subscript[a,

3]+E^(-(0.002/Subscript[<<2>>])) Subscript[a, 4]),<<48>>,<<1588>>}. Constraints should

be equalities, inequalities, or domain specifications involving the variables. >>


Mathematica thinks that the first argument of NMinimize contains some constraints, which

is not the case. It thinks so perhaps because the first argument cannot be an array.

-
Take a look at NMinimize. –  Kuba Mar 19 '14 at 13:19
I tried that. It didn't work. –  yashar Mar 19 '14 at 13:44
Please add the actual code and any data necessary to reproduce the problem. –  Yves Klett Mar 19 '14 at 14:19

For example:

experimArray = Range@20;
theoretArray = ListConvolve[{a, b, c, d, e}, Range@24]
sol = NMinimize[Norm[experimArray - theoretArray], {a, b, c, d, e}]


So:

theoretArray /. sol[[2]]
(*
{1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., 17., 18., 19., 20.}
*)

-