com.xj.anylogic.engine
Class Utilities

java.lang.Object
  extended by com.xj.anylogic.engine.Presentable
      extended by com.xj.anylogic.engine.Utilities
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
ActiveObject, Experiment

public abstract class Utilities
extends Presentable

This class provides a lot of commonly used functions and constants, including the probability distributions and mathematical functions. The class is a superclass for ActiveObject and Experiment, so that its functions can be called without any prefixing from any code written by the user within those subclasses.

Author:
XJ Technologies Company Ltd. www.anylogic.com
See Also:
Serialized Form

Field Summary
static int AM
          Value of the getAmPm(Date) method indicating the period of the day from midnight to just before noon.
static int APRIL
          Value of the getMonth(Date) method indicating the fourth month of the year in the Gregorian and Julian calendars.
static int AUGUST
          Value of the getMonth(Date) method indicating the eighth month of the year in the Gregorian and Julian calendars.
static int DAY
          Day time unit
static int DECEMBER
          Value of the getMonth(Date) method indicating the twelfth month of the year in the Gregorian and Julian calendars.
static int FEBRUARY
          Value of the getMonth(Date) method indicating the second month of the year in the Gregorian and Julian calendars.
static int FRIDAY
          Value of the getDayOfWeek(Date) method indicating Friday.
static int HOUR
          Hour time unit
static double infinity
          A constant holding the positive infinity of type double.
static int JANUARY
          Value of the getMonth(Date) method indicating the first month of the year in the Gregorian and Julian calendars.
static int JULY
          Value of the getMonth(Date) method indicating the seventh month of the year in the Gregorian and Julian calendars.
static int JUNE
          Value of the getMonth(Date) method indicating the sixth month of the year in the Gregorian and Julian calendars.
static int MARCH
          Value of the getMonth(Date) method indicating the third month of the year in the Gregorian and Julian calendars.
static int MAY
          Value of the getMonth(Date) method indicating the fifth month of the year in the Gregorian and Julian calendars.
static int MILLISECOND
          Millisecond time unit
static int MINUTE
          Minute time unit
static int MONDAY
          Value of the getDayOfWeek(Date) method indicating Monday.
static int MONTH
          Month time unit
static int NOVEMBER
          Value of the getMonth(Date) method indicating the eleventh month of the year in the Gregorian and Julian calendars.
static int OCTOBER
          Value of the getMonth(Date) method indicating the tenth month of the year in the Gregorian and Julian calendars.
static int PM
          Value of the getAmPm(Date) method indicating the period of the day from noon to just before midnight.
static int SATURDAY
          Value of the getDayOfWeek(Date) method indicating Saturday.
static int SECOND
          Second time unit
static int SEPTEMBER
          Value of the getMonth(Date) method indicating the ninth month of the year in the Gregorian and Julian calendars.
static int SUNDAY
          Value of the getDayOfWeek(Date) method indicating Sunday.
static int THURSDAY
          Value of the getDayOfWeek(Date) method indicating Thursday.
static long TIME_UNIT_DAY
          One of the possible time units.
static long TIME_UNIT_HOUR
          One of the possible time units.
static long TIME_UNIT_MILLISECOND
          One of the possible time units.
static long TIME_UNIT_MINUTE
          One of the possible time units.
static long TIME_UNIT_SECOND
          One of the possible time units.
static long TIME_UNIT_WEEK
          One of the possible time units.
static int TUESDAY
          Value of the getDayOfWeek(Date) method indicating Tuesday.
static int UNDECIMBER
          Value of the getMonth(Date) method indicating the thirteenth month of the year.
static int WEDNESDAY
          Value of the getDayOfWeek(Date) method indicating Wednesday.
static int WEEK
          Week time unit
static int YEAR
          Year time unit
 
Fields inherited from class com.xj.anylogic.engine.Presentable
ALIGNMENT_CENTER, ALIGNMENT_LEFT, ALIGNMENT_RIGHT, CAD_ANTIALIASING, CAD_INVERTED, LINE_STYLE_DASHED, LINE_STYLE_DOTTED, LINE_STYLE_SOLID, NAVIGATION_FULL, NAVIGATION_LIMITED_TO_Z_ABOVE_ZERO, NAVIGATION_NONE, NAVIGATION_ROTATION_ONLY, SHAPE_ARC, SHAPE_BUTTON, SHAPE_CAD, SHAPE_CHART_BAR, SHAPE_CHART_HISTOGRAM, SHAPE_CHART_HISTOGRAM2D, SHAPE_CHART_PIE, SHAPE_CHART_PLOT, SHAPE_CHART_STACK, SHAPE_CHART_TIME_COLOR, SHAPE_CHART_TIME_PLOT, SHAPE_CHART_TIME_STACK, SHAPE_CHECKBOX, SHAPE_COMBOBOX, SHAPE_CURVE, SHAPE_EMBEDDED_OBJECT, SHAPE_FILECHOOSER, SHAPE_GROUP, SHAPE_IMAGE, SHAPE_LINE, SHAPE_LISTBOX, SHAPE_OVAL, SHAPE_PIXEL, SHAPE_POLYLINE, SHAPE_PROGRESSBAR, SHAPE_RADIOBUTTONS, SHAPE_RECTANGLE, SHAPE_ROUNDED_RECTANGLE, SHAPE_SLIDER, SHAPE_TEXT, SHAPE_TEXTFIELD
 
Constructor Summary
Utilities()
           
 
Method Summary
 int bernoulli(double p)
          Generates a sample of the Bernoulli distribution, i.e. 1 with probability p and 0 with probability 1 - p.
static int bernoulli(double p, java.util.Random r)
          Generates a sample of the Bernoulli distribution using the specified random number generator.
 double beta(double p, double q)
          Generates a sample of the Beta distribution with min set to 0 and max set to 1.
 double beta(double p, double q, double min, double max)
          Generates a sample of the Beta distribution.
 double beta(double min, double max, double p, double q, double shift, double stretch)
          Generates a sample of truncated Beta distribution.
static double beta(double min, double max, double p, double q, double shift, double stretch, java.util.Random r)
          Generates a sample of truncated Beta distribution using the specified random number generator.
static double beta(double p, double q, double min, double max, java.util.Random r)
          Generates a sample of the Beta distribution using the specified random number generator.
 int binomial(double p)
          Generates a sample of the Binomial distribution with n set to 1.
 double binomial(double min, double max, double p, double n, double shift, double stretch)
          Generates a sample of truncated Binomial distribution.
static double binomial(double min, double max, double p, double n, double shift, double stretch, java.util.Random r)
          Generates a sample of truncated Binomial distribution using the specified random number generator.
 int binomial(double p, int n)
          Generates a sample of the Binomial distribution.
static int binomial(double p, int n, java.util.Random r)
          Generates a sample of the Binomial distribution using the specified random number generator.
static java.lang.String briefInfoOn(java.lang.Object object)
          Returns a brief one-line textual information on the given object.
 double cauchy(double lambda)
          Generates a sample of the Cauchy distribution with theta set to 0.
 double cauchy(double lambda, double theta)
          Generates a sample of the Cauchy distribution.
static double cauchy(double lambda, double theta, java.util.Random r)
          Generates a sample of the Cauchy distribution using the specified random number generator.
 double chi2(double nu)
          Generates a sample of the Chi Squared distribution with min set to 0.
 double chi2(double nu, double min)
          Generates a sample of the Chi Squared distribution.
static double chi2(double nu, double min, java.util.Random r)
          Generates a sample of the Chi Squared distribution using the specified random number generator.
static void copyToClipboard(java.lang.String s)
          Puts the given text on the system clipboard
Note that this method may not work when the model is started as applet due to security policy of browser
static java.net.URL createURL_xjal(java.lang.String url)
          Creates an URL object from the String representation
 java.util.Date date()
          Returns the current model date with respect to the start time/date and the model time unit.
 double dateToTime(java.util.Date d)
          Converts the given date to model time with respect to the start date, start time and model time unit settings
 double day()
          Returns a time value equal to one day according to the current time unit setting.
static double difference(DataSet ds1, DataSet ds2)
          Difference function which is always not-negative and reflects difference between 2 given data sets in their common arguments range
static double difference(DataSet ds, TableFunction f)
          Difference function which is always not-negative and reflects difference between given data set and table function in their common arguments range
static double differenceInDateUnits(int timeUnit, java.util.Date date1, java.util.Date date2)
          Returns the difference (date2 - date1) between two dates in the given time units.
 double differenceInDateUnits(int timeUnit, double time1, double time2)
          Returns the difference (time2 - time1) between two model dates (corresponding to the given model times) in the given time units.
static java.util.Date dropTime(java.util.Date date)
          This utility method drops time-of-the-day information and returns the date with the time 00:00:00.000
 double erlang(double beta, int m)
          Generates a sample of the Erlang distribution with min set to 0.
 double erlang(double beta, int m, double min)
          Generates a sample of the Erlang distribution.
static double erlang(double beta, int m, double min, java.util.Random r)
          Generates a sample of the Erlang distribution using the specified random number generator.
abstract  java.lang.RuntimeException error(java.lang.String errorText)
          Signals an error during the model run by throwing a RuntimeException with errorText preceded by the active object full name.
 java.lang.RuntimeException error(java.lang.String errorTextFormat, java.lang.Object... args)
          The same as error(String) but allows error format syntax like in String.format(String, Object...) method
 double exponential()
          Generates a sample of the Exponential distribution with lambda set to 1 and min set to 0.
 double exponential(double lambda)
          Generates a sample of the Exponential distribution with min set to 0.
 double exponential(double lambda, double min)
          Generates a sample of the Exponential distribution.
 double exponential(double min, double max, double shift, double stretch)
          Generates a sample of truncated Exponential distribution.
static double exponential(double min, double max, double shift, double stretch, java.util.Random r)
          Generates a sample of truncated Exponential distribution using the specified random number generator.
static double exponential(double lambda, double min, java.util.Random r)
          Generates a sample of the Exponential distribution using the specified random number generator.
static java.lang.String format(boolean value)
          Formats a boolean value
static java.lang.String format(char value)
          Formats a character to String
static java.lang.String format(java.util.Date date)
          Formats a date using the default AnyLogic formatter
static java.lang.String format(double value)
          Formats a double value using the default AnyLogic formatter
static java.lang.String format(int value)
          Formats an integer value using the default AnyLogic formatter
static java.lang.String format(long value)
          Formats a long value using the default AnyLogic formatter
static java.lang.String formatDayOfWeek(int dayOfWeek, boolean fullName)
          Returns the full or short name of the weekday
static java.lang.String formatGeoHeading(double radians)
          Formats given heading angle (measured in radians CW, starting from North direction) as human-readable geographical heading (azimuth).
static java.lang.String formatLatitude(double degrees)
          Formats latitude
static java.lang.String formatLongitude(double degrees)
          Formats longitude
static java.lang.String formatMonth(int month, boolean fullName)
          Returns the full or short name of the month
 java.lang.String formatTimeInterval(double dt)
          Returns a string representation of a given time interval, according to the current time unit settings, in the form 123 days 21h 0'56".
static double gamma_frac(double a, java.util.Random r)
           
 double gamma(double alpha, double beta)
          Generates a sample of the Gamma distribution with min set to 0.
 double gamma(double alpha, double beta, double min)
          Generates a sample of the Gamma distribution.
 double gamma(double min, double max, double alpha, double shift, double stretch)
          Generates a sample of truncated Gamma distribution.
static double gamma(double min, double max, double alpha, double shift, double stretch, java.util.Random r)
          Generates a sample of truncated Gamma distribution using the specified random number generator.
static double gamma(double alpha, double beta, double min, java.util.Random r)
          Generates a sample of the Gamma distribution using the specified random number generator.
static double gammaLog(double x)
          Returns the natural logarithm of the gamma function of x:
ln(Γ(x)).
 int geometric(double p)
          Generates a sample of the Geometric distribution.
static int geometric(double p, java.util.Random r)
          Generates a sample of the Geometric distribution using the specified random number generator.
 int getAmPm()
          Indicates whether the hour of the current model date with respect to the start time/date and the model time unit is before (AM) or after (PM) noon.
static int getAmPm(java.util.Date date)
          Indicates whether the hour of the given date is before (AM) or after (PM) noon.
 int getDayOfMonth()
          Returns the day of the month of the current model date with respect to the start time/date and the model time unit.
static int getDayOfMonth(java.util.Date date)
          Returns the day of the month of the given date.
 int getDayOfWeek()
          Returns the day of the week of the current model date with respect to the start time/date and the model time unit.
static int getDayOfWeek(java.util.Date date)
          Returns the day of the week of the given date.
static int getDayOfYear(java.util.Date date)
          Returns the day of the year of the given date.
 java.util.Random getDefaultRandomGenerator()
          Retrieves the random number generator used by all probability distributions by default, i.e. if no particular generator is specified in the call to a probability distribution function.
static double getDistance(double x1, double y1, double x2, double y2)
          Returns the distance between two given points (x1, y1) and (x2, y2)
static double getDistance(double x1, double y1, double z1, double x2, double y2, double z2)
          Returns the distance between two given points (x1, y1, z1) and (x2, y2, z2)
static double getDistanceFromPointToLine(double x1, double y1, double x2, double y2, double px, double py)
          Returns the distance from a point to a line.
static double getDistanceFromPointToLineSq(double x1, double y1, double x2, double y2, double px, double py)
          Returns the square of the distance from a point to a line.
static double getDistanceFromPointToSegment(double x1, double y1, double x2, double y2, double px, double py)
          Returns the distance from a point to a line segment.
static double getDistanceFromPointToSegmentSq(double x1, double y1, double x2, double y2, double px, double py)
          Returns the square of the distance from a point to a line segment.
static double getDistanceSq(double x1, double y1, double x2, double y2)
          Returns the square of the distance between two given points (x1, y1) and (x2, y2).
static double getDistanceSq(double x1, double y1, double z1, double x2, double y2, double z2)
          Returns the square of the distance between two given points (x1, y1, z1) and (x2, y2, z2).
 int getHour()
          Returns the hour of the morning or afternoon of the current model date with respect to the start time/date and the model time unit.
static int getHour(java.util.Date date)
          Returns the hour of the morning or afternoon of the given date.
 int getHourOfDay()
          Returns the hour of day of the current model date with respect to the start time/date and the model time unit.
static int getHourOfDay(java.util.Date date)
          Returns the hour of day of the given date.
static double getLength(double dx, double dy)
          Returns the length of the vector (dx, dy)
static double getLength(double dx, double dy, double dz)
          Returns the length of the vector (dx, dy, dz)
 int getMillisecond()
          Returns the millisecond within the second of the current model date with respect to the start time/date and the model time unit.
static int getMillisecond(java.util.Date date)
          Returns the millisecond within the second of the given date.
 int getMinute()
          Returns the minute within the hour of the current model date with respect to the start time/date and the model time unit.
static int getMinute(java.util.Date date)
          Returns the minute within the hour of the given date.
 int getMonth()
          Returns the month of the current model date with respect to the start time/date and the model time unit.
static int getMonth(java.util.Date date)
          Returns the month of the given date.
<T> T
getRandom(java.util.Collection<T> collection)
          Returns the randomly chosen element of the given collection.
