NB5 Docs► Reference Section► Binding Functions▼ distribution functions 🖺

All of the distributions that are provided in the Apache Commons Math project are supported here, in multiple forms.

Continuous or Discrete

These distributions break down into two main categories:

Continuous Distributions

These are distributions over real numbers like 23.4323, with continuity across the values. Each of the continuous distributions can provide samples that fall on an interval of the real number line. Continuous probability distributions include the Normal distribution, and the Exponential distribution, among many others.

Discrete Distributions

Discrete distributions, also known as integer distributions have only whole-number valued samples. These distributions include the Binomial distribution, the Zipf distribution, and the Poisson distribution, among others.

Hashed or Mapped

hashed samples

Generally, you will want to "randomly sample" from a probability distribution. This is handled automatically by the functions below if you do not override the defaults. The hash mode is the default sampling mode for probability distributions. This is accomplished by hashing the input before using the resulting value with the sampling curve. This is called the hash sampling mode by VirtData. You can put hash into the modifiers as explained below if you want to document it explicitly.

mapped samples

The method used to sample from these distributions depends on a mathematical function called the cumulative probability density function, or more specifically the inverse of it. Having this function computed over some interval allows one to sample the shape of a distribution progressively if desired. In other words, it allows for some percentile-like view of values within a given probability distribution. This mode of using the inverse cumulative density function is known as the map mode in VirtData, as it allows one to map a unit interval variate in a deterministic way to a density sampling curve. To enable this mode, simply pass map as one of the function modifiers for any function in this category.

Interpolated or Computed Samples

When sampling from mathematical models of probability densities, performance between different densities can vary drastically. This means that you may end up perturbing the results of your test in an unexpected way simply by changing parameters of your testing distributions. Even worse, some densities have painful corner cases in performance, like 'Zipf', which can make tests unbearably slow and flawed as they chew up CPU resources.

NOTE: Functions like 'Zipf' can still take a long time to initialize for certain parameters. If you are seeing a workload that seems to hang while initializing, it might be computing complex integrals for large parameters of Zipf. We hope to pre-compute and cache these at a future time to avoid this type of impact. For now, just be aware that some parameters on some density curves can be expensive to compute even during initialization.

Interpolated Samples

For this reason, interpolation is built-in to these sampling functions. The default mode is interpolate. This means that the sampling function is pre-computed over 1000 equidistant points in the unit interval (0.0,1.0), and the result is shared among all threads as a look-up-table for interpolation. This makes all statistical sampling functions perform nearly identically at runtime (after initialization, a one time cost). This does have the minor side effect of a little loss in accuracy, but the difference is generally negligible for nearly all performance testing cases.

Infinite or Finite

For interpolated samples from continuous distributions, you also have the option of including or excluding infinite values which may occur in some distributions. If you want to include them, use infinite, or finite to explicitly avoid them (the default). Specifying 'infinite' doesn't guarantee that you will see +Infinity or -Infinity, only that they are allowed. The Normal distribution often contains -Infinity and +Infinity, for example, due to the function used to estimate its cumulative distribution. These values can often be valuable in finding corner cases which should be treated uniformly according to IEEE 754.

Clamp or Noclamp

For interpolated samples from continuous distributions, you also have the option of clamping the allowed values to the valid range for the integral data type used as input. To clamp the output values to the range (Long.MIN_VALUE,Long.MAX_VALUE) for long->double functions, or to (Integer. MIN_VALUE,Integer.MAX_VALUE) for int-double functions, specify clamp, which is also the default. To explicitly disable this, use noclamp. This is useful when you know the downstream functions will only work with a certain range of values without truncating conversions. When you are using double values natively on the downstream functions, use noclamp to avoid limiting the domain of values in your test data. (In this case, you might also consider infinite).

Computed Samples

Conversely, compute mode sampling calls the sampling function every time a sample is needed. This affords a little more accuracy, but is generally not preferable to the default interpolated mode. You'll know if you need computed samples. Otherwise, it's best to stick with interpolation so that you spend more time testing your target system and less time testing your data generation functions.

Input Range

