lundi 2 septembre 2019

c# generate random number with trend and max and min offset

I have a function that generates a double number between 0 and 2.2:

Random random = new Random();
double value= random.NextDouble() * (2.2 - 0) + 0;

This works great but what I need is that the random value is +/- 0.2 greater or lower than the previews generated one.

For example:

If first random number is: 1.3434434, the next random number could be 1.5434434 or 1.1434434 and so on, so the numbers can have a trend going up and then could go down but the difference between the preview generated and the new one cant be greater than 0.2

Any easy way to achieve this?




Aucun commentaire:

Enregistrer un commentaire