Here it is what I'm looking for:
Having a random variable, with an unknown distribution of its values, is there any smart algorithm that can predict the next value of the variable based on n samples of it? i.e. if I have a population of 5 samples for the random variable x, let's say: 23, 41, 35, 22, 38 ; based on these values I want to predict the next value in the iteration (if possible even the k-th value). I have some knowledge on Bootstrap, https://en.wikipedia.org/wiki/Bootstrapping_(statistics), but since I'm interested to implement the algorithm in a Programming Language, Bootstrap has a high cost in time and memory, that's why I'm looking for something lighter.
P.S. I'm sorry if I made any mistake in terms, but I'm not a mathematician. Any suggestion would be appreciated.
I also posted this question in CrossValidated: https://stats.stackexchange.com/questions/224413/prediction-algorithms-in-statistics