2
0
Fork 0
mirror of https://github.com/MartinThoma/LaTeX-examples.git synced 2025-04-19 11:38:05 +02:00

added lda-gauss-1

This commit is contained in:
Martin Thoma 2014-08-11 13:54:04 -04:00
parent 58ae839d5c
commit 872835611f
4 changed files with 106 additions and 0 deletions

32
tikz/lda-gauss-1/Makefile Normal file
View file

@ -0,0 +1,32 @@
SOURCE = lda-gauss-1
DELAY = 80
DENSITY = 300
WIDTH = 512
make:
pdflatex -shell-escape $(SOURCE).tex -output-format=pdf
make clean
clean:
rm -rf $(TARGET) *.class *.html *.log *.aux *.data *.gnuplot
gif:
pdfcrop $(SOURCE).pdf
convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif
make clean
png:
make
make svg
inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png
transparentGif:
convert $(SOURCE).pdf -transparent white result.gif
make clean
svg:
#inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg
pdf2svg $(SOURCE).pdf $(SOURCE)1.svg
# Necessary, as pdf2svg does not always create valid svgs:
inkscape $(SOURCE)1.svg --export-width=$(WIDTH) --export-plain-svg=$(SOURCE)1.svg
rsvg-convert -a -w 720 -f svg $(SOURCE)1.svg -o $(SOURCE).svg

View file

@ -0,0 +1,3 @@
Compiled example
----------------
![Example](lda-gauss-1.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View file

@ -0,0 +1,71 @@
\documentclass[varwidth=true, border=4pt]{article}
\usepackage[active,tightpage]{preview}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{pgfplots}
\usepackage{helvet}
\usepackage[eulergreek]{sansmath}
\pgfmathdeclarefunction{gauss}{2}{%
\pgfmathparse{1/(sqrt(2*pi*#2))*exp(-((x-#1)^2)/(2*#2))}%
}
% to be used: \gauss(x)(mean)(variance)
\pgfplotsset{
tick label style = {font=\sansmath\sffamily},
every axis label/.append style={font=\sffamily\footnotesize},
}
\begin{document}
\begin{preview}
\begin{tikzpicture}
\begin{axis}[
width=13.5cm,
height=8.625cm,
% Grid
grid = major,
grid style={black, thin},
% size
xmin= 0, % start the diagram at this x-coordinate
xmax= 120, % end the diagram at this x-coordinate
ymin= 0, % start the diagram at this y-coordinate
ymax= 0.045, % end the diagram at this y-coordinate
% Legende
legend style={
font=\large\sansmath\sffamily,
at={(0.5,-0.18)},
anchor=north,
legend cell align=left,
legend columns=-1,
column sep=0.5cm
},
% Ticks
tick align=inside,
minor tick num=3,
minor tick style={thick},
scaled y ticks = false,
yticklabel={\pgfmathparse{\tick*100}\pgfmathprintnumber{\pgfmathresult}\%},
yticklabel style={
%/pgf/number format/precision=2,
/pgf/number format/fixed,
%/pgf/number format/fixed zerofill
},
% Axis
axis line style = very thick,
xlabel=$x$,
x label style={at={(axis description cs:0.5,0)},
anchor=north,
font=\boldmath\Large},
ylabel=$\mathcal{N}_{\mu, \sigma^2}(x)$,
y label style={at={(axis description cs:0.05,0.5)},
anchor=south,
font=\boldmath\Large},
]
\addplot [domain=0:120,ultra thick,red!90!black,samples=200,] {gauss(80,100)};
\addplot [domain=0:120,ultra thick,cyan!50!black,samples=200] {gauss(40,100)};
\addlegendentry{$\mu=80,\enskip \sigma^2 = 100$}
\addlegendentry{$\mu=40,\enskip \sigma^2 = 100$}
\end{axis}
\end{tikzpicture}
\end{preview}
\end{document}