forum.alglib.net

ALGLIB forum
It is currently Mon Mar 30, 2020 3:34 pm

All times are UTC


Forum rules


1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: spline1dfit - diverges at dataset edges
PostPosted: Wed Feb 05, 2020 4:08 am 
Offline

Joined: Wed Feb 05, 2020 3:54 am
Posts: 2
I'm using alglib's spline1dfit function to smooth some noisy analog electrical signals for characterization purposes. The fitting works very well along the entire window of input data except for at the edges. Check out the attached picture, which shows the spline diverging from the last few data points in both signals.

Here's my C++ code for performing the fit:

Code:
void denoiser::process(const QVector<double> &input_signal, QVector<double> &output_signal)

    // Set up X and Y arrays
    alglib::real_1d_array x, y;

    // Populate x array.
    x.setlength(input_signal.size());
    for(int32_t i = 0; i < input_signal.size(); i++)
    {
        x[i] = i;
    }

    // Attach y array to input signal data (shares pointer so no copying)
    y.attach_to_ptr(input_signal.size(), const_cast<double*>(input_signal.data()));

    // Set up spline interpolant and fit report structures to capture output.
    alglib::spline1dinterpolant interpolant;
    alglib::spline1dfitreport fit_report;

    // Perform fitting.
    alglib::spline1dfit(x, y, x.length(), 10*x.length(), denoiser::lambda, interpolant, fit_report);

    // Populate output with fitted spline.
    output_signal.clear();
    output_signal.reserve(input_signal.size());
    for(int32_t i = 0; i < input_signal.size(); i++)
    {
        output_signal.append(alglib::spline1dcalc(interpolant, i));
    }
}


The typical data length (N) is between 100 and 500 data points. I've tried using all kinds of values of M, including M = 0.1*N through M = 10*N. It has no effect on the divergence of the spline at the beginning/end of the window. I'm using a lambda of 0.0001.

It seems like spline1dfit is simply ignoring the first/last few points when performing the fit, even though I've specified N.

Anybody have any ideas on what might be going on here? Thanks!


Attachments:
spline_fit.png
spline_fit.png [ 9.71 KiB | Viewed 199 times ]
Top
 Profile  
 
 Post subject: Re: spline1dfit - diverges at dataset edges
PostPosted: Mon Mar 02, 2020 7:48 pm 
Offline

Joined: Wed Feb 05, 2020 3:54 am
Posts: 2
bump... anybody having similar experiences or know what might be causing the issue?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group