ecologylab.generic
Class MathTools

java.lang.Object
  extended by ecologylab.generic.MathTools

public class MathTools
extends java.lang.Object

Mathematical tools for shaping ranges of values; wrappers beyond @link java.lang.Math. Includes various falvors of random.


Method Summary
static float bias(float a, float b)
          push a to 1 extreme or the other, based on b
static float gain(float a, float b)
          push a towards middle (b < .5), or extrema (b > .5).
static float pick(float[][] choices)
           
static float pM(float op, float factor)
          plus or minus
static int rand(int max)
           
static float randBias(float factor)
           
static float randGain(float factor)
           
static float random()
           
static float random(float max)
           
static int random(int max)
           
static java.util.Vector randomize(java.util.Vector v)
           
static float randPM(float factor)
          random plus or minus
static float toExtremes(float x)
           
static boolean tossCoin()
          heads i win.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

random

public static float random()
Returns:
a random float (instead of a double)

rand

public static int rand(int max)
Returns:
a random integer <= max

random

public static int random(int max)
Returns:
a random integer < max

random

public static float random(float max)
Returns:
a random float < max

tossCoin

public static boolean tossCoin()
heads i win. tails you lose.


pick

public static float pick(float[][] choices)
Parameters:
choices - := array of pairs; each pair := [value, probability]

randomize

public static java.util.Vector randomize(java.util.Vector v)

bias

public static float bias(float a,
                         float b)
push a to 1 extreme or the other, based on b


gain

public static float gain(float a,
                         float b)
push a towards middle (b < .5), or extrema (b > .5). could also be called "contrast".


randGain

public static float randGain(float factor)

randBias

public static float randBias(float factor)

pM

public static float pM(float op,
                       float factor)
plus or minus

Parameters:
op - is 0 to 1

randPM

public static float randPM(float factor)
random plus or minus

Parameters:
factor - the magnitude of the desired result.
Returns:
a random number in the interval [-factor, factor].

toExtremes

public static float toExtremes(float x)