forum.alglib.net http://forum.alglib.net/ |
|
number of nodes set with spline2dbuildersetgrid() http://forum.alglib.net/viewtopic.php?f=2&t=3873 |
Page 1 of 1 |
Author: | frank [ Fri Dec 07, 2018 11:04 am ] |
Post subject: | number of nodes set with spline2dbuildersetgrid() |
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. |
Author: | Sergey.Bochkanov [ Mon Dec 10, 2018 10:44 am ] |
Post subject: | Re: number of nodes set with spline2dbuildersetgrid() |
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. |
Page 1 of 1 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |