mirror of
https://github.com/MartinThoma/LaTeX-examples.git
synced 2025-04-19 11:38:05 +02:00
added second image for LDA article
This commit is contained in:
parent
9558d8b3c1
commit
75bc9d0dae
6 changed files with 135 additions and 6 deletions
Binary file not shown.
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 26 KiB |
|
@ -3,6 +3,8 @@
|
|||
\usepackage[latin1]{inputenc}
|
||||
\usepackage{amsmath}
|
||||
\usepackage{pgfplots}
|
||||
\usepackage{tikz}
|
||||
\usetikzlibrary{arrows,positioning}
|
||||
\usepackage{helvet}
|
||||
\usepackage[eulergreek]{sansmath}
|
||||
|
||||
|
@ -67,6 +69,18 @@ every axis label/.append style={font=\sffamily\footnotesize},
|
|||
rotate=90,
|
||||
font=\boldmath\Large},
|
||||
]
|
||||
|
||||
\coordinate (plotAcoord) at (axis cs:70,0.024);
|
||||
\coordinate (plotAcoordY) at (axis cs:0,0.024);
|
||||
\draw[plotA,thick, dashed](plotAcoord -| plotAcoordY) -- (plotAcoord);
|
||||
|
||||
\coordinate (plotBcoord) at (axis cs:70,0.0004);
|
||||
\coordinate (plotBcoordY) at (axis cs:0,0.0004);
|
||||
\draw[plotB,thick, dashed](plotBcoord -| plotBcoordY) -- (plotBcoord);
|
||||
|
||||
\node[above right=0cm and 0cm of plotAcoordY,color=red!90!black] (f1y) {$f_{I}(70)$};
|
||||
\node[above right=0cm and 0cm of plotBcoordY,color=cyan!50!black] (f2y) {$f_{II}(70)$};
|
||||
|
||||
% Plots of the distributions
|
||||
\addplot [domain=0:120,samples=200,plotA] {gauss(80,100)};
|
||||
\addplot [domain=0:120,samples=200,plotB] {gauss(40,100)};
|
||||
|
@ -75,19 +89,18 @@ every axis label/.append style={font=\sffamily\footnotesize},
|
|||
\addplot+[plotA,
|
||||
samples at={70},
|
||||
mark=*,
|
||||
mark options={scale=1, fill=red!90!black}] {gauss(80,100)}
|
||||
node[pin={95:\large$f_I(70)$}] {};
|
||||
mark options={scale=1, fill=red!90!black}] {gauss(80,100)};
|
||||
\addplot+[plotB,
|
||||
samples at={70},
|
||||
mark=*,
|
||||
mark options={scale=1, fill=cyan!50!black}] {gauss(40,100)}
|
||||
node[pin={10:\large$f_{II}(70)$}] {};
|
||||
mark options={scale=1, fill=cyan!50!black}] {gauss(40,100)};
|
||||
\coordinate (a) at (axis cs:70,0.024);
|
||||
\draw[black,thick](a |- current plot begin) -- (a);
|
||||
|
||||
|
||||
% Add labels
|
||||
\node[plotA,above] at (axis cs:102,0.03){\Large $\mathcal{N}(80, 100)$};
|
||||
\node[plotB,above] at (axis cs:20,0.03){\Large $\mathcal{N}(40, 100)$};
|
||||
\node[plotA,above] at (axis cs:102,0.03){\Large $\mathcal{N}(80, 100)$};
|
||||
\node[plotB,above] at (axis cs:20,0.03){\Large $\mathcal{N}(40, 100)$};
|
||||
% \addlegendentry{$\mu=80,\enskip \sigma^2 = 100$}
|
||||
% \addlegendentry{$\mu=40,\enskip \sigma^2 = 100$}
|
||||
\end{axis}
|
||||
|
|
33
tikz/lda-gauss-2/Makefile
Normal file
33
tikz/lda-gauss-2/Makefile
Normal file
|
@ -0,0 +1,33 @@
|
|||
SOURCE = lda-gauss-2
|
||||
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
|
||||
rm $(SOURCE)1.svg
|
3
tikz/lda-gauss-2/README.md
Normal file
3
tikz/lda-gauss-2/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
Compiled example
|
||||
----------------
|
||||

|
BIN
tikz/lda-gauss-2/lda-gauss-2.png
Normal file
BIN
tikz/lda-gauss-2/lda-gauss-2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
80
tikz/lda-gauss-2/lda-gauss-2.tex
Normal file
80
tikz/lda-gauss-2/lda-gauss-2.tex
Normal file
|
@ -0,0 +1,80 @@
|
|||
\documentclass[varwidth=true, border=5pt]{article}
|
||||
\usepackage[active,tightpage]{preview}
|
||||
\usepackage[latin1]{inputenc}
|
||||
\usepackage{amsmath}
|
||||
\usepackage{pgfplots}
|
||||
\usepackage{tikz}
|
||||
\usetikzlibrary{arrows,positioning}
|
||||
\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}
|
||||
\tikzstyle{plotA}=[ultra thick,red!90!black]
|
||||
\tikzstyle{plotB}=[ultra thick,cyan!50!black]
|
||||
\begin{tikzpicture}
|
||||
\begin{axis}[
|
||||
width=13.5cm,
|
||||
height=8.625cm,
|
||||
% Grid
|
||||
grid = major,
|
||||
%grid style={thin, dashed},
|
||||
% size
|
||||
xmin= 0, % start the diagram at this x-coordinate
|
||||
xmax= 125, % 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,
|
||||
% xtick={40,70,80},
|
||||
ytick=\empty,
|
||||
% Axis
|
||||
axis lines = middle,
|
||||
axis line style = very thick,
|
||||
xlabel=$x$,
|
||||
x label style={at={(axis description cs:0.52,0)},
|
||||
anchor=north,
|
||||
font=\boldmath\Large},
|
||||
ylabel=$f(x)$,
|
||||
y label style={at={(axis description cs:0,0.5)},
|
||||
anchor=south,
|
||||
rotate=90,
|
||||
font=\boldmath\Large},
|
||||
]
|
||||
|
||||
% Plots of the distributions
|
||||
\addplot [domain=0:120,samples=200,plotA] {gauss(60,800)};
|
||||
\addplot [domain=0:120,samples=200,plotB] {gauss(40,100)};
|
||||
|
||||
|
||||
% Add labels
|
||||
\node[plotA,above] at (axis cs:102,0.01){\Large $\mathcal{N}(60, 800)$};
|
||||
\node[plotB,above] at (axis cs:20,0.03){\Large $\mathcal{N}(40, 100)$};
|
||||
% \addlegendentry{$\mu=80,\enskip \sigma^2 = 100$}
|
||||
% \addlegendentry{$\mu=40,\enskip \sigma^2 = 100$}
|
||||
\end{axis}
|
||||
\end{tikzpicture}
|
||||
\end{preview}
|
||||
\end{document}
|
Loading…
Add table
Add a link
Reference in a new issue