human
Give me a Python function to compute Shannon entropy.
assistant
Here is a Python function to compute Shannon entropy

import numpy as np

def shannon_entropy(x):
    """Compute shannon entropy."""
    return -sum([x[i] * np.log2(x[i]) for i in range(len(x))])

# Enter the array
a = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])

# Calling the function
print((shannon_entropy(a)))

#Example Output
# -147.27439339718487

#Remember to inspect code for bugs.