static
<T> T
getRandom(java.util.Collection<T> collection, java.util.Random r)
          Returns the randomly chosen element of the given collection.
 int getSecond()
          Returns the second within the minute of the current model date with respect to the start time/date and the model time unit.
static int getSecond(java.util.Date date)
          Returns the second within the minute of the given date.
 double getTime()
          Deprecated. Use time() instead
 int getYear()
          Returns the year of the current model date with respect to the start time/date and the model time unit.
static int getYear(java.util.Date date)
          Returns the year of the given date.
 double gumbel1(double a, double b)
          Generates a sample of the Type I Gumbel distribution.
static double gumbel1(double a, double b, java.util.Random r)
          Generates a sample of the Type I Gumbel distribution using the specified random number generator.
 double gumbel2(double a, double b)
          Generates a sample of the Type II Gumbel distribution.
static double gumbel2(double a, double b, java.util.Random r)
          Generates a sample of the Type II Gumbel distribution using the specified random number generator.
 double hour()
          Returns a time value equal to one hour according to the current time unit setting.
 int hypergeometric(int ss, int dn, int ps)
          Generates a sample of the Hypergeometric distribution.
static int hypergeometric(int ss, int dn, int ps, java.util.Random r)
          Generates a sample of the Hypergeometric distribution using the specified random number generator.
static java.lang.String inspectOf(java.lang.Object object)
          Returns a textual info on the object that can be displayed in the multi-line Inspect window.
