C# (CSharp) StopGuessing.DataStructures Namespace

Classes

Name Description
AgingMembershipSketch
AgingSketch
BinomialDistribution
BinomialLadderFilter A binomial ladder filter maps elements keys to H indexes in an n bit table of bits, which are initially set at random with a probability 0.5. Each index represents a rung on the element's ladder. The indexes set to 1/true are rungs that are below that element on the ladder and the indexes that are 0/false are rungs above the element, or which the element has yet to climb. On avarege, an element that has not been seen before will map to, on average, H/2 index that are set to 1 (true) and H/2 indexes that are set to 0 (false). This means that half the rungs are below the element and half are above it, and so the element is half way up the ladder. If a non-empty subset of the indexes that an element maps to contains 0, observing that element (the Step() method) will cause a random member of that subset to be changed from 0 to 1, causing the element to move one rung up the ladder. To ensure that the fraction of bits set to 1 stays constant, the step operation willsimultaneously clear a random bit selected from subset of indexes in the entire sketch that have value 1. The more times an element has been observed, the higher the expected number of indexes that will have been set, the higher it moves up the ladder until reaching the top (when all of its bits are set). To count the subset of a keys indexes that have been set, one can call the GetRungsBelow method. Natural variance will cause some never-before-seen keys to have more than k/2 bits set and keys that have been observed very rarely (or only in the distant past) to have fewer than k/2 bit set. an element that is observed only a few times (with ~ k/2 + epsilon bits set) will be among ~ .5^{epsilon} false-positive keys that have as many bits set by chance. Thus, until an element has been observed a more substantial number of times it is hard to differentiate from false positives. To have confidence greater than one in a million that an element has been observed, it will take an average of 20 observations.
DecayingDouble A class that represents a double that decays over time using a half life, to borrow a concept from radioactive decay. A value that is assigned a value 1d and a half life of one day will have value 0.5d after one day, .25d after two days, and so on. More generally, if you assign the value x, after e half lives it's value will be x/(2^e). Since a double that decays with time will have a constantly-changing real value, it should never be used as the key into a Dictionary or kept in a HashSet. It should not be compared for exact equality.
EditDistance A static class for calculating the edit distance between two strings, factoring in not just the standard additions, deletions, and subtstitutions, but also case changes ('a'->'A') and transpositions ('typo'->'tpyo'). The caller may set the cost of each type of edit and the calculator will compute the least-cost edit from the source string to the destination string.
EditDistance.Costs
FilterArray A FilterArray is a bit array that contains additional methods to support probabilistic data structures that map elements (keys) to a set of deterministic, pseudorandom indexes in the bit array. These methods support data structures such as bloom filters and binomial ladder filters that store information about an element within the bits at the indexes that are pseudorandomly associated with the element.
MemoryUsageLimiter
MemoryUsageLimiter.ReduceMemoryUsageEventParameters
Proportion A class representing a proportion, or fraction, of numerator over denominator. This comes in handy when one might care about the actual magnitude of the numerator/denominator, which is list in a representation that divides the numerator by the denominator.
Sketch A sketch is a probabilistic data structure that provides an approximate count of the number of times an item has been observed or, more generally, the sum of a set of numbers associated with each item (where the common case is that each observation of an item is the number 1). One can add observations of items (or numbers associated with items) and get an estimate of that number. A sketch always returns a number that is _at least_ as large as the number observed (up to the maximum number that the sketch can store). In other words, it is a lower bound on the values observed. It may falsely return a number too large, but will never return a number too small (unless, again, the value has exceeded the maximum integer the sketch is designe do store.)
Sketch.ResultOfGet
Sketch.ResultOfUpdate