utilities – Simple but useful Utility Functions
Tools for binary encodings

pybrain.utilities.one_to_n(val, maxval)
 Returns a 1inn binary encoding of a nonnegative integer.

pybrain.utilities.n_to_one(arr)
 Returns the reverse of a 1inn binary encoding.

pybrain.utilities.int2gray(i)
 Returns the value of an integer in Gray encoding.

pybrain.utilities.asBinary(i)
 Produces a string from an integer’s binary representation.
(preceding zeros removed).
Tools for sets

pybrain.utilities.reachable(stepFunction, start, destinations)
 Determines the subset of destinations that can be reached from a set of starting positions,
while using stepFunction (which produces a list of neighbor states) to navigate.
Uses breadthfirst search.

pybrain.utilities.crossproduct(ss, row=None, level=0)
 Returns the crossproduct of the sets given in ss.
Matrix tools

pybrain.utilities.triu2flat(m)
 Flattens an upper triangular matrix, returning a vector of the
nonzero elements.

pybrain.utilities.flat2triu(a, dim)
 Produces an upper triangular matrix of dimension dim from the elements of the given vector.

pybrain.utilities.blockList2Matrix(l)
 Converts a list of matrices into a corresponding big blockdiagonal one.

pybrain.utilities.blockCombine(l)
 Produce a matrix from a list of lists of its components.
Stochastic index choices

pybrain.utilities.drawIndex(probs, tolerant=False)
Draws an index given an array of probabilities.
Key tolerant:  if set to True, the array is normalized to sum to 1. 

pybrain.utilities.drawGibbs(vals, temperature=1.0)
 Return the index of the sample drawn by a softmax (Gibbs).