From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- macros/latex/contrib/thucoursework/matlabscript.m | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 macros/latex/contrib/thucoursework/matlabscript.m (limited to 'macros/latex/contrib/thucoursework/matlabscript.m') diff --git a/macros/latex/contrib/thucoursework/matlabscript.m b/macros/latex/contrib/thucoursework/matlabscript.m new file mode 100644 index 0000000000..a3b0693291 --- /dev/null +++ b/macros/latex/contrib/thucoursework/matlabscript.m @@ -0,0 +1,14 @@ +n = 1e6; % n samples +data = randn(1e6, 1); % Generate n Random Gaussian samples. +nbins = 50; % bins in your histogram +[cnt, x_hist] = hist(data, nbins); % not to plot, only to get emperical distribution. +figure; +cnt = cnt / n / (x_hist(2) - x_hist(1)); % normalization, be careful :) +bar(x_hist, cnt); % plot the hist using bar() +hold on; +x = -5 : 0.1 : 5; +plot(x, normpdf(x), 'r', 'linewidth', 2); +legend({'$\hat{p}_{\sf{x}}(x)$', '$p_{\sf{x}}(x)$'}, 'Interpreter', 'LaTeX', 'fontsize', 15); +xlabel('$x$', 'Interpreter', 'LaTeX', 'fontsize', 15); % You may change the size accordingly +ylabel('$p_{\sf{x}}(x)$', 'Interpreter', 'LaTeX', 'fontsize', 15); +title("\mlplaceholder{your-title-here}") \ No newline at end of file -- cgit v1.2.3