01-08-2009 11:36 AM
01-08-2009 11:54 AM - edited 01-08-2009 11:56 AM
You need to ensure that (x-b) is positive.
Quote from the help:
If x is not complex, it must be greater than zero unless y is an integer value. Otherwise, the result is NaN.
01-09-2009 02:37 AM
Glups! I didn't see that. Thanks a lot
01-09-2009 09:17 AM
Now I'm sure that (x-b) is positive. However I get another problem: if it works when I input a decimal number as an exponent, the fitting coefficients I get are now automatically equal to zero.
The good point is that I no longer get NaN but I'm not really satisfied with these new fitting coefficients. Do you have an idea?
01-09-2009 09:51 AM
nicoooooo wrote:if it works when I input a decimal number as an exponent, the fitting coefficients I get are now automatically equal to zero.
Well, if the fit with all zero parameters is the best possible solution you're fine. 🙂 I suspect that your initial parameter estimates are way off. You should always calculate and display the curve as calculated with the initial estimates. Does it look anything like the data? Does it have similar features?
Does the VI say it's coverged? Is there an error? How many iterations did it do?
If you don't mind, attach your VI and some typical data and I'll have a look.
01-12-2009 07:57 AM
Well, I don't think my initial parameters are the problem, because it works perfectly with a value of the exponent equal to 2 for example, but not for 2.1.
the vi computes 1000 iterations. Concerning the errors,for example if I input 1.7 I will get NaN for the coefficients and 0 for the error
If I input 1,7 as an exponent I get 0 for the coefficients but 23001 for the error.
I've attached two vis and somme typical data. I hope you will have a better idea than me
Thank you for your help
01-12-2009 11:39 AM
Ouch!
(Doing a simple fit should not requre a 10-frame stacked sequence, 20+ property nodes and local variables, 20+ sequence locals, and at least three greedy loops. All you probably need is a flat diagram the size of a postcard.)
Have you tried a decimal point instead of a comma in the model description?
Even with an exponent of 2, the fit is very poor. maybe you need to use better initial estimates?
01-13-2009 02:46 AM
I admit that a simple fit like this one should not require such a big machine. In fact I cut the sequel of the vi in order to make it a little bit more understandable (I know, I'a a beginner with Labview :). I'm sure it's possible to simplify it later.
Otherwise I've tried to use a decimal point or a comma in the model description and neither one nor the other works. It's true that even with an exponent of 2 the fit is poor but simply moving the cursor to a better place allows to better it.
I'll have a look on these greedy loops and on different guess coefficients.
Thanks
01-13-2009 10:48 AM
Sorry, I haven't had time to investigate further.
One of the probems is your ancient LabVIEW version. Starting with LabVIEW 8.0, the fitting tools have received significant improvements. Personally, I would always prefer the VI model, but that's not available pre-8.0 (at least not in an easy to use form). You only have very few parameters, so it should be easy to write a small program that interactively simulates the model curve so you can simply look at it while playing with the paramters. This should give you strong clues on what initial parameters to use.
Maybe I have time to look into this later this week.
01-15-2009 04:16 AM
Well I finally solved my problem. Instead of fitting a*(x-b)^1.7 to my data y, I've fitted 1.7*X+B to Ln(y), where X is equal to Ln(x-b) and B is equal to Ln(a).
The problem was that with this solution
at the end I could only get B, i.e a. Unfortunately, the data I really
wanted was b. So I integrated to the vi a for loop which made vary b
between two acceptable limits. Then for each value of b I actualised
the table of data (x-b) and I performed the levenberg-Marquardt vi
following the equation 1.7*X+B. To finish, the best b coefficient was
determined by finding the least mean square error performed in the loop
and by taking the corresponding best fit coefficient.
I hope I'm clear enough but I'm neither a regular english speaker nor an experienced programmer.