Calculate Shannon entropy