I am looking for a simple method to populate a large int[] testArray
with data. Method should accept a single parameter to generate a deterministic sequence of integers, but look like noise at a first glance.
Something like this comes to mind, but data might have patterns.
public int[] populate(int arraySize, int somePrime){
int[] testArray = new int[arraySize];
int offset = -100000;
long fib = 0; long fibm1 = 1; long fibm2 = 1;
//...
for(int i = offset; i< testArray.length; i++){
fib= fibm1+ fibm2;
fibm2= fibm1;
fibm1= fib;
if(i >= 0){ testArray[i] = (int) fib%somePrime; }
}
return testArray[i];
}
What would be a better method?
Aucun commentaire:
Enregistrer un commentaire