-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
Description
Hi,
for the data as shown in the example below, I get the following error if I try to fit well-behaved data with fit-order 2:
Error: LU matrix is singular
at LuDecomposition.solve (/home/damner/code/node_modules/ml-matrix/matrix.js:3201:13)
at solve (/home/damner/code/node_modules/ml-matrix/matrix.js:3977:43)
at regress (/home/damner/code/node_modules/ml-regression-polynomial/lib/index.js:174:45)
at new PolynomialRegression (/home/damner/code/node_modules/ml-regression-polynomial/lib/index.js:54:28)
The x-data is monotonous, the y-data looks like a noisy parabola. Matlab has no issue with fitting.
Any ideas, why this is failing?
- Removing first, second or last point solves issue.
- Changing the first x-value from 404.26220703125 to 404.26220703124 solves the issue. This happens for a couple elements, but not for all
- I guess it has something to do with the %.11f precision (which is not required, but just imported from .csv). But I do not just want to round the values, before I understood the problem.
- Currently, I do not know how to set breakpoints inside a module, so I did not look at the input for LuDecomposition.solve
Example:
const mlr = require('ml-regression-polynomial');
x = [404.26220703125, 404.27349853515625, 404.28448486328125, 404.29541015625, 404.3040771484375, 404.3128356933594, 404.3204040527344, 404.33154296875, 404.3409423828125, 404.3497314453125, 404.3594665527344, 404.36865234375, 404.37451171875, 404.3879699707031, 404.3951416015625, 404.40545654296875, 404.4149475097656, 404.4233703613281, 404.431884765625, 404.4431457519531, 404.4515686035156, 404.4609069824219, 404.4708251953125, 404.479248046875, 404.48883056640625, 404.4971923828125, 404.50799560546875, 404.5179443359375, 404.5263977050781, 404.5354919433594, 404.5458068847656, 404.5533447265625];
y = [0.3631210884030956, 0.38180362489729697, 0.391453923949123, 0.4037110236952629, 0.4163452490432181, 0.4288353165530643, 0.4430856652809317, 0.45358586770200177, 0.4562565407929964, 0.4650388402896439, 0.47573011091885675, 0.4837785283897874, 0.4905844679839888, 0.49022240374688425, 0.49039250930602896, 0.49193229796429716, 0.490495250991277, 0.504985674313608, 0.49096439100589284, 0.4781324538477614, 0.48063366656261153, 0.46976621057011786, 0.4587271348758588, 0.44576288402868225, 0.43918945480010974, 0.42895113530071644, 0.41687014727334876, 0.3938250656311999, 0.38222703735756586, 0.3651908364214456, 0.34985174702375216, 0.34842848544450433];
const regression = new mlr.PolynomialRegression(x, y, 2);
Thanks for your help.