static boolean isLineIntersectingLine(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
          Tests if the line segment from (x1,y1) to (x2,y2) intersects the line segment from (x3,y3) to (x4,y4).
static boolean isLineIntersectingRectangle(double x1, double y1, double x2, double y2, double rx, double ry, double rw, double rh)
          Check if the line intersects the given rectangle
static boolean isPointInsideRectangle(double rx, double ry, double rw, double rh, double px, double py)
          Tests if the specified point is inside the given rectangle.
static boolean isPointOnTheSameLine(double x1, double y1, double x2, double y2, double x3, double y3)
          Tests if the three point lie on the same line
 double laplace(double phi, double theta)
          Generates a sample of the Laplace distribution.
static double laplace(double phi, double theta, java.util.Random r)
          Generates a sample of the Laplace distribution using the specified random number generator.
static double limit(double min, double x, double max)
          Returns x if it is within [min,max] interval, otherwise returns the closest bound.
static double limitMax(double x, double max)
          Returns x if it is less or equal to max, otherwise returns max.
static double limitMin(double min, double x)
          Returns x if it is greater or equal to min, otherwise returns min.
 int logarithmic(double theta)
          Generates a sample of the Logarithmic distribution.
static int logarithmic(double theta, java.util.Random r)
          Generates a sample of the Logarithmic distribution using the specified random number generator.
 double logistic(double beta, double alpha)
          Generates a sample of the Logistic distribution.
static double logistic(double beta, double alpha, java.util.Random r)
          Generates a sample of the Logistic distribution using the specified random number generator.
 double lognormal(double mu, double sigma, double min)
          Generates a sample of the Lognormal distribution.
static double lognormal(double mu, double sigma, double min, java.util.Random r)
          Generates a sample of the Lognormal distribution using the specified random number generator.
 double millisecond()
          Returns a time value equal to one millisecond according to the current time unit setting.
 double minute()
          Returns a time value equal to one minute according to the current time unit setting.
 int negativeBinomial(double p, double n)
          Generates a sample of the Negative Binomial distribution.
 double negativeBinomial(double min, double max, double p, double n, double shift, double stretch)
          Generates a sample of truncated Negative Binomial distribution.
static double negativeBinomial(double min, double max, double p, double n, double shift, double stretch, java.util.Random r)
          Generates a sample of truncated Negative Binomial distribution using the specified random number generator.
static int negativeBinomial(double p, double n, java.util.Random r)
          Generates a sample of the Negative Binomial distribution using the specified random number generator.
 double normal()
          Generates a sample of the Normal distribution with mean set to 0 and sigma set to 1.
 double normal(double sigma)
          Generates a sample of the Normal distribution with mean set to 0.
 double normal(double sigma, double mean)
          Generates a sample of the Normal distribution.
 double normal(double min, double max, double shift, double stretch)
          Generates a sample of truncated Normal distribution.
static double normal(double min, double max, double shift, double stretch, java.util.Random r)
          Generates a sample of truncated Normal distribution using the specified random number generator.
static double normal(double sigma, double mean, java.util.Random r)
          Generates a sample of the Normal distribution using the specified random number generator.
 double pareto(double alpha)
          Generates a sample of the Pareto distribution with min set to 1.
 double pareto(double alpha, double min)
          Generates a sample of the Pareto distribution.
static double pareto(double alpha, double min, java.util.Random r)
          Generates a sample of the Pareto distribution using the specified random number generator.
 double pert(double min, double max, double mode)
          Generates a sample of the PERT distribution.
static double pert(double min, double max, double mode, java.util.Random r)
          Generates a sample of the PERT distribution using the specified random number generator.
 int poisson(double lambda)
          Generates a sample of the Poisson distribution.
 double poisson(double min, double max, double mean, double shift, double stretch)
          Generates a sample of truncated Poisson distribution.
static double poisson(double min, double max, double mean, double shift, double stretch, java.util.Random r)
          Generates a sample of truncated Poisson distribution using the specified random number generator.
static int poisson(double lambda, java.util.Random r)
          Generates a sample of the Poisson distribution using the specified random number generator.
static void prepareBeforeExperimentStart_xjal(java.lang.Class<?> experimentClass)
          This method is internal and isn't intended to be called by user (may be removed in future releases)
 double pulse(double startTime, double pulseWidth)
          Returns 1, starting at startTime, and lasting for interval pulseWidth; 0 is returned at all other times.
 double pulseTrain(double startTime, double pulseWidth, double timeBetweenPulses, double endTime)
          Returns 1, starting at startTime, and lasting for interval pulseWidth and then repeats this pattern every timeBetweenPulses time until endTime; 0 is returned at all other times.
static double quantum(double value, double quantizer)
          Returns the number smaller (by absolute value) than or equal to value that is an integer multiple of quantizer.
 double ramp(double slope, double startTime, double endTime)
          Returns 0 until the startTime and then slopes upward until endTime and then holds constant.
 boolean randomFalse(double p)
          Generates false with the given probability p.
static boolean randomFalse(double p, java.util.Random r)
          Generates false with the given probability p using the specified random number generator.
 boolean randomTrue(double p)
          Generates true with the given probability p.
static boolean randomTrue(double p, java.util.Random r)
          Generates true with the given probability p using the specified random number generator.
 double rayleigh(double sigma)
          Generates a sample of the Rayleigh distribution with min set to 0.
 double rayleigh(double sigma, double min)
          Generates a sample of the Rayleigh distribution.
static double rayleigh(double sigma, double min, java.util.Random r)
          Generates a sample of the Rayleigh distribution using the specified random number generator.
 double second()
          Returns a time value equal to one second according to the current time unit setting.
 void setDefaultRandomGenerator(java.util.Random r)
          Sets the random number generator used by all probability distributions by default, i.e. if no particular generator is specified in the call to a probability distribution function.
static double sqr(double v)
          Returns the square of the given value (v2)
 double step(double height, double stepTime)
          Returns 0 until the stepTime and then returns height
 double time()
          Returns the current model (logical) time.
 java.util.Date timeToDate(double t)
          Converts the given model time to date with respect to the start date, start time and model time unit settings, null if the time is infinity.
static java.util.Date toDate(int year, int month, int day, int hourOfDay, int minute, int second)
          Returns the date in the default time zone with given field values.
static long toDateInMillis(int year, int month, int day, int hourOfDay, int minute, int second)
          Same as toDate(int, int, int, int, int, int) but returns the date in its milliseconds representation (see Date.getTime()), i.e.
static double toLatitude(int degrees, int minutes, double seconds, boolean northOrSouth)
          Converts latitude from human-readable format (e.g. 59° 56' 0" North) to format used in the model
static double toLongitude(int degrees, int minutes, double seconds, boolean eastOrWest)
          Converts longitude from human-readable format (e.g. 30° 20' 0" East) to format used in the model
 double toTimeout(int timeUnit, double amount)
          Returns timeout, in model time units, which equals to the given amount of timeUnits from current model date
e.g.
static void trace(java.lang.Object o)
          Prints a string representation of an object to the standard output stream.
static void traceln()
          Prints a line delimiter to the standard output stream.
static void traceln(java.lang.Object o)
          Prints a string representation of an object with a line delimiter at the end to the standard output stream.
static void traceln(java.lang.String textFormat, java.lang.Object... args)
          The same as traceln(Object) but allows text format syntax like in String.format(String, Object...) method
 double triangular(double min, double max)
          Generates a sample of the Triangular distribution with mode set to (min + max)/2.
 double triangular(double min, double max, double mode)
          Generates a sample of the Triangular distribution.
 double triangular(double min, double max, double left, double mode, double right)
          Generates a sample of truncated Triangular distribution.
static double triangular(double min, double max, double left, double mode, double right, java.util.Random r)
          Generates a sample of truncated Triangular distribution using the specified random number generator.
static double triangular(double min, double max, double mode, java.util.Random r)
          Generates a sample of the Triangular distribution using the specified random number generator.
 int uniform_discr(int max)
          Generates a sample of the Discrete Uniform distribution in the interval [0, max], both 0 and max included!
 int uniform_discr(int min, int max)
          Generates a sample of the Discrete Uniform distribution on the interval [min, max], both min and max included!
static int uniform_discr(int min, int max, java.util.Random r)
          Generates a sample of the Discrete Uniform distribution on the interval [min, max] using the specified random number generator, both 0 and max included!
 double uniform_pos()
          Generates a positive random value uniformly distributed on the interval (0,1).
static double uniform_pos(java.util.Random r)
          Generates a positive random value uniformly distributed on the interval (0,1), using the specified random number generator.
 double uniform()
          Generates a random value uniformly distributed on the interval [0,1), the upper bound is not included.
 double uniform(double max)
          Generates a sample of the Uniform distribution on the interval [0, max).
 double uniform(double min, double max)
          Generates a sample of the Uniform distribution on the interval [min, max).
static double uniform(double min, double max, java.util.Random r)
          Generates a sample of the Uniform distribution on the interval [min, max) using the specified random number generator.
static double uniform(java.util.Random r)
          Generates a random value uniformly distributed on the interval [0,1), using the specified random number generator.
 double week()
          Returns a time value equal to one week according to the current time unit setting.
 double weibull(double beta, double alpha)
          Generates a sample of the Weibull distribution with min set to 0.
 double weibull(double alpha, double beta, double min)
          Generates a sample of the Weibull distribution.
 double weibull(double min, double max, double alpha, double shift, double stretch)
          Generates a sample of truncated Weibull distribution.
static double weibull(double min, double max, double alpha, double shift, double stretch, java.util.Random r)
          Generates a sample of truncated Weibull distribution using the specified random number generator.
static double weibull(double alpha, double beta, double min, java.util.Random r)
          Generates a sample of the Weibull distribution using the specified random number generator.
static double xidz(double a, double b, double x)
          Tries to divide the first argument by the second.
static double zidz(double a, double b)
          Tries to divide the first argument by the second.
 
Methods inherited from class com.xj.anylogic.engine.Presentable
contains, drawCollection, drawDatabase, drawDataset, drawExcelFile, drawFunction, drawHistogram2DData, drawHistogramData, drawInsert, drawKeyValueTable, drawModel, drawModelElements, drawPlainVariable, drawPresentation, drawQuery, drawSchedule, drawShape, drawStatistics, drawTableFunction, drawTextFile, drawUpdate, executeShapeControlAction, executeShapeControlAction, executeShapeControlAction, executeShapeControlAction, executeShapeControlAction, executeShapeControlAction, finishReadObject_xjal, getEngine, getExperiment, getNameOfShape, getPersistentShape, getPresentation, getShapeArcAngle, getShapeArcAngle, getShapeArcStartAngle, getShapeArcStartAngle, getShapeCADCustomLayerColors, getShapeCADDrawingAttributes, getShapeCADDrawingAttributes, getShapeCADFileName, getShapeCADFileName, getShapeCADVisibleLayerNames, getShapeChartColorFromDouble, getShapeChartDataColors, getShapeChartDataItems, getShapeChartDataPlotOptions, getShapeChartDataSets, getShapeChartDataTitles, getShapeChartHistogram2DOptions, getShapeChartHistogramOptions, getShapeChartHistograms, getShapeChartHistograms2D, getShapeChartProperties, getShapeControl, getShapeControl, getShapeControlDefaultValueBoolean, getShapeControlDefaultValueBoolean, getShapeControlDefaultValueDouble, getShapeControlDefaultValueDouble, getShapeControlDefaultValueInt, getShapeControlDefaultValueInt, getShapeControlDefaultValueString, getShapeControlDefaultValueString, getShapeControlManager, getShapeControlMaximum, getShapeControlMaximum, getShapeControlMinimum, getShapeControlMinimum, getShapeControlMultipleSelectionMode, getShapeControlMultipleSelectionMode, getShapeControlProgressString, getShapeControlProgressString, getShapeControlTexts, getShapeControlTexts, getShapeControlTexts2D, getShapeControlTexts2D, getShapeControlType, getShapeControlType, getShapeControlValueType, getShapeControlValueType, getShapeEmbeddedObject, getShapeEmbeddedObject, getShapeFillColor, getShapeFillColor, getShapeFont, getShapeFont, getShapeGroupContent, getShapeHeight, getShapeHeight, getShapeImageFileNames, getShapeImageFileNames, getShapeImageNumber, getShapeImageNumber, getShapeLineColor, getShapeLineColor, getShapeLineDx, getShapeLineDx, getShapeLineDy, getShapeLineDy, getShapeLineStyle, getShapeLineStyle, getShapeLineWidth, getShapeLineWidth, getShapeNPoints, getShapeNPoints, getShapePackagePrefix, getShapePointsDx, getShapePointsDx, getShapePointsDy, getShapePointsDy, getShapeRadiusX, getShapeRadiusX, getShapeRadiusY, getShapeRadiusY, getShapeReplication, getShapeRotation, getShapeRotation, getShapeScaleX, getShapeScaleX, getShapeScaleY, getShapeScaleY, getShapeText, getShapeText, getShapeTextAlignment, getShapeTextAlignment, getShapeType, getShapeWidth, getShapeWidth, getShapeX, getShapeX, getShapeY, getShapeY, getViewAreas, iconContains, isShapeCADNegative, isShapeCADNegative, isShapeClosed, isShapeClosed, isShapeControlEnabled, isShapeControlEnabled, isShapeControlVertical, isShapeControlVertical, isShapePublic, isShapeVisible, isShapeWithManualControlPoints, isShapeWithManualControlPoints, modelElementContains, modelElementContains, onClickIconAt, onClickModelAt, onClickPresentationAt, onItemRemoved, onSelectionChanged, onShapeClick, onShapeClickAt, onShapeGroupDraw, presentationContains, readCustomData, setControlValueToDefault, setControlValueToDefault, writeCustomData
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SUNDAY

public static final int SUNDAY
Value of the getDayOfWeek(Date) method indicating Sunday.

See Also:
getDayOfWeek(Date), getDayOfWeek(), Engine.getDayOfWeek(), Constant Field Values

MONDAY

public static final int MONDAY
Value of the getDayOfWeek(Date) method indicating Monday.

See Also:
getDayOfWeek(Date), getDayOfWeek(), Engine.getDayOfWeek(), Constant Field Values

TUESDAY

public static final int TUESDAY
Value of the getDayOfWeek(Date) method indicating Tuesday.

See Also:
getDayOfWeek(Date), getDayOfWeek(), Engine.getDayOfWeek(), Constant Field Values

WEDNESDAY

public static final int WEDNESDAY
Value of the getDayOfWeek(Date) method indicating Wednesday.

See Also:
getDayOfWeek(Date), getDayOfWeek(), Engine.getDayOfWeek(), Constant Field Values

THURSDAY

public static final int THURSDAY
Value of the getDayOfWeek(Date) method indicating Thursday.

See Also:
getDayOfWeek(Date), getDayOfWeek(), Engine.getDayOfWeek(), Constant Field Values

FRIDAY

public static final int FRIDAY
Value of the getDayOfWeek(Date) method indicating Friday.

See Also:
getDayOfWeek(Date), getDayOfWeek(), Engine.getDayOfWeek(), Constant Field Values

SATURDAY

public static final int SATURDAY
Value of the getDayOfWeek(Date) method indicating Saturday.

See Also:
getDayOfWeek(Date), getDayOfWeek(), Engine.getDayOfWeek(), Constant Field Values

JANUARY

public static final int JANUARY
Value of the getMonth(Date) method indicating the first month of the year in the Gregorian and Julian calendars.

See Also:
getMonth(Date), getMonth(), Engine.getMonth(), Constant Field Values

FEBRUARY

public static final int FEBRUARY
Value of the getMonth(Date) method indicating the second month of the year in the Gregorian and Julian calendars.

See Also:
getMonth(Date), getMonth(), Engine.getMonth(), Constant Field Values

MARCH

public static final int MARCH
Value of the getMonth(Date) method indicating the third month of the year in the Gregorian and Julian calendars.

See Also:
getMonth(Date), getMonth(), Engine.getMonth(), Constant Field Values

APRIL

public static final int APRIL
Value of the getMonth(Date) method indicating the fourth month of the year in the Gregorian and Julian calendars.

See Also:
getMonth(Date), getMonth(), Engine.getMonth(), Constant Field Values

MAY

public static final int MAY
Value of the getMonth(Date) method indicating the fifth month of the year in the Gregorian and Julian calendars.

See Also:
getMonth(Date), getMonth(), Engine.getMonth(), Constant Field Values

JUNE

public static final int JUNE
Value of the getMonth(Date) method indicating the sixth month of the year in the Gregorian and Julian calendars.

See Also:
getMonth(Date), getMonth(), Engine.getMonth(), Constant Field Values

JULY

public static final int JULY
Value of the getMonth(Date) method indicating the seventh month of the year in the Gregorian and Julian calendars.

See Also:
getMonth(Date), getMonth(), Engine.getMonth(), Constant Field Values

AUGUST

public static final int AUGUST
Value of the getMonth(Date) method indicating the eighth month of the year in the Gregorian and Julian calendars.

See Also:
getMonth(Date), getMonth(), Engine.getMonth(), Constant Field Values

SEPTEMBER

public static final int SEPTEMBER
Value of the getMonth(Date) method indicating the ninth month of the year in the Gregorian and Julian calendars.

See Also:
getMonth(Date), getMonth(), Engine.getMonth(), Constant Field Values

OCTOBER

public static final int OCTOBER
Value of the getMonth(Date) method indicating the tenth month of the year in the Gregorian and Julian calendars.

See Also:
getMonth(Date), getMonth(), Engine.getMonth(), Constant Field Values

NOVEMBER

public static final int NOVEMBER
Value of the getMonth(Date) method indicating the eleventh month of the year in the Gregorian and Julian calendars.

See Also:
getMonth(Date), getMonth(), Engine.getMonth(), Constant Field Values

DECEMBER

public static final int DECEMBER
Value of the getMonth(Date) method indicating the twelfth month of the year in the Gregorian and Julian calendars.

See Also:
getMonth(Date), getMonth(), Engine.getMonth(), Constant Field Values

UNDECIMBER

public static final int UNDECIMBER
Value of the getMonth(Date) method indicating the thirteenth month of the year. Although GregorianCalendar does not use this value, lunar calendars do.

See Also:
getMonth(Date), getMonth(), Engine.getMonth(), Constant Field Values

AM

public static final int AM
Value of the getAmPm(Date) method indicating the period of the day from midnight to just before noon.

See Also:
getAmPm(Date), getAmPm(), Engine.getAmPm(), Constant Field Values

PM

public static final int PM
Value of the getAmPm(Date) method indicating the period of the day from noon to just before midnight.

See Also:
getAmPm(Date), getAmPm(), Engine.getAmPm(), Constant Field Values

YEAR

public static final int YEAR
Year time unit

See Also:
toTimeout(int, double), Constant Field Values

MONTH

public static final int MONTH
Month time unit

See Also:
toTimeout(int, double), Constant Field Values

WEEK

public static final int WEEK
Week time unit

See Also:
toTimeout(int, double), Constant Field Values

DAY

public static final int DAY
Day time unit

See Also:
toTimeout(int, double), Constant Field Values

HOUR

public static final int HOUR
Hour time unit

See Also:
toTimeout(int, double), Constant Field Values

MINUTE

public static final int MINUTE
Minute time unit

See Also:
toTimeout(int, double), Constant Field Values

SECOND

public static final int SECOND
Second time unit

See Also:
toTimeout(int, double), Constant Field Values

MILLISECOND

public static final int MILLISECOND
Millisecond time unit

See Also:
toTimeout(int, double), Constant Field Values

infinity

public static final double infinity
A constant holding the positive infinity of type double.
If you want to get negative infinity, please write -infinity

See Also:
Constant Field Values

TIME_UNIT_MILLISECOND

public static final long TIME_UNIT_MILLISECOND
One of the possible time units. Equals 1.

See Also:
Constant Field Values

TIME_UNIT_SECOND

public static final long TIME_UNIT_SECOND
One of the possible time units. Equals the number of milliseconds in a second.

See Also:
Constant Field Values

TIME_UNIT_MINUTE

public static final long TIME_UNIT_MINUTE
One of the possible time units. Equals the number of milliseconds in a minute.

See Also:
Constant Field Values

TIME_UNIT_HOUR

public static final long TIME_UNIT_HOUR
One of the possible time units. Equals the number of milliseconds in an hour.

See Also:
Constant Field Values

TIME_UNIT_DAY

public static final long TIME_UNIT_DAY
One of the possible time units. Equals the number of milliseconds in a day.

See Also:
Constant Field Values

TIME_UNIT_WEEK

public static final long TIME_UNIT_WEEK
One of the possible time units. Equals the number of milliseconds in a week.

See Also:
Constant Field Values
Constructor Detail

Utilities

public Utilities()
Method Detail

error

public abstract java.lang.RuntimeException error(java.lang.String errorText)
Signals an error during the model run by throwing a RuntimeException with errorText preceded by the active object full name.

Parameters:
errorText - the text describing the error that will be displayed.
Returns:
actually this method never returns, it throws runtime exception by itself.
But the return type is defined for some cases when you would like to use the following form of call: throw error("my message");

error

public java.lang.RuntimeException error(java.lang.String errorTextFormat,
                                        java.lang.Object... args)
The same as error(String) but allows error format syntax like in String.format(String, Object...) method

See Also:
error(String), String.format(String, Object...)

time

public double time()
Returns the current model (logical) time. Time stays constant during an event execution and is only advanced between events.

Returns:
current model time

getTime

@Deprecated
public double getTime()
Deprecated. Use time() instead


date

public java.util.Date date()
Returns the current model date with respect to the start time/date and the model time unit.

Returns:
the current model date

timeToDate

public java.util.Date timeToDate(double t)
Converts the given model time to date with respect to the start date, start time and model time unit settings, null if the time is infinity.

Parameters:
t - the model time
Returns:
the date corresponding to the given model time, or null

dateToTime

public double dateToTime(java.util.Date d)
Converts the given date to model time with respect to the start date, start time and model time unit settings

Parameters:
d - the date to convert
Returns:
the model time corresponding to date

getMillisecond

public static int getMillisecond(java.util.Date date)
Returns the millisecond within the second of the given date.
E.g., at 10:04:15.250 PM the result is 250.

Parameters:
date - the date for which millisecond is returned
Returns:
the millisecond within the second of the given date

getSecond

public static int getSecond(java.util.Date date)
Returns the second within the minute of the given date.
E.g., at 10:04:15.250 PM the result is 15.

Parameters:
date - the date for which second is returned
Returns:
the second within the minute of the given date

getMinute

public static int getMinute(java.util.Date date)
Returns the minute within the hour of the given date.
E.g., at 10:04:15.250 PM the result is 4.

Parameters:
date - the date for which minute is returned
Returns:
the minute within the hour of the given date

getHour

public static int getHour(java.util.Date date)
Returns the hour of the morning or afternoon of the given date.
This method is used for the 12-hour clock.
Noon and midnight are represented by 0, not by 12.
E.g., at 10:04:15.250 PM the result is 10.

Parameters:
date - the date for which hour is returned
Returns:
the hour of the morning or afternoon of the given date
See Also:
getAmPm(Date), getHourOfDay(Date)

getAmPm

public static int getAmPm(java.util.Date date)
Indicates whether the hour of the given date is before (AM) or after (PM) noon.
This method is used for the 12-hour clock.
E.g., at 10:04:15.250 PM the result is PM.

Parameters:
date - the date for AM/PM information is returned
Returns:
AM or PM depending on the hour of the given date
See Also:
getHour(Date), getHourOfDay(Date)

getHourOfDay

public static int getHourOfDay(java.util.Date date)
Returns the hour of day of the given date.
This method is used for the 24-hour clock.
E.g., at 10:04:15.250 PM the result is 22.

Parameters:
date - the date for which hour of day is returned
Returns:
the hour of day of the given date
See Also:
getHour(Date), getAmPm(Date)

getDayOfWeek

public static int getDayOfWeek(java.util.Date date)
Returns the day of the week of the given date.
Returned value is one of:

Parameters:
date - the date for which day of the week is returned
Returns:
the day of the week of the given date

getDayOfMonth

public static int getDayOfMonth(java.util.Date date)
Returns the day of the month of the given date.
The first day of the month has value 1.

Parameters:
date - the date for which day of the month is returned
Returns:
the day of the month of the given date

getDayOfYear

public static int getDayOfYear(java.util.Date date)
Returns the day of the year of the given date.
The first day of the year has value 1.

Parameters:
date - the date for which day of the year is returned
Returns:
the day of the year of the given date

getMonth

public static int getMonth(java.util.Date date)
Returns the month of the given date.
This is a calendar-specific value.
The first month of the year in the Gregorian and Julian calendars is JANUARY which is 0; the last depends on the number of months in a year.
Possible values:

Parameters:
date - the date for which month is returned
Returns:
the month of the given date

getYear

public static int getYear(java.util.Date date)
Returns the year of the given date.
This is a calendar-specific value

Parameters:
date - the date for which year is returned
Returns:
the year of the given date

getMillisecond

public int getMillisecond()
Returns the millisecond within the second of the current model date with respect to the start time/date and the model time unit.
E.g., at 10:04:15.250 PM the result is 250.

Returns:
the millisecond within the second of the current model date with respect to the start time/date and the model time unit

getSecond

public int getSecond()
Returns the second within the minute of the current model date with respect to the start time/date and the model time unit.
E.g., at 10:04:15.250 PM the result is 15.

Returns:
the second within the minute of the current model date with respect to the start time/date and the model time unit

getMinute

public int getMinute()
Returns the minute within the hour of the current model date with respect to the start time/date and the model time unit.
E.g., at 10:04:15.250 PM the result is 4.

Returns:
the minute within the hour of the current model date with respect to the start time/date and the model time unit

getHour

public int getHour()
Returns the hour of the morning or afternoon of the current model date with respect to the start time/date and the model time unit.
This method is used for the 12-hour clock.
Noon and midnight are represented by 0, not by 12.
E.g., at 10:04:15.250 PM the result is 10.

Returns:
the hour of the morning or afternoon of the current model date with respect to the start time/date and the model time unit
See Also:
getAmPm(Date), getHourOfDay(Date)

getAmPm

public int getAmPm()
Indicates whether the hour of the current model date with respect to the start time/date and the model time unit is before (AM) or after (PM) noon.
This method is used for the 12-hour clock.
E.g., at 10:04:15.250 PM the result is PM.

Returns:
AM or PM depending on the hour of the current model date with respect to the start time/date and the model time unit
See Also:
getHour(Date), getHourOfDay(Date)

getHourOfDay

public int getHourOfDay()
Returns the hour of day of the current model date with respect to the start time/date and the model time unit.
This method is used for the 24-hour clock.
E.g., at 10:04:15.250 PM the result is 22.

Returns:
the hour of day of the current model date with respect to the start time/date and the model time unit
See Also:
getHour(Date), getAmPm(Date)

getDayOfWeek

public int getDayOfWeek()
Returns the day of the week of the current model date with respect to the start time/date and the model time unit.
Returned value is one of:

Returns:
the day of the week of the current model date with respect to the start time/date and the model time unit

getDayOfMonth

public int getDayOfMonth()
Returns the day of the month of the current model date with respect to the start time/date and the model time unit.
The first day of the month has value 1.

Returns:
the day of the month of the current model date with respect to the start time/date and the model time unit

getMonth

public int getMonth()
Returns the month of the current model date with respect to the start time/date and the model time unit.
This is a calendar-specific value.
The first month of the year in the Gregorian and Julian calendars is JANUARY which is 0; the last depends on the number of months in a year.
Possible values:

Returns:
the month of the current model date with respect to the start time/date and the model time unit

getYear

public int getYear()
Returns the year of the current model date with respect to the start time/date and the model time unit.
This is a calendar-specific value

Returns:
the year of the current model date with respect to the start time/date and the model time unit

toTimeout

public double toTimeout(int timeUnit,
                        double amount)
Returns timeout, in model time units, which equals to the given amount of timeUnits from current model date
e.g. toTimeout( DAY, 1 ) returns timeout in model time units from date() to the ( date() + 1 day )
Note, that the result of this method also depends on the current model date (because of leap years, daylight saving time tweaks) and therefore this method shouldn't be used for initialization of any constants

One of examples where this method should be used:
A model scheduling an event occurring each day at fixed time (e.g. 8:00): this method will return correct timeout on each call (even when time is switched to daylight-saving mode)
unlike day() which will always return timeout for 24 hours and may result in events scheduled at 7:00 or 9:00

Parameters:
timeUnit - time unit, possible values:
amount - the number of time units (may be negative - in this case result will be also negative)
Returns:
timeout, in model time units, which may be used e.g. to schedule an event in the given amount of timeUnits

differenceInDateUnits

public static double differenceInDateUnits(int timeUnit,
                                           java.util.Date date1,
                                           java.util.Date date2)
Returns the difference (date2 - date1) between two dates in the given time units.
Result is the number of time units that should be added to date1 to obtain date2
The result may be negative and may have fractional part depending on the given dates.

Parameters:
timeUnit - the time units for difference computation, possible values:
date1 - the first date
date2 - the second date
Returns:
the difference (date2 - date1) in the given time units

differenceInDateUnits

public double differenceInDateUnits(int timeUnit,
                                    double time1,
                                    double time2)
Returns the difference (time2 - time1) between two model dates (corresponding to the given model times) in the given time units.
Result is the number of date units that should be added to the model time time1 to obtain time2
The result may be negative and may have fractional part depending on the given dates.

Parameters:
timeUnit - the time units for difference computation, possible values:
time1 - the first model time
time2 - the second model time
Returns:
the difference (time2 - time1) in the given date units

dropTime

public static java.util.Date dropTime(java.util.Date date)
This utility method drops time-of-the-day information and returns the date with the time 00:00:00.000

Parameters:
date - the date
Returns:
the date with the time 00:00:00.000

trace

public static void trace(java.lang.Object o)
Prints a string representation of an object to the standard output stream.

Parameters:
o - the object to print

traceln

public static void traceln(java.lang.Object o)
Prints a string representation of an object with a line delimiter at the end to the standard output stream.

Parameters:
o - the object to print

traceln

public static void traceln()
Prints a line delimiter to the standard output stream.


traceln

public static void traceln(java.lang.String textFormat,
                           java.lang.Object... args)
The same as traceln(Object) but allows text format syntax like in String.format(String, Object...) method

See Also:
traceln(Object), String.format(String, Object...)

setDefaultRandomGenerator

public void setDefaultRandomGenerator(java.util.Random r)
Sets the random number generator used by all probability distributions by default, i.e. if no particular generator is specified in the call to a probability distribution function. Only the Random.nextDouble() and Random.nextGaussian() methods of the specified random number generator are called.

Parameters:
r - new random number generator.
See Also:
getDefaultRandomGenerator()

getDefaultRandomGenerator

public java.util.Random getDefaultRandomGenerator()
Retrieves the random number generator used by all probability distributions by default, i.e. if no particular generator is specified in the call to a probability distribution function.

Returns:
the default random number generator.
See Also:
setDefaultRandomGenerator(java.util.Random)

uniform

public double uniform()
Generates a random value uniformly distributed on the interval [0,1), the upper bound is not included.

Returns:
the generated sample.

uniform

public static double uniform(java.util.Random r)
Generates a random value uniformly distributed on the interval [0,1), using the specified random number generator.

Parameters:
r - the random number generator.
Returns:
the generated sample.

uniform_pos

public double uniform_pos()
Generates a positive random value uniformly distributed on the interval (0,1).

Returns:
the generated sample.

uniform_pos

public static double uniform_pos(java.util.Random r)
Generates a positive random value uniformly distributed on the interval (0,1), using the specified random number generator.

Parameters:
r - the random number generator.
Returns:
the generated sample.

uniform

public double uniform(double max)
Generates a sample of the Uniform distribution on the interval [0, max). Is equivalent to uniform(0, max). For more details see uniform(double,double).

Parameters:
max - the maximum x value.
Returns:
the generated sample.

uniform

public double uniform(double min,
                      double max)
Generates a sample of the Uniform distribution on the interval [min, max).

The Uniform distribution is a continuous distribution bounded on both sides, i.e. the sample lays in the interval [min,max). The probability density does not depend on the value of x. It is a special case of the Beta distribution. It is frequently called rectangular distribution (see Johnson et al).

The Uniform distribution is used to represent a random variable with constant likelihood of being in any small interval between min and max. Note that the probability of max value is 0; the max point never occurs.

Parameters:
min - the minimum x value.
max - the maximum x value.
Returns:
the generated sample.

uniform

public static double uniform(double min,
                             double max,
                             java.util.Random r)
Generates a sample of the Uniform distribution on the interval [min, max) using the specified random number generator. For more details see uniform(double,double).

Parameters:
min - the minimum x value.
max - the maximum x value.
r - the random number generator.
Returns:
the generated sample.

uniform_discr

public int uniform_discr(int max)
Generates a sample of the Discrete Uniform distribution in the interval [0, max], both 0 and max included! Is equivalent to uniform_discr(0, max). For more details see uniform_discr(int,int).

Parameters:
max - the maximum x value.
Returns:
the generated sample.

uniform_discr

public int uniform_discr(int min,
                         int max)
Generates a sample of the Discrete Uniform distribution on the interval [min, max], both min and max included!

The Discrete Uniform distribution is a discrete distribution bounded on [min, max] with constant probability at every value on or between the bounds. Sometimes called the discrete rectangular distribution, it arises when an event can have a finite and equally probable number of outcomes.

Parameters:
min - the minimum x value.
max - the maximum x value.
Returns:
the generated sample.

uniform_discr

public static int uniform_discr(int min,
                                int max,
                                java.util.Random r)
Generates a sample of the Discrete Uniform distribution on the interval [min, max] using the specified random number generator, both 0 and max included! For more details see uniform_discr(int,int).

Parameters:
min - the minimum x value.
max - the maximum x value.
r - the random number generator.
Returns:
the generated sample.

randomTrue

public boolean randomTrue(double p)
Generates true with the given probability p. Is equivalent to uniform() < p. The probability of false is 1 - p correspondingly.

Parameters:
p - the probability of true.
Returns:
true with probability p, false with probability 1 - p.
See Also:
randomFalse(double), bernoulli(double)

randomTrue

public static boolean randomTrue(double p,
                                 java.util.Random r)
Generates true with the given probability p using the specified random number generator.
For more details see randomTrue(double)

Parameters:
p - the probability of true.
r - the random number generator.
Returns:
true with probability p, false with probability 1 - p.
See Also:
randomFalse(double, Random), bernoulli(double, Random)

randomFalse

public boolean randomFalse(double p)
Generates false with the given probability p. Is equivalent to uniform() >= p. The probability of true is 1 - p correspondingly.

Parameters:
p - the probability of false.
Returns:
false with probability p, true with probability 1 - p
See Also:
randomTrue(double), bernoulli(double)

randomFalse

public static boolean randomFalse(double p,
                                  java.util.Random r)
Generates false with the given probability p using the specified random number generator.
For more details see randomFalse(double)

Parameters:
p - the probability of false.
r - the random number generator.
Returns:
false with probability p, true with probability 1 - p
See Also:
randomTrue(double, Random), bernoulli(double, Random)

getRandom

public <T> T getRandom(java.util.Collection<T> collection)
Returns the randomly chosen element of the given collection.
For empty collections return null.
This result of this method is an equivalent of calling: collection.get( uniform_discr( collection.size() - 1 ) )

Parameters:
collection - the collection to select an element from
Returns:
the randomly chosen element or null, if collection is empty

getRandom

public static <T> T getRandom(java.util.Collection<T> collection,
                              java.util.Random r)
Returns the randomly chosen element of the given collection. Uses the specified random number generator to choose the element.
For more details see getRandom(Collection)

Parameters:
collection - the collection to select an element from
r - the random number generator.
Returns:
the randomly chosen element or null, if collection is empty

bernoulli

public int bernoulli(double p)
Generates a sample of the Bernoulli distribution, i.e. 1 with probability p and 0 with probability 1 - p.

Parameters:
p - the probability of 1.
Returns:
the generated sample.

bernoulli

public static int bernoulli(double p,
                            java.util.Random r)
Generates a sample of the Bernoulli distribution using the specified random number generator. For more details see bernoulli(double).

Parameters:
p - the probability of 1.
r - the random number generator.
Returns:
the generated sample.

beta

public double beta(double p,
                   double q)
Generates a sample of the Beta distribution with min set to 0 and max set to 1. Is equivalent to beta(p, q, 0, 1). For more details see beta(double,double,double,double).

Parameters:
p - the lower shape parameter > 0.
q - the upper shape parameter > 0.
Returns:
the generated sample.

beta

public double beta(double p,
                   double q,
                   double min,
                   double max)
Generates a sample of the Beta distribution.

The Beta distribution is a continuous distribution that has both upper and lower finite bounds. Because many real situations can be bounded in this way, the Beta distribution can be used empirically to estimate the actual distribution before much data is available. Even when data is available, the Beta distribution should fit most data in a reasonable fashion, although it may not be the best fit. The Uniform distribution is a special case of the Beta distribution with p, q = 1.

The Beta distribution can approach zero or infinity at either of its bounds, with p controlling the lower bound and q controlling the upper bound. Values of p, q < 1 cause the Beta distribution to approach infinity at that bound. Values of p, q > 1 cause the Beta distribution to be finite at that bound.

Beta distributions have many, many uses. As summarized in Johnson et al Beta distributions have been used to model distributions of hydrologic variables, logarithm of aerosol sizes, activity time in PERT analysis, isolation data in photovoltaic system analysis, porosity / void ratio of soil, phase derivatives in communication theory, size of progeny in Escherchia Coli, dissipation rate in breakage models, proportions in gas mixtures, steady-state reflectivity, clutter and power of radar signals, construction duration, particle size, tool wear, and others. Many of these uses occur because of the doubly bounded nature of the Beta distribution.

Parameters:
p - the lower shape parameter > 0.
q - the upper shape parameter > 0.
min - the minimum x value.
max - the maximum x value.
Returns:
the generated sample.

beta

public double beta(double min,
                   double max,
                   double p,
                   double q,
                   double shift,
                   double stretch)
Generates a sample of truncated Beta distribution.
Distribution beta(p, q, 0, 1) is stretched by stretch coefficient, then shifted to the right by shift, after that it is truncated to fit in [min, max] interval. Truncation is performed by discarding every sample outside this interval and taking subsequent try.
For more details see beta(double, double, double, double)

Parameters:
min - the minimum value that this function will return. The distribution is truncated to return values above this. If the sample (stretched and shifted) is below this value it will be discarded and another sample will be drawn. Use Double.NEGATIVE_INFINITY for "No limit".
max - the maximum value that this function will return. The distribution is truncated to return values below this. If the sample (stretched and shifted) is bigger than this value it will be discarded and another sample will be drawn. Use Double.POSITIVE_INFINITY for "No limit".
p - the lower shape parameter > 0. Also known as alpha parameter
q - the upper shape parameter > 0. Also known as beta parameter
shift - the shift parameter that indicates how much the (stretched) distribution will shifted to the right
stretch - the stretch parameter that indicates how much the distribution will be stretched
Returns:
the generated sample.

beta

public static double beta(double p,
                          double q,
                          double min,
                          double max,
                          java.util.Random r)
Generates a sample of the Beta distribution using the specified random number generator. For more details see beta(double,double,double,double).

Parameters:
p - the lower shape parameter > 0.
q - the upper shape parameter > 0.
min - the minimum x value.
max - the maximum x value.
r - the random number generator.
Returns:
the generated sample.

beta

public static double beta(double min,
                          double max,
                          double p,
                          double q,
                          double shift,
                          double stretch,
                          java.util.Random r)
Generates a sample of truncated Beta distribution using the specified random number generator.
Distribution beta(p, q, 0, 1) is stretched by stretch coefficient, then shifted to the right by shift, after that it is truncated to fit in [min, max] interval. Truncation is performed by discarding every sample outside this interval and taking subsequent try.
For more details see beta(double, double, double, double)

Parameters:
min - the minimum value that this function will return. The distribution is truncated to return values above this. If the sample (stretched and shifted) is below this value it will be discarded and another sample will be drawn. Use Double.NEGATIVE_INFINITY for "No limit".
max - the maximum value that this function will return. The distribution is truncated to return values below this. If the sample (stretched and shifted) is bigger than this value it will be discarded and another sample will be drawn. Use Double.POSITIVE_INFINITY for "No limit".
p - the lower shape parameter > 0. Also known as alpha parameter
q - the upper shape parameter > 0. Also known as beta parameter
shift - the shift parameter that indicates how much the (stretched) distribution will shifted to the right
stretch - the stretch parameter that indicates how much the distribution will be stretched
r - the random number generator.
Returns:
the generated sample.

binomial

public int binomial(double p)
Generates a sample of the Binomial distribution with n set to 1. Is equivalent to binomial(p, 1). For more details see binomial(double,int).

Parameters:
p - the p parameter of the Binomial distribution, i.e. the probability of the event occurrence.
Returns:
the generated sample.

binomial

public int binomial(double p,
                    int n)
Generates a sample of the Binomial distribution.

Parameters:
p - the probability of the event occurrence.
n - the number of trials.
Returns:
the generated sample.

binomial

public double binomial(double min,
                       double max,
                       double p,
                       double n,
                       double shift,
                       double stretch)
Generates a sample of truncated Binomial distribution.
Distribution binomial(p, n) is stretched by stretch coefficient, then shifted to the right by shift, after that it is truncated to fit in [min, max] interval. Truncation is performed by discarding every sample outside this interval and taking subsequent try.
For more details see binomial(double, int)

Parameters:
min - the minimum value that this function will return. The distribution is truncated to return values above this. If the sample (stretched and shifted) is below this value it will be discarded and another sample will be drawn. Use Double.NEGATIVE_INFINITY for "No limit".
max - the maximum value that this function will return. The distribution is truncated to return values below this. If the sample (stretched and shifted) is bigger than this value it will be discarded and another sample will be drawn. Use Double.POSITIVE_INFINITY for "No limit".
p - the probability of the event occurrence.
n - the number of trials. If n is not an integer it will be rounded to the nearest integer.
shift - the shift parameter that indicates how much the (stretched) distribution will shifted to the right
stretch - the stretch parameter that indicates how much the distribution will be stretched
Returns:
the generated sample, note that in common case it is not an integer (because of stretching).

binomial

public static int binomial(double p,
                           int n,
                           java.util.Random r)
Generates a sample of the Binomial distribution using the specified random number generator.

Parameters:
p - the probability of the event occurrence.
n - the number of trials.
r - the random number generator.
Returns:
the generated sample.

binomial

public static double binomial(double min,
                              double max,
                              double p,
                              double n,
                              double shift,
                              double stretch,
                              java.util.Random r)
Generates a sample of truncated Binomial distribution using the specified random number generator.
Distribution binomial(p, n) is stretched by stretch coefficient, then shifted to the right by shift, after that it is truncated to fit in [min, max] interval. Truncation is performed by discarding every sample outside this interval and taking subsequent try.
For more details see binomial(double, int)

Parameters:
min - the minimum value that this function will return. The distribution is truncated to return values above this. If the sample (stretched and shifted) is below this value it will be discarded and another sample will be drawn. Use Double.NEGATIVE_INFINITY for "No limit".
max - the maximum value that this function will return. The distribution is truncated to return values below this. If the sample (stretched and shifted) is bigger than this value it will be discarded and another sample will be drawn. Use Double.POSITIVE_INFINITY for "No limit".
p - the probability of the event occurrence.
n - the number of trials. If n is not an integer it will be rounded to the nearest integer.
shift - the shift parameter that indicates how much the (stretched) distribution will shifted to the right
stretch - the stretch parameter that indicates how much the distribution will be stretched
r - the random number generator.
Returns:
the generated sample, note that in common case it is not an integer (because of stretching).

cauchy

public double cauchy(double lambda)
Generates a sample of the Cauchy distribution with theta set to 0. Is equivalent to cauchy(lambda, 0). For more details see cauchy(double,double).

Parameters:
lambda - the scaling parameter > 0.
Returns:
the generated sample.

cauchy

public double cauchy(double lambda,
                     double theta)
Generates a sample of the Cauchy distribution.

The Cauchy distribution is an unbounded continuous distribution that has a sharp central peak but significantly broad tails. The tails are much heavier than the tails of the Normal distribution.

The Cauchy distribution can be used to represent the ratio of two equally distributed parameters in certain cases, e.g. the ratio of two normal parameters. This distribution has no finite moments because of its extensive tails. Thus it can also be used to generate wildly divergent data a long as the data has a central tendency.

Parameters:
lambda - the scaling parameter > 0.
theta - the mode, or central peak position.
Returns:
the generated sample.

cauchy

public static double cauchy(double lambda,
                            double theta,
                            java.util.Random r)
Generates a sample of the Cauchy distribution using the specified random number generator. For more details see cauchy(double,double).

Parameters:
lambda - the scaling parameter > 0.
theta - the mode, or central peak position.
r - the random number generator.
Returns:
the generated sample.

chi2

public double chi2(double nu)
Generates a sample of the Chi Squared distribution with min set to 0. Is equivalent to chi2(nu, 0). For more details see chi2(double,double)

Parameters:
nu - the shape parameter.
Returns:
the generated sample.

chi2

public double chi2(double nu,
                   double min)
Generates a sample of the Chi Squared distribution.

The Chi Squared is a continuous distribution bounded on the lower side. Note that the Chi Squared distribution is a subset of the Gamma distribution with beta=2 and alpha=nµ/2. Like the Gamma distribution, it has three distinct regions. For nµ=2, the Chi Squared distribution reduces to the Exponential distribution, starting at a finite value at minimum x and decreasing monotonically thereafter. For nµ<2, the Chi Squared distribution tends to infinity at minimum x and decreases monotonically for increasing x. For nµ>2, the Chi Squared distribution is 0 at minimum x, peaks at a value that depends on nµ, decreasing monotonically thereafter.

Because the Chi Squared distribution does not have a scaling parameter, its utilization is somewhat limited. Frequently, this distribution will try to represent data with a clustered distribution with nµ less than 2. However, it can be viewed as the distribution of the sum of squares of independent unit normal variables with nµ degrees of freedom and is used in many statistical tests.

Examples of each of the regions of the Chi Squared distribution are shown above. Note that the peak of the distribution moves away from the minimum value for increasing nu, but with a much broader distribution.

Parameters:
nu - the shape parameter.
min - the minimum x value.
Returns:
the generated sample.

chi2

public static double chi2(double nu,
                          double min,
                          java.util.Random r)
Generates a sample of the Chi Squared distribution using the specified random number generator. For more details see chi2(double,double).

Parameters:
nu - the shape parameter.
min - the minimum x value.
r - the random number generator.
Returns:
the generated sample.

erlang

public double erlang(double beta,
                     int m)
Generates a sample of the Erlang distribution with min set to 0. Is equivalent to erlang(beta, m, 0). For more details see erlang(double,int,double)/

Parameters:
beta - the scale factor > 0.
m - the shape factor (positive integer).
Returns:
the generated sample.

erlang

public double erlang(double beta,
                     int m,
                     double min)
Generates a sample of the Erlang distribution.

The Erlang distribution is a continuous distribution bounded on the lower side. It is a special case of the Gamma distribution where the parameter, m, is restricted to a positive integer. As such, the Erlang distribution has no region where F(x) tends to infinity at the minimum value of x [m<1], but does have a special case at m=1, where it reduces to the Exponential distribution.

The Erlang distribution has been used extensively in reliability and in queuing theory, thus in discrete event simulation, because it can be viewed as the sum of m exponentially distributed random variables, each with mean beta.

Parameters:
beta - the scale factor > 0.
m - the shape factor (positive integer).
min - the minimum x value.
Returns:
the generated sample.

erlang

public static double erlang(double beta,
                            int m,
                            double min,
                            java.util.Random r)
Generates a sample of the Erlang distribution using the specified random number generator. For more details see erlang(double,int,double).

Parameters:
beta - the scale factor > 0.
m - the shape factor (positive integer).
min - the minimum x value.
r - the random number generator.
Returns:
the generated sample.

exponential

public double exponential()
Generates a sample of the Exponential distribution with lambda set to 1 and min set to 0. Is equivalent to exponential(1, 0). For more details see exponential(double,double)

Returns:
the generated sample.

exponential

public double exponential(double lambda)
Generates a sample of the Exponential distribution with min set to 0. Is equivalent to exponential(lambda, 0). For more details see exponential(double,double).

Parameters:
lambda - the shape parameter.
Returns:
the generated sample.

exponential

public double exponential(double lambda,
                          double min)
Generates a sample of the Exponential distribution.

The Exponential distribution is a continuous distribution bounded on the lower side. It’s shape is always the same, starting at a finite value at the minimum and continuously decreasing at larger x. The Exponential distribution decreases rapidly for increasing x.

The Exponential distribution is frequently used to represent the time between random occurrences, such as the time between arrivals at a specific location in a queuing model or the time between failures in reliability models. It has also been used to represent the services times of a specific operation. Further, it serves as an explicit manner in which the time dependence on noise may be treated. As such, these models are making explicit use of the lack of history dependence of the exponential distribution; it has the same set of probabilities when shifted in time. Even when Exponential models are known to be inadequate to describe the situation, their mathematical tractability provides a good starting point. Later, a more complex distribution such as Erlang or Weibull may be investigated.

Parameters:
lambda - the shape parameter.
min - the minimum x value.
Returns:
the generated sample.

exponential

public double exponential(double min,
                          double max,
                          double shift,
                          double stretch)
Generates a sample of truncated Exponential distribution.
Distribution exponential(1, 0) is stretched by stretch coefficient, then shifted to the right by shift, after that it is truncated to fit in [min, max] interval. Truncation is performed by discarding every sample outside this interval and taking subsequent try.
For more details see exponential(double, double)

Parameters:
min - the minimum value that this function will return. The distribution is truncated to return values above this. If the sample (stretched and shifted) is below this value it will be discarded and another sample will be drawn. Use Double.NEGATIVE_INFINITY for "No limit".
max - the maximum value that this function will return. The distribution is truncated to return values below this. If the sample (stretched and shifted) is bigger than this value it will be discarded and another sample will be drawn. Use Double.POSITIVE_INFINITY for "No limit".
shift - the shift parameter that indicates how much the (stretched) distribution will shifted to the right
stretch - the stretch parameter that indicates how much the distribution will be stretched
Returns:
the generated sample

exponential

public static double exponential(double lambda,
                                 double min,
                                 java.util.Random r)
Generates a sample of the Exponential distribution using the specified random number generator. For more details see exponential(double,double).

Parameters:
lambda - the shape parameter.
min - the minimum x value.
r - the random number generator.
Returns:
the generated sample.

exponential

public static double exponential(double min,
                                 double max,
                                 double shift,
                                 double stretch,
                                 java.util.Random r)
Generates a sample of truncated Exponential distribution using the specified random number generator.
Distribution exponential(1, 0) is stretched by stretch coefficient, then shifted to the right by shift, after that it is truncated to fit in [min, max] interval. Truncation is performed by discarding every sample outside this interval and taking subsequent try.
For more details see exponential(double, double)

Parameters:
min - the minimum value that this function will return. The distribution is truncated to return values above this. If the sample (stretched and shifted) is below this value it will be discarded and another sample will be drawn. Use Double.NEGATIVE_INFINITY for "No limit".
max - the maximum value that this function will return. The distribution is truncated to return values below this. If the sample (stretched and shifted) is bigger than this value it will be discarded and another sample will be drawn. Use Double.POSITIVE_INFINITY for "No limit".
shift - the shift parameter that indicates how much the (stretched) distribution will shifted to the right
stretch - the stretch parameter that indicates how much the distribution will be stretched
r - the random number generator.
Returns:
the generated sample

gamma

public double gamma(double alpha,
                    double beta)
Generates a sample of the Gamma distribution with min set to 0. Is equivalent to gamma(alpha, beta, 0). For more details see gamma(double,double,double).

Parameters:
alpha - the shape parameter > 0.
beta - the scale parameter > 0.
Returns:
the generated sample.

gamma

public double gamma(double alpha,
                    double beta,
                    double min)
Generates a sample of the Gamma distribution.

The Gamma distribution is a continuous distribution bounded at the lower side. It has three distinct regions. For ?=1, the Gamma distribution reduces to the Exponential distribution, starting at a finite value at minimum x and decreasing monotonically thereafter. For ?<1, the Gamma distribution tends to infinity at minimum x and decreases monotonically for increasing x. For ?>1, the Gamma distribution is 0 at minimum x, peaks at a value that depends on both alpha and beta, decreasing monotonically thereafter. If alpha is restricted to positive integers, the Gamma distribution is reduced to the Erlang distribution.

Note that the Gamma distribution also reduces to the Chi Squared distribution for min=0, ?=2, and ?=nµ/2. It can then be viewed as the distribution of the sum of squares of independent unit normal variables, with nµ degrees of freedom and is used in many statistical tests.

The Gamma distribution can also be used to approximate the Normal distribution, for large alpha, while maintaining its strictly positive values of x [actually (x-min)].

The Gamma distribution has been used to represent lifetimes, lead times, personal income data, a population about a stable equilibrium, interarrival times, and service times. In particular, it can represent lifetime with redundancy (see Johnson9, Shooman10).

Examples of each of the regions of the Gamma distribution are shown above. Note the peak of the distribution moving away from the minimum value for increasing alpha, but with a much broader distribution.

Parameters:
alpha - the shape parameter > 0.
beta - the scale parameter > 0.
min - the minimum x value.
Returns:
the generated sample.

gamma

public double gamma(double min,
                    double max,
                    double alpha,
                    double shift,
                    double stretch)
Generates a sample of truncated Gamma distribution.
Distribution gamma(alpha, 1, 0) is stretched by stretch coefficient, then shifted to the right by shift, after that it is truncated to fit in [min, max] interval. Truncation is performed by discarding every sample outside this interval and taking subsequent try.
For more details see gamma(double, double, double)

Parameters:
min - the minimum value that this function will return. The distribution is truncated to return values above this. If the sample (stretched and shifted) is below this value it will be discarded and another sample will be drawn. Use Double.NEGATIVE_INFINITY for "No limit".
max - the maximum value that this function will return. The distribution is truncated to return values below this. If the sample (stretched and shifted) is bigger than this value it will be discarded and another sample will be drawn. Use Double.POSITIVE_INFINITY for "No limit".
alpha - the shape parameter > 0. Also known as order. If less than 1, then 1 will be used.
shift - the shift parameter that indicates how much the (stretched) distribution will shifted to the right
stretch - the stretch parameter that indicates how much the distribution will be stretched
Returns:
the generated sample

gamma

public static double gamma(double alpha,
                           double beta,
                           double min,
                           java.util.Random r)
Generates a sample of the Gamma distribution using the specified random number generator. For more details see gamma(double,double,double).

Parameters:
alpha - the shape parameter > 0.
beta - the scale parameter > 0.
min - the minimum x value.
r - the random number generator.
Returns:
the generated sample.

gamma_frac

public static double gamma_frac(double a,
                                java.util.Random r)

gamma

public static double gamma(double min,
                           double max,
                           double alpha,
                           double shift,
                           double stretch,
                           java.util.Random r)
Generates a sample of truncated Gamma distribution using the specified random number generator.
Distribution gamma(alpha, 1, 0) is stretched by stretch coefficient, then shifted to the right by shift, after that it is truncated to fit in [min, max] interval. Truncation is performed by discarding every sample outside this interval and taking subsequent try.
For more details see gamma(double, double, double)

Parameters:
min - the minimum value that this function will return. The distribution is truncated to return values above this. If the sample (stretched and shifted) is below this value it will be discarded and another sample will be drawn. Use Double.NEGATIVE_INFINITY for "No limit".
max - the maximum value that this function will return. The distribution is truncated to return values below this. If the sample (stretched and shifted) is bigger than this value it will be discarded and another sample will be drawn. Use Double.POSITIVE_INFINITY for "No limit".
alpha - the shape parameter > 0. Also known as order. If less than 1, then 1 will be used.
shift - the shift parameter that indicates how much the (stretched) distribution will shifted to the right
stretch - the stretch parameter that indicates how much the distribution will be stretched
r - the random number generator.
Returns:
the generated sample

geometric

public int geometric(double p)
Generates a sample of the Geometric distribution.

The Geometric distribution is a discrete distribution bounded at 0 and unbounded on the high side. It is a special case of the Negative Binomial distribution. In particular, it is the direct discrete analog for the continuous Exponential distribution. The Geometric distribution has no history dependence, its probability at any value being independent of a shift along the axis.

Generated sample has the distribution of the number X of trials needed to get one success. Returned values are { 1, 2, 3, ... }. If you need 'geometric' in terms of "number of failures before the 1st success", please use the expression geometric( p ) - 1.

The Geometric distribution has been used for inventory demand, marketing survey returns, a ticket control problem, and meteorological models.

Parameters:
p - the probability of occurrence.
Returns:
the generated sample.

geometric

public static int geometric(double p,
                            java.util.Random r)
Generates a sample of the Geometric distribution using the specified random number generator. For more details see geometric(double).

Parameters:
p - the probability of occurrence.
r - the random number generator.
Returns:
the generated sample.

hypergeometric

public int hypergeometric(int ss,
                          int dn,
                          int ps)
Generates a sample of the Hypergeometric distribution.

The Hypergeometric distribution is a discrete distribution bounded by [0,s]. It describes the number of defects, x, in a sample of size s from a population of size N which has m total defects. The ratio of m/N = p is sometimes used rather than m to describe the probability of a defect. Note that defects may be interpreted as successes, in which case x is the number of failures until (s-x) successes. The sample is taken without replacement.

The Hypergeometric distribution is used to describe sampling from a population where an estimate of the total number of defects is desired. It has also been used to estimate the total population of species from a tagged subset. However, estimates of all three parameters from a data set are notoriously fickle and error prone, so use of these parameters to estimate a physical quantity without specifying at least one of the parameters is not recommended. (see Johnson et. al.1)

Parameters:
ss - the sample size.
dn - the number of defects in the population.
ps - the size of the population.
Returns:
the generated sample.

hypergeometric

public static int hypergeometric(int ss,
                                 int dn,
                                 int ps,
                                 java.util.Random r)
Generates a sample of the Hypergeometric distribution using the specified random number generator. For more details see hypergeometric(int,int,int).

Parameters:
ss - the sample size.
dn - the number of defects in the population.
ps - the size of the population.
Returns:
the generated sample.

gumbel1

public double gumbel1(double a,
                      double b)
Generates a sample of the Type I Gumbel distribution.
This distribution has the form
p(x) = a b exp(-(b exp(-ax) + ax))

Parameters:
a - the 'a' parameter
b - the 'b' parameter
Returns:
the generated sample.

gumbel1

public static double gumbel1(double a,
                             double b,
                             java.util.Random r)
Generates a sample of the Type I Gumbel distribution using the specified random number generator. For more details see gumbel1(double,double).

Parameters:
a - the 'a' parameter
b - the 'b' parameter
r - the random number generator.
Returns:
the generated sample.

gumbel2

public double gumbel2(double a,
                      double b)
Generates a sample of the Type II Gumbel distribution.
This distribution has the form
p(x) = b a x^-(a+1) exp(-b x^-a))

Parameters:
a - the 'a' parameter
b - the 'b' parameter
Returns:
the generated sample.

gumbel2

public static double gumbel2(double a,
                             double b,
                             java.util.Random r)
Generates a sample of the Type II Gumbel distribution using the specified random number generator. For more details see gumbel2(double,double).

Parameters:
a - the 'a' parameter
b - the 'b' parameter
r - the random number generator.
Returns:
the generated sample.

laplace

public double laplace(double phi,
                      double theta)
Generates a sample of the Laplace distribution.

The Laplace distribution, sometimes called the double exponential distribution, is an unbounded continuous distribution that has a very sharp central peak, located at theta. The distribution scales with phi.

The Laplace distribution can be used to describe the difference of two independent, and equally distributed, exponentials. It is also used in error analysis. (see Johnson et.al.1)

Parameters:
phi - the scaling parameter.
theta - the mode, or central peak position.
Returns:
the generated sample.

laplace

public static double laplace(double phi,
                             double theta,
                             java.util.Random r)
Generates a sample of the Laplace distribution using the specified random number generator. For more details see laplace(double,double).

Parameters:
phi - the scaling parameter.
theta - the mode, or central peak position.
r - the random number generator.
Returns:
the generated sample.

logarithmic

public int logarithmic(double theta)
Generates a sample of the Logarithmic distribution.

The Logarithmic distribution is a discrete distribution bounded by [1,...]. Theta is related to the sample size and the mean.

The Logarithmic distribution is used to describe the diversity of a sample, that is, how many of a given type of thing are contained in a sample of things. For instance, this distribution has been used to describe the number of individuals of a given species in a sampling of mosquitoes, or the number of parts of a given type in a sampling of inventory. (see Johnson et.al.1)

Parameters:
theta - the shape/scale parameter 0Returns:
the generated sample.

logarithmic

public static int logarithmic(double theta,
                              java.util.Random r)
Generates a sample of the Logarithmic distribution using the specified random number generator. For more details see logarithmic(double).

Parameters:
theta - the shape/scale parameter 0r - the random number generator.
Returns:
the generated sample.

logistic

public double logistic(double beta,
                       double alpha)
Generates a sample of the Logistic distribution.

The Logistic distribution is an unbounded continuous distribution which is symmetrical about its mean [and shift parameter], alpha. The shape of the Logistic distribution is very much like the Normal distribution, except that the Logistic distribution has broader tails.

The Logistic function is most often used a growth model: for populations, for weight gain, for business failure, etc. The Logistic distribution can be can be used to test for the suitability of such a model, with transformation to get back to the minimum and maximum values for the Logistic function. Occasionally, the Logistic function is used in place of the Normal function where exceptional cases play a larger role.(see Johnson et. al.1)

Parameters:
beta - the scale parameter > 0.
alpha - the shift parameter.
Returns:
the generated sample.

logistic

public static double logistic(double beta,
                              double alpha,
                              java.util.Random r)
Generates a sample of the Logistic distribution using the specified random number generator. For more details see logistic(double,double).

Parameters:
beta - the scale parameter > 0.
alpha - the shift parameter.
r - the random number generator.
Returns:
the generated sample.

lognormal

public double lognormal(double mu,
                        double sigma,
                        double min)
Generates a sample of the Lognormal distribution.

The Lognormal distribution is a continuous distribution bounded on the lower side. It is always 0 at minimum x, rising to a peak that depends on both mu and sigma, then decreasing monotonically for increasing x.

By definition, the natural logarithm of a Lognormal random variable is a Normal random variable. Its parameters are usually given in terms of this included Normal.

The Lognormal distribution can also be used to approximate the Normal distribution, for small sigma, while maintaining its strictly positive values of x [actually (x-min)].

The Lognormal distribution is used in many different areas including the distribution of particle size in naturally occurring aggregates, dust concentration in industrial atmospheres, the distribution of minerals present in low, concentrations, duration of sickness absence, physicians' consultant time, lifetime distributions in reliability, distribution of income, employee retention, and many applications modeling weight, height, etc.(see Johnson et. al.1)

Parameters:
mu - the mean of the included Normal.
sigma - the standard deviation of the included Normal.
min - the minimum x value.
Returns:
the generated sample.

lognormal

public static double lognormal(double mu,
                               double sigma,
                               double min,
                               java.util.Random r)
Generates a sample of the Lognormal distribution using the specified random number generator. For more details see lognormal(double,double,double).

Parameters:
mu - the mean of the included Normal.
sigma - the standard deviation of the included Normal.
min - the minimum x value.
r - the random number generator.
Returns:
the generated sample.

negativeBinomial

public int negativeBinomial(double p,
                            double n)
Generates a sample of the Negative Binomial distribution.

The Negative Binomial distribution is a discrete distribution bounded on the low side at 0 and unbounded on the high side. The Negative Binomial distribution reduces to the Geometric Distribution for n = 1. The Negative Binomial distribution gives the total number of trials, x, to get k events (failures...), each with the constant probability, p, of occurring.

The Negative Binomial distribution has many uses; some occur because it provides a good approximation for the sum or mixing of other discrete distributions. By itself, it is used to model accident statistics, birth-and-death processes, market research and consumer expenditure, lending library data, biometrical data, and many others. (see Johnson et. al.1)

Parameters:
p - the probability of event (in the interval [0,1]).
n - the number of desired events.
Returns:
the generated sample.

negativeBinomial

public double negativeBinomial(double min,
                               double max,
                               double p,
                               double n,
                               double shift,
                               double stretch)
Generates a sample of truncated Negative Binomial distribution.
Distribution negativeBinomial(p, n) is stretched by stretch coefficient, then shifted to the right by shift, after that it is truncated to fit in [min, max] interval. Truncation is performed by discarding every sample outside this interval and taking subsequent try.
For more details see negativeBinomial(double, double)

Parameters:
min - the minimum value that this function will return. The distribution is truncated to return values above this. If the sample (stretched and shifted) is below this value it will be discarded and another sample will be drawn. Use Double.NEGATIVE_INFINITY for "No limit".
max - the maximum value that this function will return. The distribution is truncated to return values below this. If the sample (stretched and shifted) is bigger than this value it will be discarded and another sample will be drawn. Use Double.POSITIVE_INFINITY for "No limit".
p - the probability of the event occurrence.
n - the number of trials. If n is not an integer it will be rounded to the nearest integer.
shift - the shift parameter that indicates how much the (stretched) distribution will shifted to the right
stretch - the stretch parameter that indicates how much the distribution will be stretched
Returns:
the generated sample

negativeBinomial

public static int negativeBinomial(double p,
                                   double n,
                                   java.util.Random r)
Generates a sample of the Negative Binomial distribution using the specified random number generator. For more details see negativeBinomial(double,double).

Parameters:
p - the probability of event (in the interval [0,1]).
n - the number of desired events.
r - the random number generator.
Returns:
the generated sample.

negativeBinomial

public static double negativeBinomial(double min,
                                      double max,
                                      double p,
                                      double n,
                                      double shift,
                                      double stretch,
                                      java.util.Random r)
Generates a sample of truncated Negative Binomial distribution using the specified random number generator.
Distribution negativeBinomial(p, n) is stretched by stretch coefficient, then shifted to the right by shift, after that it is truncated to fit in [min, max] interval. Truncation is performed by discarding every sample outside this interval and taking subsequent try.
For more details see negativeBinomial(double, double)

Parameters:
min - the minimum value that this function will return. The distribution is truncated to return values above this. If the sample (stretched and shifted) is below this value it will be discarded and another sample will be drawn. Use Double.NEGATIVE_INFINITY for "No limit".
max - the maximum value that this function will return. The distribution is truncated to return values below this. If the sample (stretched and shifted) is bigger than this value it will be discarded and another sample will be drawn. Use Double.POSITIVE_INFINITY for "No limit".
p - the probability of the event occurrence.
n - the number of trials. If n is not an integer it will be rounded to the nearest integer.
shift - the shift parameter that indicates how much the (stretched) distribution will shifted to the right
stretch - the stretch parameter that indicates how much the distribution will be stretched
r - the random number generator.
Returns:
the generated sample

normal

public double normal()
Generates a sample of the Normal distribution with mean set to 0 and sigma set to 1. Is equivalent to normal(1, 0). For more details see normal(double,double).

Returns:
the generated sample.

normal

public double normal(double sigma)
Generates a sample of the Normal distribution with mean set to 0. Is equivalent to normal(sigma, 0). For more details see normal(double,double)

Parameters:
sigma - the shape parameter = standard deviation.
Returns:
the generated sample.

normal

public double normal(double sigma,
                     double mean)
Generates a sample of the Normal distribution.

The Normal distribution is an unbounded continuous distribution. It is sometimes called a Gaussian distribution or the bell curve. Because of its property of representing an increasing sum of small, independent errors, the Normal distribution finds many, many uses in statistics. It is wrongly used in many situations. Possibly, the most important test in the fitting of analytical distributions is the elimination of the Normal distribution as a possible candidate.

The Normal distribution is used as an approximation for the Binomial distribution when the values of n, p are in the appropriate range. The Normal distribution is frequently used to represent symmetrical data, but suffers from being unbounded in both directions. If the data is known to have a lower bound, it may be better represented by suitable parameterization of the Lognormal, Weibull or Gamma distributions. If the data is known to have both upper and lower bounds, the Beta distribution can be used, although much work has been done on truncated Normal distributions.

Parameters:
sigma - the shape parameter = standard deviation.
mean - the shift parameter = mean value.
Returns:
the generated sample.

normal

public double normal(double min,
                     double max,
                     double shift,
                     double stretch)
Generates a sample of truncated Normal distribution.
Distribution normal(1, 0) is stretched by stretch coefficient, then shifted to the right by shift, after that it is truncated to fit in [min, max] interval. Truncation is performed by discarding every sample outside this interval and taking subsequent try.
For more details see normal(double, double)

Parameters:
min - the minimum value that this function will return. The distribution is truncated to return values above this. If the sample (stretched and shifted) is below this value it will be discarded and another sample will be drawn. Use Double.NEGATIVE_INFINITY for "No limit".
max - the maximum value that this function will return. The distribution is truncated to return values below this. If the sample (stretched and shifted) is bigger than this value it will be discarded and another sample will be drawn. Use Double.POSITIVE_INFINITY for "No limit".
shift - the shift parameter that indicates how much the (stretched) distribution will shifted to the right = mean value
stretch - the stretch parameter that indicates how much the distribution will be stretched = standard deviation
Returns:
the generated sample

normal

public static double normal(double sigma,
                            double mean,
                            java.util.Random r)
Generates a sample of the Normal distribution using the specified random number generator. For more details see normal(double,double)

Parameters:
sigma - the shape parameter = standard deviation.
mean - the shift parameter = mean value.
r - the random number generator.
Returns:
the generated sample.

normal

public static double normal(double min,
                            double max,
                            double shift,
                            double stretch,
                            java.util.Random r)
Generates a sample of truncated Normal distribution using the specified random number generator.
Distribution normal(1, 0) is stretched by stretch coefficient, then shifted to the right by shift, after that it is truncated to fit in [min, max] interval. Truncation is performed by discarding every sample outside this interval and taking subsequent try.
For more details see normal(double, double)

Parameters:
min - the minimum value that this function will return. The distribution is truncated to return values above this. If the sample (stretched and shifted) is below this value it will be discarded and another sample will be drawn. Use Double.NEGATIVE_INFINITY for "No limit".
max - the maximum value that this function will return. The distribution is truncated to return values below this. If the sample (stretched and shifted) is bigger than this value it will be discarded and another sample will be drawn. Use Double.POSITIVE_INFINITY for "No limit".
shift - the shift parameter that indicates how much the (stretched) distribution will shifted to the right = mean value
stretch - the stretch parameter that indicates how much the distribution will be stretched = standard deviation
r - the random number generator.
Returns:
the generated sample

pareto

public double pareto(double alpha)
Generates a sample of the Pareto distribution with min set to 1. Is equivalent to pareto(alpha, 1). For more details see pareto(double,double)

Parameters:
alpha - the scale parameter > 0.
Returns:
the generated sample.

pareto

public double pareto(double alpha,
                     double min)
Generates a sample of the Pareto distribution.

The Pareto distribution is a continuous distribution bounded on the lower side. It has a finite value at the minimum x and decreases monotonically for increasing x. A Pareto random variable is the exponential of an Exponential random variable, and possesses many of the same characteristics.

The Pareto distribution has, historically, been used to represent the income distribution of a society. It is also used to model many empirical phenomena with very long right tails, such as city population sizes, occurrence of natural resources, stock price fluctuations, size of firms, brightness of comets, and error clustering in communication circuits.

The shape of the Pareto curve changes slowly with ?, but the tail of the distribution increases dramatically with decreasing ?.

Parameters:
alpha - the scale parameter > 0.
min - the minimum x value.
Returns:
the generated sample.

pareto

public static double pareto(double alpha,
                            double min,
                            java.util.Random r)
Generates a sample of the Pareto distribution using the specified random number generator. For more details see pareto(double,double).

Parameters:
alpha - the scale parameter > 0.
min - the minimum x value.
r - the random number generator.
Returns:
the generated sample.

poisson

public int poisson(double lambda)
Generates a sample of the Poisson distribution.

The Poisson distribution is a discrete distribution bounded at 0 on the low side and unbounded on the high side. The Poisson distribution is a limiting form of the Hypergeometric distribution.

The Poisson distribution finds frequent use because it represents the infrequent occurrence of events whose rate is constant. This includes many types of events in time or space such as arrivals of telephone calls, defects in semiconductor manufacturing, defects in all aspects of quality control, molecular distributions, stellar distributions, geographical distributions of plants, shot noise, etc. It is an important starting point in queuing theory and reliability theory. Note that the time between arrivals (defects) is Exponentially distributed, which makes this distribution a particularly convenient starting point even when the process is more complex.

The Poisson distribution peaks near ? and falls off rapidly on either side.

Parameters:
lambda - the rate of occurrence.
Returns:
the generated sample.

poisson

public double poisson(double min,
                      double max,
                      double mean,
                      double shift,
                      double stretch)
Generates a sample of truncated Poisson distribution.
Distribution poisson(mean) is stretched by stretch coefficient, then shifted to the right by shift, after that it is truncated to fit in [min, max] interval. Truncation is performed by discarding every sample outside this interval and taking subsequent try.
For more details see poisson(double)

Parameters:
min - the minimum value that this function will return. The distribution is truncated to return values above this. If the sample (stretched and shifted) is below this value it will be discarded and another sample will be drawn. Use Double.NEGATIVE_INFINITY for "No limit".
max - the maximum value that this function will return. The distribution is truncated to return values below this. If the sample (stretched and shifted) is bigger than this value it will be discarded and another sample will be drawn. Use Double.POSITIVE_INFINITY for "No limit".
mean - the mean value for the distribution = rate of event occurrence
shift - the shift parameter that indicates how much the (stretched) distribution will shifted to the right
stretch - the stretch parameter that indicates how much the distribution will be stretched
Returns:
the generated sample, note that in common case it is not an integer (because of stretching).

poisson

public static int poisson(double lambda,
                          java.util.Random r)
Generates a sample of the Poisson distribution using the specified random number generator. For more details see poisson(double).

Parameters:
lambda - the rate of occurrence.
r - the random number generator.
Returns:
the generated sample.

poisson

public static double poisson(double min,
                             double max,
                             double mean,
                             double shift,
                             double stretch,
                             java.util.Random r)
Generates a sample of truncated Poisson distribution using the specified random number generator.
Distribution poisson(mean) is stretched by stretch coefficient, then shifted to the right by shift, after that it is truncated to fit in [min, max] interval. Truncation is performed by discarding every sample outside this interval and taking subsequent try.
For more details see poisson(double)

Parameters:
min - the minimum value that this function will return. The distribution is truncated to return values above this. If the sample (stretched and shifted) is below this value it will be discarded and another sample will be drawn. Use Double.NEGATIVE_INFINITY for "No limit".
max - the maximum value that this function will return. The distribution is truncated to return values below this. If the sample (stretched and shifted) is bigger than this value it will be discarded and another sample will be drawn. Use Double.POSITIVE_INFINITY for "No limit".
mean - the mean value for the distribution = rate of event occurrence
shift - the shift parameter that indicates how much the (stretched) distribution will shifted to the right
stretch - the stretch parameter that indicates how much the distribution will be stretched
r - the random number generator.
Returns:
the generated sample, note that in common case it is not an integer (because of stretching).

rayleigh

public double rayleigh(double sigma)
Generates a sample of the Rayleigh distribution with min set to 0. Is equivalent to rayleigh(sigma, 0). For more details see rayleigh(double,double)

Parameters:
sigma - the scale parameter > 0.
Returns:
the generated sample.

rayleigh

public double rayleigh(double sigma,
                       double min)
Generates a sample of the Rayleigh distribution.

The Rayleigh distribution is a continuous distribution bounded on the lower side. It is a special case of the Weibull distribution with alpha =2 and beta/sqrt(2) =sigma. Because of the fixed shape parameter, the Rayleigh distribution does not change shape although it can be scaled.

The Rayleigh distribution is frequently used to represent lifetimes because its hazard rate increases linearly with time, e.g. the lifetime of vacuum tubes. This distribution also finds application in noise problems in communications.

Parameters:
sigma - the scale parameter > 0.
min - the minimum x value.
Returns:
the generated sample.

rayleigh

public static double rayleigh(double sigma,
                              double min,
                              java.util.Random r)
Generates a sample of the Rayleigh distribution using the specified random number generator. For more details see rayleigh(double,double)

Parameters:
sigma - the scale parameter > 0.
min - the minimum x value.
r - the random number generator.
Returns:
the generated sample.

triangular

public double triangular(double min,
                         double max)
Generates a sample of the Triangular distribution with mode set to (min + max)/2. Is equivalent to triangular(min, (min + max)/2, max). For more details see triangular(double,double,double).

Parameters:
min - the minimum x value.
max - the maximum x value.
Returns:
the generated sample.

triangular

public double triangular(double min,
                         double max,
                         double mode)
Generates a sample of the Triangular distribution.

The Triangular distribution is a continuous distribution bounded on both sides.

The Triangular distribution is often used when no or little data is available; it is rarely an accurate representation of a data set. However, it is employed as the functional form of regions for fuzzy logic due to its ease of use.

The Triangular distribution can take on very skewed forms including negative skewness. For the exceptional cases where the mode is either the min or max, the Triangular distribution becomes a right triangle.

Parameters:
min - the minimum x value.
max - the maximum x value.
mode - the most likely x value.
Returns:
the generated sample.

triangular

public double triangular(double min,
                         double max,
                         double left,
                         double mode,
                         double right)
Generates a sample of truncated Triangular distribution.
Distribution triangular(left, right, mode) is stretched by stretch coefficient, then shifted to the right by shift, after that it is truncated to fit in [min, max] interval. Truncation is performed by discarding every sample outside this interval and taking subsequent try.
For more details see triangular(double, double, double)

Parameters:
min - the minimum value that this function will return. The distribution is truncated to return values above this. If the sample (stretched and shifted) is below this value it will be discarded and another sample will be drawn. Use Double.NEGATIVE_INFINITY for "No limit".
max - the maximum value that this function will return. The distribution is truncated to return values below this. If the sample (stretched and shifted) is bigger than this value it will be discarded and another sample will be drawn. Use Double.POSITIVE_INFINITY for "No limit".
left - the minimum x value for triangular distribution.
mode - the most likely x value for triangular distribution.
right - the maximum x value for triangular distribution.
Returns:
the generated sample

triangular

public static double triangular(double min,
                                double max,
                                double mode,
                                java.util.Random r)
Generates a sample of the Triangular distribution using the specified random number generator. For more details see triangular(double,double,double).

Parameters:
min - the minimum x value.
max - the maximum x value.
mode - the most likely x value.
r - the random number generator.
Returns:
the generated sample.

triangular

public static double triangular(double min,
                                double max,
                                double left,
                                double mode,
                                double right,
                                java.util.Random r)
Generates a sample of truncated Triangular distribution using the specified random number generator.
Distribution triangular(left, right, mode) is stretched by stretch coefficient, then shifted to the right by shift, after that it is truncated to fit in [min, max] interval. Truncation is performed by discarding every sample outside this interval and taking subsequent try.
For more details see triangular(double, double, double)

Parameters:
min - the minimum value that this function will return. The distribution is truncated to return values above this. If the sample (stretched and shifted) is below this value it will be discarded and another sample will be drawn. Use Double.NEGATIVE_INFINITY for "No limit".
max - the maximum value that this function will return. The distribution is truncated to return values below this. If the sample (stretched and shifted) is bigger than this value it will be discarded and another sample will be drawn. Use Double.POSITIVE_INFINITY for "No limit".
left - the minimum x value for triangular distribution.
mode - the most likely x value for triangular distribution.
right - the maximum x value for triangular distribution.
r - the random number generator.
Returns:
the generated sample

pert

public double pert(double min,
                   double max,
                   double mode)
Generates a sample of the PERT distribution.

The PERT distribution is a continuous distribution bounded on both sides. Being an alternative distribution to the Triangular, it has the same three inputs, Minimum, Most Likely, and Maximum, but is a smooth curve that puts less emphasis on extreme values.

The PERT distribution is often used in risk analysis applications, e.g. in Monte Carlo simulations to assess cost and project duration risks.

Parameters:
min - the minimum x value.
max - the maximum x value.
mode - the most likely x value.
Returns:
the generated sample.

pert

public static double pert(double min,
                          double max,
                          double mode,
                          java.util.Random r)
Generates a sample of the PERT distribution using the specified random number generator. For more details see pert(double, double, double)

Parameters:
min - the minimum x value.
mode - the most likely x value.
max - the maximum x value.
r - the random number generator.
Returns:
the generated sample.

weibull

public double weibull(double beta,
                      double alpha)
Generates a sample of the Weibull distribution with min set to 0. Is equivalent to weibull(alpha, beta, 0). For more details see weibull(double,double,double).

Parameters:
beta - the scale parameter > 0.
alpha - the shape parameter > 0.
Returns:
the generated sample.

weibull

public double weibull(double alpha,
                      double beta,
                      double min)
Generates a sample of the Weibull distribution.

The Weibull distribution is a continuous distribution bounded on the lower side. Because it provides one of the limiting distributions for extreme values, it is also referred to as the Frechet distribution and the Weibull-Gnedenko distribution.

Like the Gamma distribution, it has three distinct regions. For ?=1, the Weibull distribution is reduced to the Exponential distribution, starting at a finite value at minimum x and decreasing monotonically thereafter. For ?<1, the Weibull distribution tends to infinity at minimum x and decreases monotonically for increasing x. for ?>1, the Weibull distribution is 0 at minimum x, peaks at a value that depends on both ? and ?, decreasing monotonically thereafter. Uniquely, the Weibull distribution has negative skewness for ?>3.6.

The Weibull distribution can also be used to approximate the Normal distribution for ?=3.6, while maintaining its strictly positive values of x [actually (x-min)], although the kurtosis is slightly smaller than 3, the Normal value.

The Weibull distribution derived its popularity from its use to model the strength of materials, and has since been used to model just about everything. In particular, the Weibull distribution is used to represent wearout lifetimes in reliability, wind speed, rainfall intensity, health related issues, germination, duration of industrial stoppages, migratory systems, and thunderstorm data.

Parameters:
alpha - the shape parameter > 0.
beta - the scale parameter > 0.
min - the minimum x value.
Returns:
the generated sample.

weibull

public double weibull(double min,
                      double max,
                      double alpha,
                      double shift,
                      double stretch)
Generates a sample of truncated Weibull distribution.
Distribution weibull(alpha, stretch, 0) is shifted to the right by shift and then truncated to fit in [min, max] interval. Truncation is performed by discarding every sample outside this interval and taking subsequent try.
For more details see weibull(double, double, double)

Parameters:
min - the minimum value that this function will return. The distribution is truncated to return values above this. If the sample (stretched and shifted) is below this value it will be discarded and another sample will be drawn. Use Double.NEGATIVE_INFINITY for "No limit".
max - the maximum value that this function will return. The distribution is truncated to return values below this. If the sample (stretched and shifted) is bigger than this value it will be discarded and another sample will be drawn. Use Double.POSITIVE_INFINITY for "No limit".
alpha - the shape parameter > 0.
shift - the shift parameter that indicates how much the (stretched) distribution will shifted to the right
stretch - the scale parameter.
Returns:
the generated sample

weibull

public static double weibull(double alpha,
                             double beta,
                             double min,
                             java.util.Random r)
Generates a sample of the Weibull distribution using the specified random number generator. For more details see weibull(double,double,double).

Parameters:
alpha - the shape parameter > 0.
beta - the scale parameter > 0.
min - the minimum x value.
r - the random number generator.
Returns:
the generated sample.

weibull

public static double weibull(double min,
                             double max,
                             double alpha,
                             double shift,
                             double stretch,
                             java.util.Random r)
Generates a sample of truncated Weibull distribution using the specified random number generator.
Distribution weibull(alpha, stretch, 0) is shifted to the right by shift and then truncated to fit in [min, max] interval. Truncation is performed by discarding every sample outside this interval and taking subsequent try.
For more details see weibull(double, double, double)

Parameters:
min - the minimum value that this function will return. The distribution is truncated to return values above this. If the sample (stretched and shifted) is below this value it will be discarded and another sample will be drawn. Use Double.NEGATIVE_INFINITY for "No limit".
max - the maximum value that this function will return. The distribution is truncated to return values below this. If the sample (stretched and shifted) is bigger than this value it will be discarded and another sample will be drawn. Use Double.POSITIVE_INFINITY for "No limit".
alpha - the shape parameter > 0.
shift - the shift parameter that indicates how much the (stretched) distribution will shifted to the right
stretch - the scale parameter.
r - the random number generator.
Returns:
the generated sample

sqr

public static double sqr(double v)
Returns the square of the given value (v2)

Parameters:
v - the value
Returns:
v * v

getLength

public static double getLength(double dx,
                               double dy)
Returns the length of the vector (dx, dy)

Parameters:
dx - the x coordinate of the vector
dy - the y coordinate of the vector
Returns:
the length of the vector (dx, dy)

getLength

public static double getLength(double dx,
                               double dy,
                               double dz)
Returns the length of the vector (dx, dy, dz)

Parameters:
dx - the x coordinate of the vector
dy - the y coordinate of the vector
dz - the z coordinate of the vector
Returns:
the length (euclidean norm) of the vector (dx, dy, dz)

getDistance

public static double getDistance(double x1,
                                 double y1,
                                 double x2,
                                 double y2)
Returns the distance between two given points (x1, y1) and (x2, y2)

Parameters:
x1 - the x coordinate of the first point
y1 - the y coordinate of the first point
x2 - the x coordinate of the second point
y2 - the y coordinate of the second point
Returns:
the distance between points

getDistanceSq

public static double getDistanceSq(double x1,
                                   double y1,
                                   double x2,
                                   double y2)
Returns the square of the distance between two given points (x1, y1) and (x2, y2).
This method is useful for comparing different distances, finding nearest point etc. because of better performance compared with getDistance()

Parameters:
x1 - the x coordinate of the first point
y1 - the y coordinate of the first point
x2 - the x coordinate of the second point
y2 - the y coordinate of the second point
Returns:
the square of the distance between points

getDistance

public static double getDistance(double x1,
                                 double y1,
                                 double z1,
                                 double x2,
                                 double y2,
                                 double z2)
Returns the distance between two given points (x1, y1, z1) and (x2, y2, z2)

Parameters:
x1 - the x coordinate of the first point
y1 - the y coordinate of the first point
z1 - the z coordinate of the first point
x2 - the x coordinate of the second point
y2 - the y coordinate of the second point
z2 - the z coordinate of the second point
Returns:
the distance between points

getDistanceSq

public static double getDistanceSq(double x1,
                                   double y1,
                                   double z1,
                                   double x2,
                                   double y2,
                                   double z2)
Returns the square of the distance between two given points (x1, y1, z1) and (x2, y2, z2).
This method is useful for comparing different distances, finding nearest point etc. because of better performance compared with getDistance()

Parameters:
x1 - the x coordinate of the first point
y1 - the y coordinate of the first point
z1 - the z coordinate of the first point
x2 - the x coordinate of the second point
y2 - the y coordinate of the second point
z2 - the z coordinate of the second point
Returns:
the square of the distance between points

isPointOnTheSameLine

public static boolean isPointOnTheSameLine(double x1,
                                           double y1,
                                           double x2,
                                           double y2,
                                           double x3,
                                           double y3)
Tests if the three point lie on the same line

Parameters:
x1 - the X coordinate of point 1
y1 - the Y coordinate of point 1
x2 - the X coordinate of point 2
y2 - the Y coordinate of point 2
x3 - the X coordinate of point 3
y3 - the Y coordinate of point 3
Returns:
true if 3 points lie on one line, otherwise false
Since:
6.8

isPointInsideRectangle

public static boolean isPointInsideRectangle(double rx,
                                             double ry,
                                             double rw,
                                             double rh,
                                             double px,
                                             double py)
Tests if the specified point is inside the given rectangle.

Parameters:
rx - the X coordinate of top-left corner of the rectangle
ry - the Y coordinate of top-left corner of the rectangle
rw - the width of the rectangle
rh - the height of the rectangle
px - the X coordinate of the point to test
py - the Y coordinate of the point to test
Returns:
true if the point is within the rectangle boundary, otherwise false
Since:
6.8

isLineIntersectingLine

public static boolean isLineIntersectingLine(double x1,
                                             double y1,
                                             double x2,
                                             double y2,
                                             double x3,
                                             double y3,
                                             double x4,
                                             double y4)
Tests if the line segment from (x1,y1) to (x2,y2) intersects the line segment from (x3,y3) to (x4,y4).

Parameters:
x1 - the X coordinate of the start point of the first specified line segment
y1 - the Y coordinate of the start point of the first specified line segment
x2 - the X coordinate of the end point of the first specified line segment
y2 - the Y coordinate of the end point of the first specified line segment
x3 - the X coordinate of the start point of the second specified line segment
y3 - the Y coordinate of the start point of the second specified line segment
x4 - the X coordinate of the end point of the second specified line segment
y4 - the Y coordinate of the end point of the second specified line segment
Returns:
true if the first specified line segment and the second specified line segment intersect each other; false otherwise.
Since:
6.8

isLineIntersectingRectangle

public static boolean isLineIntersectingRectangle(double x1,
                                                  double y1,
                                                  double x2,
                                                  double y2,
                                                  double rx,
                                                  double ry,
                                                  double rw,
                                                  double rh)
Check if the line intersects the given rectangle

Parameters:
x1 - the X coordinate of the start point of the specified line
y1 - the Y coordinate of the start point of the specified line
x2 - the X coordinate of the end point of the specified line
y2 - the Y coordinate of the end point of the specified line
rx - the X coordinate of top-left corner of the rectangle
ry - the Y coordinate of top-left corner of the rectangle
rw - the width of the rectangle
rh - the height of the rectangle
Returns:
true if the line intersects rectangle (has at least one common point, even lying on the rectangle's boundary)
Since:
6.8

getDistanceFromPointToLine

public static double getDistanceFromPointToLine(double x1,
                                                double y1,
                                                double x2,
                                                double y2,
                                                double px,
                                                double py)
Returns the distance from a point to a line. The distance measured is the distance between the specified point and the closest point on the infinitely-extended line defined by the specified coordinates. If the specified point intersects the line, this method returns 0.0.

Parameters:
x1 - the X coordinate of the start point of the specified line
y1 - the Y coordinate of the start point of the specified line
x2 - the X coordinate of the end point of the specified line
y2 - the Y coordinate of the end point of the specified line
px - the X coordinate of the specified point being measured against the specified line
py - the Y coordinate of the specified point being measured against the specified line
Returns:
a double value that is the distance from the specified point to the specified line.
Since:
6.8
See Also:
getDistanceFromPointToSegment(double, double, double, double, double, double)

getDistanceFromPointToLineSq

public static double getDistanceFromPointToLineSq(double x1,
                                                  double y1,
                                                  double x2,
                                                  double y2,
                                                  double px,
                                                  double py)
Returns the square of the distance from a point to a line. The distance measured is the distance between the specified point and the closest point on the infinitely-extended line defined by the specified coordinates. If the specified point intersects the line, this method returns 0.0.

Parameters:
x1 - the X coordinate of the start point of the specified line
y1 - the Y coordinate of the start point of the specified line
x2 - the X coordinate of the end point of the specified line
y2 - the Y coordinate of the end point of the specified line
px - the X coordinate of the specified point being measured against the specified line
py - the Y coordinate of the specified point being measured against the specified line
Returns:
a double value that is the square of the distance from the specified point to the specified line.
Since:
6.8
See Also:
getDistanceFromPointToSegmentSq(double, double, double, double, double, double)

getDistanceFromPointToSegment

public static double getDistanceFromPointToSegment(double x1,
                                                   double y1,
                                                   double x2,
                                                   double y2,
                                                   double px,
                                                   double py)
Returns the distance from a point to a line segment. The distance measured is the distance between the specified point and the closest point between the specified end points. If the specified point intersects the line segment in between the end points, this method returns 0.0.

Parameters:
x1 - the X coordinate of the start point of the specified line segment
y1 - the Y coordinate of the start point of the specified line segment
x2 - the X coordinate of the end point of the specified line segment
y2 - the Y coordinate of the end point of the specified line segment
px - the X coordinate of the specified point being measured against the specified line segment
py - the Y coordinate of the specified point being measured against the specified line segment
Returns:
a double value that is the distance from the specified point to the specified line segment.
Since:
6.8
See Also:
getDistanceFromPointToLine(double, double, double, double, double, double)

getDistanceFromPointToSegmentSq

public static double getDistanceFromPointToSegmentSq(double x1,
                                                     double y1,
                                                     double x2,
                                                     double y2,
                                                     double px,
                                                     double py)
Returns the square of the distance from a point to a line segment. The distance measured is the distance between the specified point and the closest point between the specified end points. If the specified point intersects the line segment in between the end points, this method returns 0.0.

Parameters:
x1 - the X coordinate of the start point of the specified line segment
y1 - the Y coordinate of the start point of the specified line segment
x2 - the X coordinate of the end point of the specified line segment
y2 - the Y coordinate of the end point of the specified line segment
px - the X coordinate of the specified point being measured against the specified line segment
py - the Y coordinate of the specified point being measured against the specified line segment
Returns:
a double value that is the square of the distance from the specified point to the specified line segment.
Since:
6.8
See Also:
getDistanceFromPointToLineSq(double, double, double, double, double, double)

zidz

public static double zidz(double a,
                          double b)
Tries to divide the first argument by the second. If the result is infinity or not a number, returns 0, otherwise returns the division result.

Parameters:
a - first value
b - second value
Returns:
division result or 0

xidz

public static double xidz(double a,
                          double b,
                          double x)
Tries to divide the first argument by the second. If the result is infinity or not a number, returns the third argument, otherwise returns the division result.

Parameters:
a - first value
b - second value
x - defines return result in case of unsuccessful division
Returns:
division result or x

limitMin

public static double limitMin(double min,
                              double x)
Returns x if it is greater or equal to min, otherwise returns min. May be more self-explanatory than the function max as explicitly says "x is left-limited by min".

Parameters:
min - left bound
x - the value
Returns:
x or min

limitMax

public static double limitMax(double x,
                              double max)
Returns x if it is less or equal to max, otherwise returns max. May be more self-explanatory than the function min as explicitly says "x is right-limited by max".

Parameters:
x - the value
max - right bound
Returns:
x or max

limit

public static double limit(double min,
                           double x,
                           double max)
Returns x if it is within [min,max] interval, otherwise returns the closest bound.

Parameters:
min - left bound
x - the value
max - right bound
Returns:
min, x or max

gammaLog

public static double gammaLog(double x)
Returns the natural logarithm of the gamma function of x:
ln(Γ(x)).
The gamma function is an extension of the factorial function that works on all positive values of x.
If n is a positive integer, then: Γ(n) = (n - 1)!.

The gammaLog function may be useful in System Dynamics models for computing combinatorial factors.

Parameters:
x - the value.
Returns:
ln(Γ(x))

step

public double step(double height,
                   double stepTime)
Returns 0 until the stepTime and then returns height

Parameters:
height -
stepTime -
Returns:
0 until the stepTime and then returns height

pulse

public double pulse(double startTime,
                    double pulseWidth)
Returns 1, starting at startTime, and lasting for interval pulseWidth; 0 is returned at all other times.

Parameters:
startTime - the pulse start time
pulseWidth - the length of pulse time interval
Returns:
1 for pulse (when time is within [start, start+width)), otherwise 0

pulseTrain

public double pulseTrain(double startTime,
                         double pulseWidth,
                         double timeBetweenPulses,
                         double endTime)
Returns 1, starting at startTime, and lasting for interval pulseWidth and then repeats this pattern every timeBetweenPulses time until endTime; 0 is returned at all other times.
If the value of timeBetweenPulses is smaller than pulseWidth then 1 will be returned between startTime and endTime.

Parameters:
startTime - the first pulse start time
pulseWidth - the length of pulse time interval
timeBetweenPulses - the length of time interval between starts pulses
endTime - the end time of pulses, since this time the method returns 0
Returns:
1 for pulses, 0 otherwise

ramp

public double ramp(double slope,
                   double startTime,
                   double endTime)
Returns 0 until the startTime and then slopes upward until endTime and then holds constant.

Parameters:
slope - the coefficient of returned value growth between startTime and endTime
startTime - the start time of the ramp
endTime - the end time of the ramp
Returns:
zero until the startTime, then slope until endTime and then constant.

quantum

public static double quantum(double value,
                             double quantizer)
Returns the number smaller (by absolute value) than or equal to value that is an integer multiple of quantizer.
If quantizer is less than or equal to zero, then value is returned unchanged.

Parameters:
value -
quantizer -
Returns:
quantized value

difference

public static double difference(DataSet ds,
                                TableFunction f)
Difference function which is always not-negative and reflects difference between given data set and table function in their common arguments range

Parameters:
ds - data set
f - table function with linear interpolation
Returns:
square root of the average of square of difference between linearly interpolated data set and table function
The integration range is the intersection of argument ranges of data set and function

difference

public static double difference(DataSet ds1,
                                DataSet ds2)
Difference function which is always not-negative and reflects difference between 2 given data sets in their common arguments range

Parameters:
ds1 - data set
ds2 - data set
Returns:
square root of the average of square of difference between linearly interpolated data sets
The integration range is the intersection of argument ranges of data sets

millisecond

public double millisecond()
Returns a time value equal to one millisecond according to the current time unit setting.

Returns:
a time value equal to one millisecond

second

public double second()
Returns a time value equal to one second according to the current time unit setting.

Returns:
a time value equal to one second

minute

public double minute()
Returns a time value equal to one minute according to the current time unit setting.

Returns:
a time value equal to one minute

hour

public double hour()
Returns a time value equal to one hour according to the current time unit setting.

Returns:
a time value equal to one hour

day

public double day()
Returns a time value equal to one day according to the current time unit setting.

Returns:
a time value equal to one day

week

public double week()
Returns a time value equal to one week according to the current time unit setting.

Returns:
a time value equal to one week

briefInfoOn

public static java.lang.String briefInfoOn(java.lang.Object object)
Returns a brief one-line textual information on the given object. Supports most frequently used types: most numeric types, Color, Date, ActiveObject, collections, HyperArray, events, transitions, etc. If the argument type is not supported, returns its defualt toString(). If the argument is null, returns null.

Parameters:
object - the obejct to give info on
Returns:
brief one-line textual information on the object

inspectOf

public static java.lang.String inspectOf(java.lang.Object object)
Returns a textual info on the object that can be displayed in the multi-line Inspect window. This info is an extended version of what is given by briefInfoOn().

Parameters:
object - the object being inspected
Returns:
an extended textual info on the object

copyToClipboard

public static void copyToClipboard(java.lang.String s)
Puts the given text on the system clipboard
Note that this method may not work when the model is started as applet due to security policy of browser

Parameters:
s - the text to put on the clipboard

format

public static java.lang.String format(double value)
Formats a double value using the default AnyLogic formatter

Parameters:
value - the double value to be formatted.
Returns:
the string containing the formatted value

format

public static java.lang.String format(int value)
Formats an integer value using the default AnyLogic formatter

Parameters:
value - the integer value to be formatted.
Returns:
the string containing the formatted value

format

public static java.lang.String format(long value)
Formats a long value using the default AnyLogic formatter

Parameters:
value - the long value to be formatted.
Returns:
the string containing the formatted value

format

public static java.lang.String format(java.util.Date date)
Formats a date using the default AnyLogic formatter

Parameters:
date - the date to be formatted.
Returns:
the string containing the formatted value

formatDayOfWeek

public static java.lang.String formatDayOfWeek(int dayOfWeek,
                                               boolean fullName)
Returns the full or short name of the weekday

Parameters:
dayOfWeek - one of MONDAY, TUESDAY, ... contants
fullName - if true, then returns the full name ("Monday", "Tuesday", etc.), otherwise - short ("Mon", "Tue", etc.)
Returns:
the name of the weekday

formatMonth

public static java.lang.String formatMonth(int month,
                                           boolean fullName)
Returns the full or short name of the month

Parameters:
month - one of JANUARY, FEBRUARY, ... contants
fullName - if true, then returns the full name ("January", "February", etc.), otherwise - short ("Jan", "Feb", etc.)
Returns:
the name of the month

format

public static java.lang.String format(boolean value)
Formats a boolean value

Parameters:
value - the boolean value to be formatted.
Returns:
the string containing the formatted value ("true" or "false")

format

public static java.lang.String format(char value)
Formats a character to String

Parameters:
value - the character value to be formatted.
Returns:
the string containing the formatted value

formatTimeInterval

public java.lang.String formatTimeInterval(double dt)
Returns a string representation of a given time interval, according to the current time unit settings, in the form 123 days 21h 0'56".

Parameters:
dt - the time interval
Returns:
string representation of the time interval

formatLongitude

public static java.lang.String formatLongitude(double degrees)
Formats longitude

Parameters:
degrees - the longitude in decimal degrees
Returns:
formatted longitude, e.g. E30°20'0"

formatLatitude

public static java.lang.String formatLatitude(double degrees)
Formats latitude

Parameters:
degrees - the latitude in decimal degrees
Returns:
formatted latitude, e.g. N59°56'0"

formatGeoHeading

public static java.lang.String formatGeoHeading(double radians)
Formats given heading angle (measured in radians CW, starting from North direction) as human-readable geographical heading (azimuth). E.g. PI / 7 will be formatted as "26° NNE"

Parameters:
radians - the heading angle (measured in radians CW, starting from North direction)
Returns:
formatted human-readable geographical heading (angle in degrees CW from North)

toLatitude

public static double toLatitude(int degrees,
                                int minutes,
                                double seconds,
                                boolean northOrSouth)
Converts latitude from human-readable format (e.g. 59° 56' 0" North) to format used in the model

Parameters:
degrees - number of degrees, 0...90
minutes - number of minutes (1/60 of degree), 0...59
seconds - number of seconds (1/60 of minute), 0 <= seconds < 60
northOrSouth - true for North, false for South
Returns:
the resulting latitude, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)

toLongitude

public static double toLongitude(int degrees,
                                 int minutes,
                                 double seconds,
                                 boolean eastOrWest)
Converts longitude from human-readable format (e.g. 30° 20' 0" East) to format used in the model

Parameters:
degrees - number of degrees, 0...180
minutes - number of minutes (1/60 of degree), 0...59
seconds - number of seconds (1/60 of minute), 0 <= seconds < 60
eastOrWest - true for East, false for West
Returns:
the resulting longitude, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)

toDate

public static java.util.Date toDate(int year,
                                    int month,
                                    int day,
                                    int hourOfDay,
                                    int minute,
                                    int second)
Returns the date in the default time zone with given field values.

Parameters:
year - the year
month - the month, is 0-based. e.g., 0 for January.
Following values may be used:
day - the day of the month
hourOfDay - the hour of day (using 24-hour clock)
minute - the minute
second - the second

toDateInMillis

public static long toDateInMillis(int year,
                                  int month,
                                  int day,
                                  int hourOfDay,
                                  int minute,
                                  int second)
Same as toDate(int, int, int, int, int, int) but returns the date in its milliseconds representation (see Date.getTime()), i.e. the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by the date.

See Also:
toDate(int, int, int, int, int, int), Date.getTime()

createURL_xjal

public static java.net.URL createURL_xjal(java.lang.String url)
Creates an URL object from the String representation

Parameters:
url - the String to parse as a URL.
Returns:
an URL object

prepareBeforeExperimentStart_xjal

public static void prepareBeforeExperimentStart_xjal(java.lang.Class<?> experimentClass)
This method is internal and isn't intended to be called by user (may be removed in future releases)



Copyright © 1991-2008 XJ Technlogies. All Rights Reserved.