diff --git a/ex-1/plots/misc.py b/ex-1/plots/misc.py index 85710dd..c313daf 100755 --- a/ex-1/plots/misc.py +++ b/ex-1/plots/misc.py @@ -6,12 +6,13 @@ import argparse import sys -# -i → agrs.show → open plot in interactive mode -# -s → args.save → save plot +# -i → agrs.show → open plot in interactive mode +# -s → args.save → save plot # -# -n → agrs.note → do the Landau plot with the notes -# -b → args.both → do the Landau-Moyal plot -# -m → args.area → do the Landau median plot +# -n → agrs.note → do the Landau plot with the notes +# -b → args.both → do the Landau-Moyal plot +# -m → args.area → do the Landau median plot +# -c → args.cauchy → do the Cauchy PDF plot def moyal(x, μ, σ): @@ -19,20 +20,24 @@ def moyal(x, μ, σ): return N * np.exp(- 0.5 * ((x - μ)/σ + np.exp(- (x - μ)/σ))) +def cauchy(x): + return 1/(np.pi*(1 + x**2)) + + def main(args): # prepare figure if args.show: plt.figure() - elif args.save: plt.rcParams['font.size'] = 8 if (args.both or args.area): plt.figure(figsize=(3, 2)) elif args.note: plt.figure(figsize=(5, 3)) + elif args.cauchy: + plt.figure(figsize=(3, 2)) if args.note: - # useful coordinates y_min = -0.0086 # y min axes y_max = 0.1895 # y max axes @@ -85,6 +90,12 @@ def main(args): plt.plot(x, moyal(x, μ, σ), color='gray', label='Moyal') plt.legend() + # do Cauchy plot + if args.cauchy: + x = np.arange(-10, 10, 0.01) + plt.plot(x, cauchy(x), color='gray', label='Cauchy') + plt.legend() + # save figure plt.tight_layout() if args.show: @@ -96,6 +107,8 @@ def main(args): plt.savefig('slides/images/both-pdf.pdf', transparent=True) if args.area: plt.savefig('slides/images/median.pdf', transparent=True) + if args.cauchy: + plt.savefig('slides/images/cauchy-pdf.pdf') if __name__ == '__main__': @@ -116,5 +129,8 @@ if __name__ == '__main__': parser.add_argument('-a', '--area', action='store_true', default=False, help='do the area plot') + parser.add_argument('-c', '--cauchy', + action='store_true', default=False, + help='do the cauchy plot') args = parser.parse_args() main(args) diff --git a/slides/images/cauchy-pdf.pdf b/slides/images/cauchy-pdf.pdf new file mode 100644 index 0000000..809a82f Binary files /dev/null and b/slides/images/cauchy-pdf.pdf differ