baseCode.math
Class RandomChooser

java.lang.Object
  extended bybaseCode.math.RandomChooser

public class RandomChooser
extends java.lang.Object

Fill arrays with random values given a source of values.

Copyright (c) 2004

Institution: Columbia University

Version:
$Id: RandomChooser.java,v 1.8 2005/03/21 18:01:04 pavlidis Exp $
Author:
Paul Pavlidis

Method Summary
static void chooserandom(double[] randomvals, double[] sourcedata, int[] deck, int max, int n)
          Fill randomvals with random things from sourcedata, without replacement.
static void chooserandom(int[] randomnums, boolean[] recLog, int max, int n)
          choose n random integers from 0 to max without repeating
static void chooserandom(int[] randomnums, int[] deck, int max, int n)
          choose n random integers from 0 to max without repeating
static void chooserandomWrep(int[] randomnums, 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 witha given seed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

init

public static void init(long seed)
Initialized the random number generator witha given seed.

Parameters:
seed -

chooserandom

public static void chooserandom(double[] randomvals,
                                double[] sourcedata,
                                int[] deck,
                                int max,
                                int n)
Fill randomvals with random things from sourcedata, without replacement.

Parameters:
randomvals - answers go here.
sourcedata - Data to be randomly selected
deck - an array pre-filled with integers from 0 to max, but they don't have to be in order.
max - how many values we need.
n - int

chooserandom

public static void chooserandom(int[] randomnums,
                                int[] deck,
                                int max,
                                int n)
choose n random integers from 0 to max without repeating

Parameters:
randomnums - answers go here.
deck - an array pre-filled with integers from 0 to max, but they don't have to be in order.
max - how many values we need.
n - int

chooserandom

public static void chooserandom(int[] randomnums,
                                boolean[] recLog,
                                int max,
                                int n)
choose n random integers from 0 to max without repeating

Parameters:
randomnums - int[]
recLog - record of what values are already chosen.
max - int
n - int

chooserandomWrep

public static void chooserandomWrep(int[] randomnums,
                                    int max,
                                    int n)
Same as chooserandom, but with replacement -- that is, repeats are allowed.

Parameters:
randomnums - int[]
max - int
n - int


Copyright © 2003-2005 Columbia University. All Rights Reserved.