Here you can find the source of shuffleArray(double[] ar)
Parameter | Description |
---|---|
ar | double array to be shuffled |
static void shuffleArray(double[] ar)
//package com.java2s; //License from project: Open Source License import java.util.Random; public class Main { /**//from w ww . j av a 2 s.c o m * Implementing Fisher-Yates shuffle * @param ar double array to be shuffled */ static void shuffleArray(double[] ar) { Random rnd = new Random(); for (int i = ar.length - 1; i >= 0; i--) { int index = rnd.nextInt(i + 1); // Simple swap double a = ar[index]; ar[index] = ar[i]; ar[i] = a; } } }