Can MATLAB find a function that generated a random set of points?
Show older comments
Hi I'm new with MATLAB. I have a random function that generates 1000 points (x,y). If I only have those points, how can I get the function that generated those random points (x,y)?
2 Comments
Azzi Abdelmalek
on 22 Jul 2016
The question is not clear, especially when you say:If I only have those points
Answers (1)
John D'Errico
on 22 Jul 2016
In general, no, you cannot find the underlying function. In fact, there are infinitely many functions that will pass through a given set of points. How should MATLAB know which of those functions apply to this set of points?
For example, suppose I choose 3 points.
x = [0 1 2];
y1 = exp(x) + x.^3 - 3*x.^2 + 2*x;
y2 = exp(x);
As it turns out, the polynomial part there is zero on the point set [0,1,2]. So if you have only function values at those three points, then MATLAB could not possibly know which expression was used to generate either y1 or y2.
Again, there are infinitely many "functions" that will pass through any set of points. In order to estimate a model, the analyst needs to pose some model family that will apply. If you are unwilling to provide any input on the question, then a spline interpolant is generally your best choice.
Categories
Find more on Random Number Generation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!