Module dstats.base

Relatively low-level primitives on which to build higher-level math/stat functionality. Some are used internally, some are just things that may be useful to users of this library. This module is starting to take on the appearance of a small utility library.

Note

In several functions in this module that return arrays, the last parameter is an optional buffer for storing the return value. If this parameter is ommitted or the buffer is not large enough, one will be allocated on the GC heap.

Author

David Simcha

Functions

NameDescription
auroc(classATs, classBTs) Finds the area under the ROC curve (a curve with sensitivity on the Y-axis and 1 - specificity on the X-axis). This is a useful metric for determining how well a test statistic discriminates between two classes. The following assumptions are made in this implementation:
bin(data, nbin, buf) Bins data into nbin equal width bins, indexed from 0 to nbin - 1, with 0 being the smallest bin, etc. The values returned are the bin index for each element.
binCounts(data, nbin, buf) Bins data into nbin equal width bins, indexed from 0 to nbin - 1, with 0 being the smallest bin, etc. The values returned are the counts for each bin.
byCategory(values, categories) Given a range of values and a range of categories, separates values by category. This function also guarantees that the order within each category will be maintained.
byCategory(values, categories) Special case implementation for when ElementType!C is boolean.
comb(stuff, r) Create a Comb struct from a range or of a set of bounds.
dstatsEnforce(value, msg)
frequency(input) Returns an associative array of counts of every element in input. Works w/ any iterable.
frqBin(data, nbin, buf) Bins data into nbin equal frequency bins, indexed from 0 to nbin - 1, with 0 being the smallest bin, etc. The values returned are the bin index for each element.
logFactorial(n)
logNcomb(n, k) Log of (n choose k).
perm(stuff) Create a Perm struct from a range or of a set of bounds.
rank(input, buf) Given an input array, outputs an array containing the rank from [1, input.length] corresponding to each element. Ties are dealt with by averaging. This function does not reorder the input range. Return type is float[] by default, but if you are sure you have no ties, ints can be used for efficiency (in which case ties will not be averaged), and if you need more precision when averaging ties, you can use double or real.
rankSort(input, buf) Same as rank(), but also sorts the input range. The array returned will still be identical to that returned by rank(), i.e. the rank of each element will correspond to the ranks of the elements in the input array before sorting.
saveAll(args) Given a tuple possibly containing forward ranges, returns a tuple where save() has been called on all forward ranges.
seq(start, end, increment) Generates a sequence from [start..end] by increment. Includes start, excludes end. Does so eagerly as an array.
sign(num)
toNumericRange(rangeIn) Converts a range with arbitrary element types (usually strings) to a range of reals lazily. Ignores any elements that could not be successfully converted. Useful for creating an input range that can be used with this lib out of a File without having to read the whole file into an array first. The advantages to this over just using std.algorithm.map are that it's less typing and that it ignores non-convertible elements, such as blank lines.
_arrayExpSliceDivass_d(p1, c0)
_arrayExpSliceMulass_d(p1, c0)
_arraySliceExpMulSliceMinass_d(p2, c1, p0)

Classes

NameDescription
DstatsArgumentException This is the exception that is thrown on invalid arguments to a dstats function.

Structs

NameDescription
Comb Generates every possible combination of r elements of the given sequence, or array indices from zero to N, depending on which c'tor is called. Uses an input range interface.
Perm A struct that generates all possible permutations of a sequence.
ToNumericRange

Templates

NameDescription
doubleIterable Tests whether T is iterable and has elements of a type implicitly convertible to double.

Manifest constants

NameTypeDescription
doubleInput Tests whether T is an input range whose elements can be implicitly converted to doubles.

Global variables

NameTypeDescription
logFactorialTable immutable(double[])