An implementation of a MultiSet backed by a HashMap.
HashSelectableSet uses a hashset implementation to provide O(1) insertion, O(1) removal, O(1) search, O(n) listing elements, and O(log n) selecting an element uniformly at random.
A priority map using a heap implementation.
A priority map using a heap implementation. Provides O(log n) insertion, update, and extracting the minimum element.
A resampler that allows efficient resampling from a set of weighted samples provided as the inputs.
A resampler that allows efficient resampling from a set of weighted samples provided as the inputs. Creating the resampler takes O(N log N) time, where N is the number of input samples, and selecting M samples takes O(M log N).
Trait of multisets that can contain more than one instance of the same element.
Trait of multisets that can contain more than one instance of the same element.
The type of values contained in the set
A priority map is like a priority queue except that keys in the clue are mapped to values that determine their place in the queue.
A priority map is like a priority queue except that keys in the clue are mapped to values that determine their place in the queue. The value associated with a key can be updated, resulting in the key being moved to a different place in the queue.
A resampler allows resampling from a set of weighted samples provided as the inputs.
A set that supports selection of an element uniformly at random, in addition to the usual set operations.
Finds the index of the maximal element in the sequence.
Returns logp if all conditions are true.
Returns logp if all conditions are true. Else returns -Inf.
Returns the Cartesian product of any number of inputs.
Returns the Cartesian product of any number of inputs. The results are returned in lexicographic order.
Gets the value associated with a key in a map, inserting a default value if it is not found.
Gets the value associated with a key in a map, inserting a default value if it is not found. The default is only evaluated if the key is not found in the map.
Returns the Cartesian product of any number of inputs of the same type.
Returns the Cartesian product of any number of inputs of the same type. The results are returned in lexicographic order.
Returns all indices of the given element in the traversable.
Given a traversable, some indices, and a value, inserts the value at the given indices into the traversable.
Given a traversable, some indices, and a value, inserts the value at the given indices into the traversable. The resulting list contains all the elements of the input traversable as well as the value at the appropriate indices. For example, insertAtIndices(List(1,2), List(0,2,4), 3) yields List(3,1,3,2,3). The indices must be in order to produce the correct result. If the indices are such that there would be a gap in the resulting traversable, IllegalArgumentException is thrown.
Sums two probabilities in log space.
Computes the sum of many probabilities in log space.
Computes the average time to run the given function.
Computes the average time to run the given function. The second argument is the number of times to run it before starting to measure to warm up the JVM. The third argument is the number of times to run and measure.
Memoize the given function so that it is only applied once to each input with the result stored.
Normalize the given list of doubles so that the proportions remain constant and they sum to 1.
Normalize the given list of doubles so that the proportions remain constant and they sum to 1. An exception will be thrown if the inputs sum to 0.
Find the elements that are reachable from a given element in a directed graph.
Find the elements that are reachable from a given element in a directed graph. The graph is represented as a function from T to List[T], where the list associated with an element is the list of nodes to which there is a directed edge from the element. The element on which reachable is called is not returned as one of the reachable elements.
The implementation avoids following the exponential number of paths by marking which nodes have been checked. This technique also allows the algorithm to work on cyclic graphs.
Round the given double to the nearest element of the non-empty ordered list.
Sample a value given a multinomial distribution.
Sample a value given a multinomial distribution. The input is a list of pairs where each pair specifies a value and its associated probability. This method assumes the probabilities sum to 1.
A random number generator.
Computes and returns the argument, timing how long it takes to produce the answer and printing the result.
Computes all pairs of elements in the list in which the first element appears before the second.