You're reading the documentation for a development version. For the latest released version, please have a look at 0.10.1.
- librosa.sequence.transition_loop(n_states, prob)
Construct a self-loop transition matrix over
The transition matrix will have the following properties:
transition[i, i] = pfor all
transition[i, j] = (1 - p) / (n_states - 1)for all
j != i
This type of transition matrix is appropriate when states tend to be locally stable, and there is no additional structure between different states. This is primarily useful for de-noising frame-wise predictions.
- n_statesint > 1
The number of states
- probfloat in [0, 1] or iterable, length=n_states
If a scalar, this is the probability of a self-transition.
If a vector of length
p[i]is the probability of self-transition in state
- transitionnp.ndarray [shape=(n_states, n_states)]
The transition matrix
>>> librosa.sequence.transition_loop(3, 0.5) array([[0.5 , 0.25, 0.25], [0.25, 0.5 , 0.25], [0.25, 0.25, 0.5 ]])
>>> librosa.sequence.transition_loop(3, [0.8, 0.5, 0.25]) array([[0.8 , 0.1 , 0.1 ], [0.25 , 0.5 , 0.25 ], [0.375, 0.375, 0.25 ]])