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

Name Description
auroc 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 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 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 Special case implementation for when ElementType!C is boolean.
byCategory 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.
comb Create a Comb struct from a range or of a set of bounds.
dstatsEnforce
frequency Returns an associative array of counts of every element in input. Works w/ any iterable.
frqBin 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
logNcomb Log of (n choose k).
perm Create a Perm struct from a range or of a set of bounds.
rank 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 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 Given a tuple possibly containing forward ranges, returns a tuple where save() has been called on all forward ranges.
seq Generates a sequence from [start..end] by increment. Includes start, excludes end. Does so eagerly as an array.
sign
toNumericRange 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
_arrayExpSliceMulass_d
_arraySliceExpMulSliceSubass_d

Classes

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

Structs

Name Description
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

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

Enum values

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

Global variables

Name Type Description
logFactorialTable immutable(double[])

Authors

Copyright

License