forum.alglib.net

ALGLIB forum
It is currently Wed Jun 26, 2019 10:36 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: number of nodes set with spline2dbuildersetgrid()
PostPosted: Fri Dec 07, 2018 11:04 am 
Offline

Joined: Fri Dec 07, 2018 10:14 am
Posts: 1
Hi,

Q0: What are the rules when setting number of nodes in spline2dbuildersetgrid() ?
Q1: What changes when I set different number of nodes in spline2dbuildersetgrid() ?
Q2: What changes when I set different number for X and Y nodes in spline2dbuildersetgrid() ?

This example
http://www.alglib.net/translator/man/manual.cpp.html#example_spline2d_fit_blocklls
sets 5 input points :
Code:
     real_2d_array xy = "[[-0.987,-0.902,0.359],[0.948,-0.992,0.347],[-1.000,1.000,0.333],[1.000,0.973,0.339],[0.017,0.180,0.968]]";

and grid of nodes is 5x5:
Code:
    spline2dbuildersetgrid(builder, 5, 5);


What would change if I set eg
Code:
    spline2dbuildersetgrid(builder, 50, 50);

or
Code:
    spline2dbuildersetgrid(builder, 5, 50);



Or, I have 5000 input samples and set
Code:
   spline2dbuildersetgrid(builder, 5, 5);


Thank you.


Top
 Profile  
 
 Post subject: Re: number of nodes set with spline2dbuildersetgrid()
PostPosted: Mon Dec 10, 2018 10:44 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 849
It is hard to have one-to-one correspondence between your answers and questions, so I give you a flat list:

1) the more nodes you have, the more flexible model you have. A model with K nodes in some direction can perform at most K "zigzags" in this direction, and in real life you need 4x-6x times more nodes than you have "zigzags".

Say, if you want to approximate y=sin(x) for x in [0,2pi], then you need a grid with at least 5 nodes which will cover key points of the function (extremal points and zeros). But 10 nodes is much better because you can not be 100% sure that equidistant grid will place its nodes exactly to the right points. Same applied to 2D problems.

The general rule is that you should know what flexibility you require from the spline. ALGLIB can not determine right number of nodes for you. But you can experiment with different nodes count until you are satisfied.

2) From the other side, the more nodes you have, the harder is to solve LLS problem. Our spline fitting subroutine is orders of magnitude faster than straightforward linear least squares solver, but anyway - the more nodes, the more time.

3) when you set nodes count, it is silently remembered. Next call to spline2dfit() will result in the model constructed with at least as many nodes as you specified (ALGLIB may decide to add a few more nodes to handle some internal issues).

4) you can set different nodes count if you have dataset with different spans for X and Y dimensions, or you simply need different flexibility for different dimensions.

Say, if your points are spread within 100meters x 1000meters rectangle, you can specify KX=50 nodes for dimension #0 and KY=10*KX nodes for dimension #1.


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: Google [Bot] 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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group