public class RandomChooser extends Object
Modifier and Type | Method and Description |
---|---|
static double[] |
chooserandom(double[] sourcedata,
int k)
Random numbers from sourcedata, without replacement.
|
static int[] |
chooserandom(int[] deck,
int k)
choose k random integers from 0 to max (exclusive) without repeating
|
static int[] |
chooserandom(int max,
int n)
choose n random integers from 0 (inclusive) to max (exclusive) without repeating
|
static List<? extends Object> |
chooserandom(List<? extends Object> source,
int n) |
static <T> Set<T> |
chooseRandomSubset(int n,
Collection<? extends T> superSet)
Select a random subset of size n from collection superSet
|
static <T> Set<T> |
chooseRandomSubset(int n,
List<? extends T> superSet)
Select a random subset of size n from List superSet
|
static int[] |
chooserandomWrep(int max,
int n)
Same as chooserandom, but with replacement -- that is, repeats are allowed.
|
static void |
init(long seed)
Initialized the random number generator with a given seed.
|
public static double[] chooserandom(double[] sourcedata, int k)
sourcedata
- Data to be randomly selecteddeck
- an array pre-filled with integers from 0 to max, but they don't have to be in order (just an
optimization so we don't have to generate this multiple times)k
- how many values we need.public static int[] chooserandom(int max, int n)
max
- largest value to choosen
- how many to choosepublic static int[] chooserandom(int[] deck, int k)
deck
- an array pre-filled with integers from 0 to max, but they don't have to be in order. Provided to
avoid recomputing in iterative computations.k
- how many to choosepublic static List<? extends Object> chooserandom(List<? extends Object> source, int n)
source
- n
- RandomDataGenerator.nextSample
public static <T> Set<T> chooseRandomSubset(int n, Collection<? extends T> superSet)
n
- superSet
- public static <T> Set<T> chooseRandomSubset(int n, List<? extends T> superSet)
n
- superSet
- public static int[] chooserandomWrep(int max, int n)
randomnums
- int[]max
- intn
- intpublic static void init(long seed)
seed
- Copyright © 2003–2022 UBC Michael Smith Laboratories. All rights reserved.