I have defined a few basic real functions that accept integer arguments only. I tried to use my basic functions to fit decimal data. But it keep saying that: “Unable to solve for the fit parameters; the design matrix is nonrectangular, non-numerical, or could not be inverted.”
I figured out a work-around: to allow my basic functions to accept decimal values. But I really like to keep the basic functions ‘pure’ with integer input only. I have attached a picture to explain the issue.
The example is simplified: fit 4 points (1,1), (2,1), (3,1) and (4,1) using sin^2(x) and cos^2(x). The answer is obviously:
1 * sin^2(x) + 1* cos^2(x).
In example 1, I defined sin^2 and cos^2 to accept integer arguments only. The FindFit worked as expected.
In example 2, I used decimals y=1.0 for one of the point. The FindFit failed.
In example 3, I allowed sin^2 and cos^2 to accept real numbers. Now FindFit worked again.
The strange thing is: the integral argument is about x-coordinates; yet FindFit failed when y-coord is not integer. Why would the fitting algorithm insists lattice points (integer x and y) if x has to be 1,2,3,4,5,…?
This behavior seemed a ‘bug’ to me. Because, in my real example, my basic functions are real, they produce decimal numbers, But I have good reason to restrict the arguments to integers only. I don’t want to throw away the “n_Integer” tag in the argument.