All of these functions take a long as the input value for sampling. This is similar to how the unit interval (0.0,1.0) is used in mathematics and statistics, but more tailored to modern system capabilities. Instead of using the unit interval, we simply use the interval of all positive longs. This provides more compatibility with other functions in VirtData, including hashing functions. Internally, this value is automatically converted to a unit interval variate as needed to work well with the distributions from Apache Math.

Beta

@see Wikipedia: Beta distribution @see Commons JavaDoc: BetaDistribution

Binomial

@see Wikipedia: Binomial distribution @see Commons JavaDoc: BinomialDistribution

Cauchy

@see Wikipedia: Cauchy_distribution @see Commons Javadoc: CauchyDistribution

ChiSquared

@see Wikipedia: Chi-squared distribution @see Commons JavaDoc: ChiSquaredDistribution

CoinFunc

This is a higher-order function which takes an input value, and flips a coin. The first parameter is used as the threshold for choosing a function. If the sample values derived from the input is lower than the threshold value, then the first following function is used, and otherwise the second is used. For example, if the threshold is 0.23, and the input value is hashed and sampled in the unit interval to 0.43, then the second of the two provided functions will be used. The input value does not need to be hashed beforehand, since the user may need to use the full input value before hashing as the input to one or both of the functions. This function will accept either a LongFunction or a {@link Function} or a LongUnaryOperator in either position. If necessary, use {@link function.ToLongFunction} to adapt other function forms to be compatible with these signatures.

ConstantContinuous

Always yields the same value. @see Commons JavaDoc: ConstantContinuousDistribution

Enumerated

Creates a probability density given the values and optional weights provided, in "value:weight value:weight ..." form. The weight can be elided for any value to use the default weight of 1.0d. @see Commons JavaDoc: EnumeratedRealDistribution

Exponential

@see Wikipedia: Exponential distribution @see Commons JavaDoc: ExponentialDistribution

F

@see Wikipedia: F-distribution @see Commons JavaDoc: FDistribution @see Mathworld: F-Distribution

Gamma

@see Wikipedia: Gamma distribution @see Commons JavaDoc: GammaDistribution

Geometric

@see Wikipedia: Geometric distribution @see Commons JavaDoc: GeometricDistribution

Gumbel

@see Wikipedia: Gumbel distribution @see Commons JavaDoc: GumbelDistribution

Hypergeometric

@see Wikipedia: Hypergeometric distribution @see Commons JavaDoc: HypergeometricDistribution

Laplace

@see Wikipedia: Laplace distribution @see Commons JavaDoc: LaplaceDistribution

Levy

@see Wikipedia: Lévy distribution @see Commons JavaDoc: LevyDistribution

LogNormal

@see Wikipedia: Log-normal distribution @see Commons JavaDoc: LogNormalDistribution

Logistic

@see Wikipedia: Logistic distribution @see Commons JavaDoc: LogisticDistribution

Nakagami

@see Wikipedia: Nakagami distribution @see Commons JavaDoc: NakagamiDistribution

Normal

@see Wikipedia: Normal distribution @see Commons JavaDoc: NormalDistribution

Pareto

@see Wikipedia: Pareto distribution @see Commons JavaDoc: ParetoDistribution

Pascal

@see Commons JavaDoc: PascalDistribution @see Wikipedia: Negative binomial distribution

Poisson

@see Wikipedia: Poisson distribution @see Commons JavaDoc: PoissonDistribution

T

@see Wikipedia: Student's t-distribution @see Commons JavaDoc: TDistribution

Triangular

@see Wikipedia: Triangular distribution @see Commons JavaDoc: TriangularDistribution

Uniform

@see Wikipedia: Uniform distribution (continuous) @see Commons JavaDoc: UniformContinuousDistribution

Weibull

@see Wikipedia: Weibull distribution @see Wolfram Mathworld: Weibull Distribution @see Commons Javadoc: WeibullDistribution

WeightedFuncs

Allows for easy branching over multiple functions with specific weights.

Zipf

@see Wikipedia: Zipf's Law @see Commons JavaDoc: ZipfDistribution

Back to top