summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/thucoursework/matlabscript.m
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/thucoursework/matlabscript.m
Initial commit
Diffstat (limited to 'macros/latex/contrib/thucoursework/matlabscript.m')
-rw-r--r--macros/latex/contrib/thucoursework/matlabscript.m14
1 files changed, 14 insertions, 0 deletions
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