LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

multivariate fitting issues

Hi there,
 
I found that Martin Fierz wrote a program in Labview to implement non negative general least square fitting. The program can be found at http://www.fierz.ch/physics.htm  or it can be downloaded from https://www.fiera.ch/LA_NNLSfit.zip
 
When I try this one to fit my signal (over 10 components for each signal), I got too many zeros (only 1 or 2 factors are not zero) which is not what I expected. I don't know the problem comes from the NNLS algorithm or the program needs some improvement?
 
I would appreciate it for those of you who are more familiar with Labview to give some help. Thank you.
 
Jan 
 
 
0 Kudos
Message 11 of 16
(1,092 Views)
Hi Jan,

Have you tried contacting Martin directly?  He's the author of the code, and even states in his readme file that it's not a perfect solution - he may be able to provide more effective insight into why the program doesn't behave as you're expecting than we can.  I gave the VI's a quick look and saw no glaring faults, though I must confess that I am not an expert in this particular algorithm.
Cheers,

Matt Pollock
National Instruments
0 Kudos
Message 12 of 16
(1,071 Views)


@bcvan wrote:
When I try this one to fit my signal (over 10 components for each signal), I got too many zeros (only 1 or 2 factors are not zero) which is not what I expected. I don't know the problem comes from the NNLS algorithm or the program needs some improvement?


Jan,
 
I had a quick glance at NNLS, and it seems to work just fine. One thing is the "max iter" control which defaults to zero and does not have a connector. This makes it not a good VI for a "drop-in" replacement for "solve linear equations". Currently, you need to keep the FP open and manually set this.
 
Increase the "maxiter" to e.g. 10 and things look better. I would recommend to set the default to something more reasonable in case it is not wired AND assign it a terminal so you can set the desired value from the calling program.
 
(One problem is also that Martin seems to love EXT precision, which is completely useless here because the LabVIEW matrix operations coerce back to DBL anyway. Change all terminals and diagram constant that are currently EXT to DBL and things are a bit more reasonable.)
 
I haven't studied the rest of the code, but it does seem to work. 🙂
0 Kudos
Message 13 of 16
(1,063 Views)
M. and A.,
 
Thanks so much for your comment and help.
 
Best,
Jan
0 Kudos
Message 14 of 16
(1,039 Views)
Thanks for pointing out that VI. After making the mentioned changes, I am actually using it for some of my analysis problems. 🙂
 
(Still, I think the code could be improved even more, it's a bit slow).
0 Kudos
Message 15 of 16
(1,034 Views)

Hi,

 

I have started using this code too and it works very well.

I have made the changes suggested by Altenbach and have also found the only downside is the time taken to complete the calculations.

In comparison the Matlab command.

On same data set LabVIEW ~ 55secs, Matlab <1sec.

 

Has anyone found a faster way of doing this?

 

One solution is to build a Matlab dll with the function embedded, install the Matlab runtime engine, write a C wrapper and call the function that way, but I'd rather do it natively in LabVIEW.

0 Kudos
Message 16 of 16
(758 Views)