unsort¶
- emlib.combinatorics.unsort(seq, entropy, margin=0, tolerance=0.05, numiter=100, timeout=None)[source]¶
Generate a permutation of xs unsorted according to the given entropy.
- Parameters:
seq (
Sequence
) – a sequence to be unsortedentropy (
float
) – 0=the original sequence is returned; 1=random sequence is returnedmargin – a number or tuple (left, right). These elements are left untouched
numiter – the number of times the algorithm is run. The best result will be returned
timeout (
Optional
[float
]) – alternatively, you can specify a timeout (numiter will be disregarded)
- Return type:
ndarray
- Returns:
un unsorted version of seq, as numpy array, or None if
If entropy == 0: the original sequence is returned
If entropy == 1: a sequence is generated which is as random as possible (this does not mean that there cannot be any fixed points, it refers to the general result)
Examples
# unsort the first 10 numbers, leave 0 and 9 untouched at their places unsort(range(10), 0.5, margin=1) # unsort the given seq., do not touch the first too elements unsort((1,3, 5, 4, 0), 0.2, margin=(2, 0))