Effacer les filtres
Effacer les filtres

Does MATLAB have any toolboxes or commands for predicting the next number in a series?

5 vues (au cours des 30 derniers jours)
Alex
Alex le 18 Mar 2017
Commenté : Greg Heath le 2 Avr 2017
I have a data series x as a function of time y:
x=[14,14,3,4,8,3,2,5,11,2,1,5,10,2,4,1,8,11,5,1,3,1,2;]
y=1:1:23
How do I predict the next number (x,y=24)? Does MATLAB have any toolboxes for that type of problem or will I need to code something like a neural network solution from scratch?
Cheers
  1 commentaire
Greg Heath
Greg Heath le 2 Avr 2017
Why in the world are you using x(y) instead of the worldwide timetested standard y(x)?
Dizzily,
Greg

Connectez-vous pour commenter.

Réponses (3)

Jan
Jan le 27 Mar 2017
Modifié(e) : Jan le 27 Mar 2017
19.
Carl E. Linderholm showed, that any sequence of numbers can be continued by 19. It is easy to construct a corresponding Lagrange polynomial p(x) such that p(1), p(2), ... p(n) yields the given numbers and p(n+1) is 19. This rule is much easier than all other rules and is applies in general.
Of course you could use your favorite number also. But then this gives psychologists the chance to interpret your subconsciousness. So better choose 19 (and do not tell anybody if this is your favorite number).
See http://www.whydomath.org/Reading_Room_Material/ian_stewart/9505.html (they claim it was a Laplace interpolation - fortunately the law is such universal, that this detail does not matter.)
  1 commentaire
Image Analyst
Image Analyst le 1 Avr 2017
I totally agree with Jan. In fact there was a controversy some years ago about using such "predict the next number" questions on college entrance exams because virtually any number (any one of their choices) could be an answer using some formula. You can't really say any of the numbers is right and all the rest are wrong.

Connectez-vous pour commenter.


John D'Errico
John D'Errico le 18 Mar 2017
Modifié(e) : John D'Errico le 18 Mar 2017
There is no reason to suppose that the next INTEGER in that series will be easily predicted. Neural nets are not a magical tool that will do here. For example, consider this vector?
[3 5 4 5 6 8 9 8 12 11 10 12 9 11 11 11 10 9 11 11 13 12 12 11]
What is the next term in that series?
Will any neural net be able to predict intelligently that the next term is 12? You might guess what the number is. But KNOWING with any confidence what the next number is will never be something a statistical tool can do, merely by looking at the numbers.
Worse, any numerical tool that would try to extrapolate a series would not understand that the result would be an integer. Any simple extrapolant would probably predict some floating point number.
Ok, I'll even be nice and tell you the next 5 numbers in that sequence. They are [12 15 17 17 16]. What is the next number? Feel free to postulate what is the mechanism behind that sequence. A little creative thinking should suffice. Statistics won't help though.
Unless you actually see the pattern, you will not be able to predict this sequence easily. In fact, I was wondering if oeis would be able to solve it.
https://oeis.org
oeis is a great source to solve such problem sequences. But I'm not at all surprised that it did not find a match for either the sequence you gave, or the one I posed.
  4 commentaires
John D'Errico
John D'Errico le 28 Mar 2017
Actually, in the series I posed, the next term would have been 20. And the one after that? 24.
Alex
Alex le 29 Mar 2017
Modifié(e) : Alex le 1 Avr 2017
Great idea, I will look into the auto-correlation function more: https://www.mathworks.com/help/signal/ref/finddelay.html
16, then 1 are the next number for my series. I wasn't taking a guess at the new one you posed. I am not sure whether to treat the vector X as my signal or to pad it up to the value of the largest integer to treat each integer as a separate sensor to compute the time delay between when the same number is repeated.

Connectez-vous pour commenter.


the cyclist
the cyclist le 18 Mar 2017
Modifié(e) : the cyclist le 18 Mar 2017

The Statistics and Machine Learning Toolbox has many, many tools for making inferences from data.

You could also try the Neural Network Toolbox, but I don't think you need that.

But if you just plot your data

x=[14,14,3,4,8,3,2,5,11,2,1,5,10,2,4,1,8,11,5,1,3,1,2;]
y=1:1:23
figure; plot(y,x,'o')

you'll see that y is certainly not very predictive of x. (But maybe even a little predictive power is OK for your application.)

  3 commentaires
the cyclist
the cyclist le 18 Mar 2017
Modifié(e) : the cyclist le 18 Mar 2017
Ah, fair enough!
Do you have some underlying theoretical model? nlinfit from the Stats toolbox is one possible tool.
Also, I don't have much experience in this area, but this might be more of a signal processing problem. There is a separate toolbox for that, too. Or maybe you could use the fft function in base MATLAB.
Alex
Alex le 25 Mar 2017
Thank you, I am interpreting the data as voltages from a sensor so tried using FFT (I tried using all three examples in the FFT documentation: 'noisy signal', 'gaussian pulse' and 'cosine') to see if I could compute the amplitude and frequency spectrum(s), but do not see to have a central frequency. I believe I need more data.
I do not have a model to use nlinfit, but have noted this as something to try in the future. Thank you for your helpful suggestions!
Cheers,
Alex

Connectez-vous pour commenter.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by