pygsti.extras.drift.signal.sparsity#
- sparsity(p)#
Returns the Hoyer sparsity index of the input vector p. This is defined to be:
HoyerIndex = (sqrt(l) - (|p|_1 / |p|_2)) / (sqrt(l) - 1)
where l is the length of the vector and |.|_1 and |.|_2 are the 1-norm and 2-norm of the vector, resp.