curve fitting toolbox: how to fit a multivariate b spline to data (regression)
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I have n d-dimensional vectors (input data) and n scalars as targets. I want to fit a multivariate b spline to this data using least squares, i.e. minimize
\sum_{i=1}^n f(x_i)-y_i^2,
where x_i=(x_i^(1),...x_i^(d)) is the i-th d-dimensional input-vector and y_i is my i-th target. I am aware of the function "spap2", where it works in the univariate case d=1, but in the multivariate case it only seems to run with gridded data. Is there a possibilty to make it work for random design as well?
Thanks in advance
0 commentaires
Réponses (1)
Unai San Miguel
le 2 Juil 2019
Modifié(e) : Unai San Miguel
le 2 Juil 2019
I think it is the same as for the d=1 case: you have to define a convenient knot sequence, and in turn a spline vector space, and find the spline function in that space that is closest to your data in the sense defined by the least square distance. This is what spap2 does, but it also provides you with a knot sequence if you don't define any.
So, you can start by choosing a knot sequence t and order k (I almost always use k = 4 and tend to forget it), looking for inspiration in the spap2 code, for example, that works well for your data. This is in general an iterative process: start with few knots and increase the number until you are satisfied with the result.
From the spap2 help page:
In the d > 1 case the process is similar, you have to choose 1d knot sequences for every dimension t1, t2, ..., td and use s = spap2({t1, t2, ..., td}, [k1, k2, ..., kd], x, y). If the results are not what you wanted (fnval(s, x) is very different from y), then refine some of the knot vectors and repeat.
You don't need your data x to be in a structured grid, what you need is that your model allows your data to having been generated by a tensor product (hyper)surface, plus maybe some noise.
I am wrong. Sorry, spap2 does not give the answer I thought it gave for d > 1. I guess you will have to preprocess the data somehow, maybe with what is explained here?
I thought it could be done the way I explained it above but now I realize that in my problems the data do have a grid-like structure, and the approximation process is done dimension by dimension.
0 commentaires
Voir également
Catégories
En savoir plus sur Spline Postprocessing dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!