diff --git a/ex-1/plots/misc.py b/ex-1/plots/misc.py index 1109550..bec6279 100755 --- a/ex-1/plots/misc.py +++ b/ex-1/plots/misc.py @@ -6,23 +6,31 @@ 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 -# -c → args.cauchy → do the Cauchy PDF 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 +# -gm → args.gamo → do the Gaussian-Moyal compare plot +# -gl → args.gala → do the Gaussian-Landau compare plot +# -c → args.cauchy → do the Cauchy PDF plot +# Moyal PDF def moyal(x, μ, σ): N = (1)/(np.sqrt(2 * np.pi) * σ) return N * np.exp(- 0.5 * ((x - μ)/σ + np.exp(- (x - μ)/σ))) - +# Cauchy PDF def cauchy(x): return 1/(np.pi*(1 + x**2)) +# Gauss PDF +def gauss(x, μ, σ): + N = (1)/(np.sqrt(2 * np.pi) * σ) + return N * np.exp(- 0.5 * ((x - μ)/σ)**2) + def main(args): # prepare figure @@ -30,12 +38,12 @@ def main(args): plt.figure() elif args.save: plt.rcParams['font.size'] = 8 - if (args.both or args.area): + if (args.both or args.area or args.cauchy): plt.figure(figsize=(3, 2)) + elif (args.gamo or args.gala): + plt.figure(figsize=(2.5, 2)) elif args.note: plt.figure(figsize=(5, 3)) - elif args.cauchy: - plt.figure(figsize=(3, 2)) if args.note: # useful coordinates @@ -68,12 +76,13 @@ def main(args): plt.xlim(-10, 10) plt.ylim(y_min, y_max) - if args.both: + if (args.both): plt.ylim(-0.015, 0.265) # draw Landau plot - x, y = np.loadtxt(sys.stdin, unpack=True) - plt.plot(x, y, color='#92182b', label='Landau') + if not args.gamo: + x, y = np.loadtxt(sys.stdin, unpack=True) + plt.plot(x, y, color='#92182b', label='Landau') # Color the area under the function if args.area: @@ -82,20 +91,31 @@ def main(args): plt.fill_between(x[:x0], y[:x0], color='#ff99a8') plt.fill_between(x[x0:], y[x0:], color='#b28e94') - # do Moyal plot - if args.both: - μ = -0.22278298 - σ = 1.1191486 - x = np.arange(-10, 30, 0.01) - 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() + μ = -0.22278298 + σ = 1.1191486 + + # do Moyal plot + if (args.both or args.gamo): + x = np.arange(-10, 10, 0.01) + plt.plot(x, moyal(x, μ, σ), color='gray', label='Moyal') + plt.legend() + + # do Gaussian plot + if (args.gamo or args.gala): + x = np.arange(-10, 10, 0.01) + if args.gala: + a = 1.97 + if args.gamo: + a = 1.65 + plt.plot(x, gauss(x, μ, a*σ), color='#cfb017', label='Gauss') + plt.legend() + # save figure plt.tight_layout() if args.show: @@ -109,6 +129,10 @@ def main(args): plt.savefig('slides/images/median.pdf', transparent=True) if args.cauchy: plt.savefig('slides/images/cauchy-pdf.pdf', transparent=True) + if args.gamo: + plt.savefig('slides/images/gamo-pdf.pdf') + if args.gala: + plt.savefig('slides/images/gala-pdf.pdf') if __name__ == '__main__': @@ -132,5 +156,11 @@ if __name__ == '__main__': parser.add_argument('-c', '--cauchy', action='store_true', default=False, help='do the cauchy plot') + parser.add_argument('-gl', '--gala', + action='store_true', default=False, + help='do the gaussian-landau plot') + parser.add_argument('-gm', '--gamo', + action='store_true', default=False, + help='do the gaussian-moyal plot') args = parser.parse_args() main(args) diff --git a/slides/images/gala-pdf.pdf b/slides/images/gala-pdf.pdf new file mode 100644 index 0000000..4a8325a Binary files /dev/null and b/slides/images/gala-pdf.pdf differ diff --git a/slides/images/gamo-pdf.pdf b/slides/images/gamo-pdf.pdf new file mode 100644 index 0000000..f7be859 Binary files /dev/null and b/slides/images/gamo-pdf.pdf differ