public class Util extends Object
Modifier and Type | Field and Description |
---|---|
static Random |
random
The global random number generator
|
static long |
randSeed
The random seed for all random number generators in the simulation
|
Modifier and Type | Method and Description |
---|---|
static String |
concatenate(List<String> strings,
String sep)
Concatenate a list of strings.
|
static String |
concatenate(String[] strings,
String sep)
Concatenate an array of strings.
|
static double |
constrain(double inputValue,
double minValue,
double maxValue)
Constrain a double value between a lower and upper bound.
|
static boolean |
isDoubleEqual(double a,
double b)
Whether two floating-point numbers (doubles) are equal.
|
static boolean |
isDoubleEqual(double a,
double b,
double precision)
Whether two floating-point numbers (doubles) are equal.
|
static boolean |
isDoubleEqualOrGreater(double a,
double b)
Whether two floating-point numbers (doubles) are greater than or
equal to another.
|
static boolean |
isDoubleEqualOrLess(double a,
double b)
Whether two floating-point numbers (doubles) are less than or
equal to another.
|
static boolean |
isDoubleNotEqual(double a,
double b)
Whether two floating-point numbers (doubles) are not equal.
|
static boolean |
isDoubleNotEqual(double a,
double b,
double precision)
Whether two floating-point numbers (doubles) are not equal.
|
static boolean |
isDoubleNotZero(double a)
Whether a floating-point numbers (doubles) is not zero.
|
static boolean |
isDoubleZero(double a)
Whether a floating-point numbers (doubles) is zero.
|
static boolean |
nearlyEqual(double a,
double b,
double epsilon)
Check whether two double values are "nearly" equal.
|
static int |
randomIndex(double[] distribution)
Choose a number according to a finite probability distribution.
|
static int |
randomIndex(List<Double> distribution)
Choose a number according to a finite probability distribution.
|
static List<String> |
readFileToStrArray(String inFileName)
Read the content of a file into a list of strings.
|
static double |
recenter(double inputValue,
double minValue,
double maxValue)
Recenter a double value between a lower and upper bound.
|
static double |
sum(double[] as)
The sum of an array of floating-point numbers
|
static double |
sum(Iterable<Double> as)
The sum of a sequence of floating-point numbers
|
public static long randSeed
public static final Random random
public static boolean nearlyEqual(double a, double b, double epsilon)
a
- the first double valueb
- the second double valueepsilon
- the precisionpublic static boolean isDoubleZero(double a)
a
- a double valuepublic static boolean isDoubleNotZero(double a)
a
- a double valuepublic static boolean isDoubleEqual(double a, double b)
a
- a double valueb
- a double valuepublic static boolean isDoubleNotEqual(double a, double b)
a
- a double valueb
- a double valuepublic static boolean isDoubleEqual(double a, double b, double precision)
a
- a double valueb
- a double valueprecision
- the bound on of the difference between a and b that
is considered equal.public static boolean isDoubleNotEqual(double a, double b, double precision)
a
- a double valueb
- a double valueprecision
- the bound on of the difference between a and b that
is considered equal.public static boolean isDoubleEqualOrGreater(double a, double b)
a
- a double valueb
- a double valuepublic static boolean isDoubleEqualOrLess(double a, double b)
a
- a double valueb
- a double valuepublic static double constrain(double inputValue, double minValue, double maxValue)
inputValue
- the value to constrainminValue
- the lower boundmaxValue
- the upper boundpublic static double recenter(double inputValue, double minValue, double maxValue)
inputValue
- the value to recenterminValue
- the lower boundmaxValue
- the upper boundpublic static double sum(Iterable<Double> as)
as
- an iterable of double valuespublic static double sum(double[] as)
as
- an array of double valuespublic static int randomIndex(double[] distribution)
distribution
- the probability distributionpublic static int randomIndex(List<Double> distribution)
distribution
- the probability distributionpublic static String concatenate(List<String> strings, String sep)
strings
- a list of stringsep
- the separatorpublic static String concatenate(String[] strings, String sep)
strings
- an array of stringsep
- the separatorpublic static List<String> readFileToStrArray(String inFileName) throws IOException
inFileName
- the name of the fileIOException
Copyright © 2013. All rights reserved.