Skip to content

Instantly share code, notes, and snippets.

@lucainnocenti
Created November 15, 2021 02:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucainnocenti/0e41ef50fe3764b41e338179f621d860 to your computer and use it in GitHub Desktop.
Save lucainnocenti/0e41ef50fe3764b41e338179f621d860 to your computer and use it in GitHub Desktop.
Two-dimensional visualisation of Shannon entropy
ShannonEntropy[probs_] := -Total[# * Log @ #] & @ DeleteCases[probs, _?PossibleZeroQ];
par[t_, s_] = {1, 0, 0} + t / Sqrt@2 {-1, 1, 0} + s/Sqrt[3/2] {-1/2, -1/2, 1} // Simplify;
par[pars_List] := par @@ pars;
ContourPlot[
ShannonEntropy@par[t, s], {t, 0, Sqrt@2}, {s, 0, Sqrt[3/2]},
PlotRange -> All,
ColorFunction -> "TemperatureMap", PlotRangePadding -> None,
Contours -> 10,
FrameStyle -> Directive[Large, Black, FontFamily -> "Latin Modern Math"],
FrameLabel -> (MaTeX[#, Magnification -> 2] & /@ {"t", "s"}),
AspectRatio -> Sqrt[3/2]/Sqrt[2]
] ~ Show ~ Graphics[{Thickness@0.015, Purple,
Circle[{1/Sqrt@2, 1/Sqrt@6}, 0.4]
}
]
@lucainnocenti
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment