Hi all,
Great work on this code. However, I'm trying to use alglib.polynomialfit and I'm having difficulties.
Generally, it works very well. However, on some datasets, I have some issues. Some insight/help would be appreciated. I'm using C#.
I call it something like:
alglib.polynomialfitreport rr; double [] tm; // array of double's representing time - not equal intervals but sorted in increasing order double [] xa; // array of values representing 'x' (with error) at time tm[] int poly_degree; // always 2 or 3 or 4 int info; alglib.barycentricinterpolant xb; alglib.polynomialfit(tm, xa, polydegree, out info, out xb, out rr);
When I then want to generate data, I'm calling: alglib.barycentricdiff1(xb, t, out x, out slope);
Pretty standard stuff, I think. But occasionally, depending on parameter t, x will calculate to NaN, even though when you look at the dataset (via a grapher), it's a pretty simple curve between tm and xa that can easily be approximated with a 2 or 3 order polynomial equation. The value is either completely valid or NaN.
I had originally tried to call polynomialbar2pow() but it always gives me unreasonable results. polynomialpow2bar(), and polynomialbar2pow() seem to reasonable duals when I first start with a polynomial, but not in these instances.
My hunch is I am possibly using it incorrectly? Or possibly using the wrong routine to curve fit a polynomial through a set of points defined by (tm, xa)? Or is there a bug here? When it works 99% of the time, my gut says bug, but this is my first attempt playing with the package, too. Help would be appreciated!
Thanks,
--Rob
|