diff options
author | Samuel Niederer <43746162+samnied@users.noreply.github.com> | 2022-07-24 12:17:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-24 12:17:00 +0200 |
commit | efe7c35759afb5cbae3c1683873c5159be0be09f (patch) | |
tree | 84f2e8510132352f9943bddc577ccf32cd46f2dc /buch/chapters/040-rekursion/images | |
parent | add current work (diff) | |
parent | Merge pull request #26 from p1mueller/master (diff) | |
download | SeminarSpezielleFunktionen-efe7c35759afb5cbae3c1683873c5159be0be09f.tar.gz SeminarSpezielleFunktionen-efe7c35759afb5cbae3c1683873c5159be0be09f.zip |
Merge branch 'AndreasFMueller:master' into master
Diffstat (limited to '')
-rw-r--r-- | buch/chapters/040-rekursion/images/0f1.cpp | 94 | ||||
-rw-r--r-- | buch/chapters/040-rekursion/images/0f1.pdf | bin | 0 -> 49497 bytes | |||
-rw-r--r-- | buch/chapters/040-rekursion/images/0f1.tex | 86 | ||||
-rw-r--r-- | buch/chapters/040-rekursion/images/Makefile | 30 | ||||
-rw-r--r-- | buch/chapters/040-rekursion/images/beta.pdf | bin | 0 -> 109772 bytes | |||
-rw-r--r-- | buch/chapters/040-rekursion/images/beta.tex | 236 | ||||
-rw-r--r-- | buch/chapters/040-rekursion/images/betadist.m | 58 | ||||
-rw-r--r-- | buch/chapters/040-rekursion/images/loggammaplot.m | 43 | ||||
-rw-r--r-- | buch/chapters/040-rekursion/images/loggammaplot.pdf | bin | 0 -> 30943 bytes | |||
-rw-r--r-- | buch/chapters/040-rekursion/images/loggammaplot.tex | 89 | ||||
-rw-r--r-- | buch/chapters/040-rekursion/images/order.m | 119 | ||||
-rw-r--r-- | buch/chapters/040-rekursion/images/order.pdf | bin | 0 -> 32688 bytes | |||
-rw-r--r-- | buch/chapters/040-rekursion/images/order.tex | 125 |
13 files changed, 879 insertions, 1 deletions
diff --git a/buch/chapters/040-rekursion/images/0f1.cpp b/buch/chapters/040-rekursion/images/0f1.cpp new file mode 100644 index 0000000..24ca3f1 --- /dev/null +++ b/buch/chapters/040-rekursion/images/0f1.cpp @@ -0,0 +1,94 @@ +/* + * 0f1.cpp + * + * (c) 2022 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule + */ +#include <cstring> +#include <cstdio> +#include <cstdlib> +#include <cmath> +#include <string> +#include <iostream> +#include <fstream> + +static int N = 100; +static double xmin = -50; +static double xmax = 30; +static int points = 200; + +double f(double b, double x) { + double s = 1; + double p = 1; + for (int k = 1; k < N; k++) { + p = p * x / (k * (b + k - 1.)); + s += p; + } + return s; +} + +typedef std::pair<double, double> point_t; + +point_t F(double b, double x) { + return std::make_pair(x, f(b, x)); +} + +std::string ff(double f) { + if (f > 1000) { f = 1000; } + if (f < -1000) { f = -1000; } + char b[128]; + snprintf(b, sizeof(b), "%.4f", f); + return std::string(b); +} + +std::ostream& operator<<(std::ostream& out, const point_t& p) { + char b[128]; + out << "({" << ff(p.first) << "*\\dx},{" << ff(p.second) << "*\\dy})"; + return out; +} + +void curve(std::ostream& out, double b, const std::string& name) { + double h = (xmax - xmin) / points; + out << "\\def\\kurve" << name << "{"; + out << std::endl << "\t" << F(b, xmin); + for (int i = 1; i <= points; i++) { + double x = xmin + h * i; + out << std::endl << "\t-- " << F(b, x); + } + out << std::endl; + out << "}" << std::endl; +} + +int main(int argc, char *argv[]) { + std::ofstream out("0f1data.tex"); + + double s = 13/(xmax-xmin); + out << "\\def\\dx{" << ff(s) << "}" << std::endl; + out << "\\def\\dy{" << ff(s) << "}" << std::endl; + out << "\\def\\xmin{" << ff(s * xmin) << "}" << std::endl; + out << "\\def\\xmax{" << ff(s * xmax) << "}" << std::endl; + + curve(out, 0.5, "one"); + curve(out, 1.5, "two"); + curve(out, 2.5, "three"); + curve(out, 3.5, "four"); + curve(out, 4.5, "five"); + curve(out, 5.5, "six"); + curve(out, 6.5, "seven"); + curve(out, 7.5, "eight"); + curve(out, 8.5, "nine"); + curve(out, 9.5, "ten"); + + curve(out,-0.5, "none"); + curve(out,-1.5, "ntwo"); + curve(out,-2.5, "nthree"); + curve(out,-3.5, "nfour"); + curve(out,-4.5, "nfive"); + curve(out,-5.5, "nsix"); + curve(out,-6.5, "nseven"); + curve(out,-7.5, "neight"); + curve(out,-8.5, "nnine"); + curve(out,-9.5, "nten"); + + out.close(); + return EXIT_SUCCESS; +} diff --git a/buch/chapters/040-rekursion/images/0f1.pdf b/buch/chapters/040-rekursion/images/0f1.pdf Binary files differnew file mode 100644 index 0000000..2c35813 --- /dev/null +++ b/buch/chapters/040-rekursion/images/0f1.pdf diff --git a/buch/chapters/040-rekursion/images/0f1.tex b/buch/chapters/040-rekursion/images/0f1.tex new file mode 100644 index 0000000..1bc8b87 --- /dev/null +++ b/buch/chapters/040-rekursion/images/0f1.tex @@ -0,0 +1,86 @@ +% +% 0f1.tex -- template for standalon tikz images +% +% (c) 2021 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule +% +\documentclass[tikz]{standalone} +\usepackage{amsmath} +\usepackage{times} +\usepackage{txfonts} +\usepackage{pgfplots} +\usepackage{csvsimple} +\usetikzlibrary{arrows,intersections,math} +\begin{document} +\def\skala{1} +\input{0f1data.tex} +\definecolor{darkgreen}{rgb}{0,0.6,0} +\begin{tikzpicture}[>=latex,thick,scale=\skala] + +\begin{scope} +\clip (\xmin,-1) rectangle (\xmax,5); +\draw[color=blue!5!red,line width=1.4pt] \kurveone; +\draw[color=blue!16!red,line width=1.4pt] \kurvetwo; +\draw[color=blue!26!red,line width=1.4pt] \kurvethree; +\draw[color=blue!37!red,line width=1.4pt] \kurvefour; +\draw[color=blue!47!red,line width=1.4pt] \kurvefive; +\draw[color=blue!57!red,line width=1.4pt] \kurvesix; +\draw[color=blue!68!red,line width=1.4pt] \kurveseven; +\draw[color=blue!78!red,line width=1.4pt] \kurveeight; +\draw[color=blue!89!red,line width=1.4pt] \kurvenine; +\draw[color=blue!100!red,line width=1.4pt] \kurveten; +\def\ds{0.4} +\begin{scope}[yshift=0.5cm] +\node[color=blue!5!red] at (\xmin,{1*\ds}) [right] {$\alpha=0.5$}; +\node[color=blue!16!red] at (\xmin,{2*\ds}) [right] {$\alpha=1.5$}; +\node[color=blue!26!red] at (\xmin,{3*\ds}) [right] {$\alpha=2.5$}; +\node[color=blue!37!red] at (\xmin,{4*\ds}) [right] {$\alpha=2.5$}; +\node[color=blue!47!red] at (\xmin,{5*\ds}) [right] {$\alpha=3.5$}; +\node[color=blue!57!red] at (\xmin,{6*\ds}) [right] {$\alpha=5.5$}; +\node[color=blue!68!red] at (\xmin,{7*\ds}) [right] {$\alpha=6.5$}; +\node[color=blue!78!red] at (\xmin,{8*\ds}) [right] {$\alpha=7.5$}; +\node[color=blue!89!red] at (\xmin,{9*\ds}) [right] {$\alpha=8.5$}; +\node[color=blue!100!red]at (\xmin,{10*\ds}) [right] {$\alpha=9.5$}; +\end{scope} +\node at (-1.7,4.5) {$\displaystyle +y=\mathstrut_0F_1\biggl(\begin{matrix}\text{---}\\\alpha\end{matrix};x\biggr)$}; +\end{scope} + +\draw[->] (\xmin-0.2,0) -- (\xmax+0.3,0) coordinate[label=$x$]; +\draw[->] (0,-0.5) -- (0,5.3) coordinate[label={right:$y$}]; + +\begin{scope}[yshift=-6.5cm] +\begin{scope} +\clip (\xmin,-5) rectangle (\xmax,5); + +\draw[color=darkgreen!5!red,line width=1.4pt] \kurvenone; +\draw[color=darkgreen!16!red,line width=1.4pt] \kurventwo; +\draw[color=darkgreen!26!red,line width=1.4pt] \kurventhree; +\draw[color=darkgreen!37!red,line width=1.4pt] \kurvenfour; +\draw[color=darkgreen!47!red,line width=1.4pt] \kurvenfive; +\draw[color=darkgreen!57!red,line width=1.4pt] \kurvensix; +\draw[color=darkgreen!68!red,line width=1.4pt] \kurvenseven; +\draw[color=darkgreen!78!red,line width=1.4pt] \kurveneight; +\draw[color=darkgreen!89!red,line width=1.4pt] \kurvennine; +\draw[color=darkgreen!100!red,line width=1.4pt] \kurventen; +\end{scope} + +\draw[->] (\xmin-0.2,0) -- (\xmax+0.3,0) coordinate[label=$x$]; +\draw[->] (0,-5.2) -- (0,5.3) coordinate[label={right:$y$}]; +\def\ds{-0.4} +\begin{scope}[yshift=-0.5cm] +\node[color=darkgreen!5!red] at (\xmax,{1*\ds}) [left] {$\alpha=-0.5$}; +\node[color=darkgreen!16!red] at (\xmax,{2*\ds}) [left] {$\alpha=-1.5$}; +\node[color=darkgreen!26!red] at (\xmax,{3*\ds}) [left] {$\alpha=-2.5$}; +\node[color=darkgreen!37!red] at (\xmax,{4*\ds}) [left] {$\alpha=-2.5$}; +\node[color=darkgreen!47!red] at (\xmax,{5*\ds}) [left] {$\alpha=-3.5$}; +\node[color=darkgreen!57!red] at (\xmax,{6*\ds}) [left] {$\alpha=-5.5$}; +\node[color=darkgreen!68!red] at (\xmax,{7*\ds}) [left] {$\alpha=-6.5$}; +\node[color=darkgreen!78!red] at (\xmax,{8*\ds}) [left] {$\alpha=-7.5$}; +\node[color=darkgreen!89!red] at (\xmax,{9*\ds}) [left] {$\alpha=-8.5$}; +\node[color=darkgreen!100!red]at (\xmax,{10*\ds}) [left] {$\alpha=-9.5$}; +\end{scope} +\end{scope} + +\end{tikzpicture} +\end{document} + diff --git a/buch/chapters/040-rekursion/images/Makefile b/buch/chapters/040-rekursion/images/Makefile index 9608a94..54ed23b 100644 --- a/buch/chapters/040-rekursion/images/Makefile +++ b/buch/chapters/040-rekursion/images/Makefile @@ -3,7 +3,8 @@ # # (c) 2021 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule # -all: gammaplot.pdf fibonacci.pdf +all: gammaplot.pdf fibonacci.pdf order.pdf beta.pdf loggammaplot.pdf \ + 0f1.pdf gammaplot.pdf: gammaplot.tex gammapaths.tex pdflatex gammaplot.tex @@ -16,3 +17,30 @@ fibonaccigrid.tex: fibonacci.m fibonacci.pdf: fibonacci.tex fibonaccigrid.tex pdflatex fibonacci.tex + +order.pdf: order.tex orderpath.tex + pdflatex order.tex + +orderpath.tex: order.m + octave order.m + +beta.pdf: beta.tex betapaths.tex + pdflatex beta.tex + +betapaths.tex: betadist.m + octave betadist.m + +loggammaplot.pdf: loggammaplot.tex loggammadata.tex + pdflatex loggammaplot.tex + +loggammadata.tex: loggammaplot.m + octave loggammaplot.m + +0f1: 0f1.cpp + g++ -O -Wall -g -o 0f1 0f1.cpp + +0f1data.tex: 0f1 + ./0f1 + +0f1.pdf: 0f1.tex 0f1data.tex + pdflatex 0f1.tex diff --git a/buch/chapters/040-rekursion/images/beta.pdf b/buch/chapters/040-rekursion/images/beta.pdf Binary files differnew file mode 100644 index 0000000..0e6567b --- /dev/null +++ b/buch/chapters/040-rekursion/images/beta.pdf diff --git a/buch/chapters/040-rekursion/images/beta.tex b/buch/chapters/040-rekursion/images/beta.tex new file mode 100644 index 0000000..1e1a1b3 --- /dev/null +++ b/buch/chapters/040-rekursion/images/beta.tex @@ -0,0 +1,236 @@ +% +% beta.tex -- display some symmetric beta distributions +% +% (c) 2021 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule +% +\documentclass[tikz]{standalone} +\usepackage{amsmath} +\usepackage{times} +\usepackage{txfonts} +\usepackage{pgfplots} +\usepackage{csvsimple} +\usetikzlibrary{arrows,intersections,math,calc} +\input{betapaths.tex} +\begin{document} +\def\skala{12} +\definecolor{colorone}{rgb}{1.0,0.6,0.0} +\definecolor{colortwo}{rgb}{1.0,0.0,0.0} +\definecolor{colorthree}{rgb}{0.6,0.0,0.6} +\definecolor{colorfour}{rgb}{0.6,0.0,1.0} +\definecolor{colorfive}{rgb}{0.0,0.0,1.0} +\definecolor{colorsix}{rgb}{0.4,0.6,1.0} +\definecolor{colorseven}{rgb}{0.0,0.0,0.0} +\definecolor{coloreight}{rgb}{0.0,0.8,0.8} +\definecolor{colornine}{rgb}{0.0,0.8,0.2} +\definecolor{colorten}{rgb}{0.2,0.4,0.0} +\definecolor{coloreleven}{rgb}{0.6,1.0,0.0} +\definecolor{colortwelve}{rgb}{1.0,0.8,0.4} + +\def\achsen{ + \foreach \x in {0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9}{ + \draw ({\x*\dx},{-0.1/\skala}) -- ({\x*\dx},{0.1/\skala}); + \node at ({\x*\dx},{-0.1/\skala}) [below] {$\x$}; + } + \foreach \y in {1,2,3,4}{ + \draw ({-0.1/\skala},{\y*\dy}) -- ({0.1/\skala},{\y*\dy}); + \node at ({-0.1/\skala},{\y*\dy}) [left] {$\y$}; + } + \def\x{1} + \draw ({\x*\dx},{-0.1/\skala}) -- ({\x*\dx},{0.1/\skala}); + \node at ({\x*\dx},{-0.1/\skala}) [below] {$\x$}; + \def\x{0} + \node at ({\x*\dx},{-0.1/\skala}) [below] {$\x$}; + + \draw[->] ({-0.1/\skala},0) -- ({1*\dx+0.4/\skala},0) + coordinate[label={$x$}]; + \draw[->] (0,{-0.1/\skala}) -- (0,{\betamax*\dy+0.4/\skala},0) + coordinate[label={right:$\beta(a,b,x)$}]; +} + +\def\farbcoord#1#2{ + ({\dx*(0.63+((#1)/5)*0.27)},{\dx*(0.18+((#2)/5)*0.27)}) +} +\def\farbviereck{ + \foreach \x in {1,2,3,4}{ + \draw[color=gray!30] \farbcoord{\x}{0} -- \farbcoord{\x}{4}; + \draw[color=gray!30] \farbcoord{0}{\x} -- \farbcoord{4}{\x}; + } + \draw[->] \farbcoord{0}{0} -- \farbcoord{4.4}{0} + coordinate[label={$a$}]; + \draw[->] \farbcoord{0}{0} -- \farbcoord{0}{4.4} + coordinate[label={left: $b$}]; + \foreach \x in {1,2,3,4}{ + \node[color=gray] at \farbcoord{4}{\x} [right] {\tiny $b=\x$}; + %\fill[color=white,opacity=0.7] + % \farbcoord{(\x-0.1)}{3.3} + % rectangle + % \farbcoord{(\x+0.1)}{4}; + \node[color=gray] at \farbcoord{\x}{4} [right,rotate=90] + {\tiny $a=\x$}; + } +} +\def\farbpunkt#1#2#3{ + \fill[color=#3] \farbcoord{#1}{#2} circle[radius={0.1/\skala}]; +} + +\begin{tikzpicture}[>=latex,thick,scale=\skala] + +\def\dx{1.15} +\def\dy{0.1} +\def\opa{0.1} + +\def\betamax{4.9} + +\begin{scope} +\clip (0,0) rectangle ({1*\dx},{\betamax*\dy}); +\fill[color=colorone,opacity=\opa] (0,0) -- \betaaa -- (\dx,0) -- cycle; +\fill[color=colortwo,opacity=\opa] (0,0) -- \betabb -- (\dx,0) -- cycle; +\fill[color=colorthree,opacity=\opa] (0,0) -- \betacc -- (\dx,0) -- cycle; +\fill[color=colorfour,opacity=\opa] (0,0) -- \betadd -- (\dx,0) -- cycle; +\fill[color=colorfive,opacity=\opa] (0,0) -- \betaee -- (\dx,0) -- cycle; +\fill[color=colorsix,opacity=\opa] (0,0) -- \betaff -- (\dx,0) -- cycle; +\fill[color=colorseven,opacity=\opa] (0,0) -- \betagg -- (\dx,0) -- cycle; +\fill[color=coloreight,opacity=\opa] (0,0) -- \betahh -- (\dx,0) -- cycle; +\fill[color=colornine,opacity=\opa] (0,0) -- \betaii -- (\dx,0) -- cycle; +\fill[color=colorten,opacity=\opa] (0,0) -- \betajj -- (\dx,0) -- cycle; +\fill[color=coloreleven,opacity=\opa] (0,0) -- \betakk -- (\dx,0) -- cycle; +\fill[color=colortwelve,opacity=\opa] (0,0) -- \betall -- (\dx,0) -- cycle; + +\draw[color=colorone] \betaaa; +\draw[color=colortwo] \betabb; +\draw[color=colorthree] \betacc; +\draw[color=colorfour] \betadd; +\draw[color=colorfive] \betaee; +\draw[color=colorsix] \betaff; +\draw[color=colorseven] \betagg; +\draw[color=coloreight] \betahh; +\draw[color=colornine] \betaii; +\draw[color=colorten] \betajj; +\draw[color=coloreleven] \betakk; +\draw[color=colortwelve] \betall; + +\end{scope} + +\achsen + +\farbviereck + +\farbpunkt{\alphatwelve}{\betatwelve}{colortwelve} +\farbpunkt{\alphaeleven}{\betaeleven}{coloreleven} +\farbpunkt{\alphaten}{\betaten}{colorten} +\farbpunkt{\alphanine}{\betanine}{colornine} +\farbpunkt{\alphaeight}{\betaeight}{coloreight} +\farbpunkt{\alphaseven}{\betaseven}{colorseven} +\farbpunkt{\alphasix}{\betasix}{colorsix} +\farbpunkt{\alphafive}{\betafive}{colorfive} +\farbpunkt{\alphafour}{\betafour}{colorfour} +\farbpunkt{\alphathree}{\betathree}{colorthree} +\farbpunkt{\alphatwo}{\betatwo}{colortwo} +\farbpunkt{\alphaone}{\betaone}{colorone} + + +\def\betamax{4.9} + +\begin{scope}[yshift=-0.6cm] + +\begin{scope} +\clip (0,0) rectangle ({1*\dx},{\betamax*\dy}); +\fill[color=colorone,opacity=\opa] (0,0) -- \betaea -- (\dx,0) -- cycle; +\fill[color=colortwo,opacity=\opa] (0,0) -- \betaeb -- (\dx,0) -- cycle; +\fill[color=colorthree,opacity=\opa] (0,0) -- \betaec -- (\dx,0) -- cycle; +\fill[color=colorfour,opacity=\opa] (0,0) -- \betaed -- (\dx,0) -- cycle; +\fill[color=colorfive,opacity=\opa] (0,0) -- \betaee -- (\dx,0) -- cycle; +\fill[color=colorsix,opacity=\opa] (0,0) -- \betaef -- (\dx,0) -- cycle; +\fill[color=colorseven,opacity=\opa] (0,0) -- \betaeg -- (\dx,0) -- cycle; +\fill[color=coloreight,opacity=\opa] (0,0) -- \betaeh -- (\dx,0) -- cycle; +\fill[color=colornine,opacity=\opa] (0,0) -- \betaei -- (\dx,0) -- cycle; +\fill[color=colorten,opacity=\opa] (0,0) -- \betaej -- (\dx,0) -- cycle; +\fill[color=coloreleven,opacity=\opa] (0,0) -- \betaek -- (\dx,0) -- cycle; +\fill[color=colortwelve,opacity=\opa] (0,0) -- \betael -- (\dx,0) -- cycle; + +\draw[color=colorone] \betaea; +\draw[color=colortwo] \betaeb; +\draw[color=colorthree] \betaec; +\draw[color=colorfour] \betaed; +\draw[color=colorfive] \betaee; +\draw[color=colorsix] \betaef; +\draw[color=colorseven] \betaeg; +\draw[color=coloreight] \betaeh; +\draw[color=colornine] \betaei; +\draw[color=colorten] \betaej; +\draw[color=coloreleven] \betaek; +\draw[color=colortwelve] \betael; +\end{scope} + +\achsen + +\farbviereck + +\farbpunkt{\alphafive}{\betatwelve}{colortwelve} +\farbpunkt{\alphafive}{\betaeleven}{coloreleven} +\farbpunkt{\alphafive}{\betaten}{colorten} +\farbpunkt{\alphafive}{\betanine}{colornine} +\farbpunkt{\alphafive}{\betaeight}{coloreight} +\farbpunkt{\alphafive}{\betaseven}{colorseven} +\farbpunkt{\alphafive}{\betasix}{colorsix} +\farbpunkt{\alphafive}{\betafive}{colorfive} +\farbpunkt{\alphafive}{\betafour}{colorfour} +\farbpunkt{\alphafive}{\betathree}{colorthree} +\farbpunkt{\alphafive}{\betatwo}{colortwo} +\farbpunkt{\alphafive}{\betaone}{colorone} + +\end{scope} + +\begin{scope}[yshift=-1.2cm] + +\begin{scope} +\clip (0,0) rectangle ({1*\dx},{\betamax*\dy}); +\fill[color=colorone,opacity=\opa] (0,0) -- \betaal -- (\dx,0) -- cycle; +\fill[color=colortwo,opacity=\opa] (0,0) -- \betabl -- (\dx,0) -- cycle; +\fill[color=colorthree,opacity=\opa] (0,0) -- \betacl -- (\dx,0) -- cycle; +\fill[color=colorfour,opacity=\opa] (0,0) -- \betadl -- (\dx,0) -- cycle; +\fill[color=colorfive,opacity=\opa] (0,0) -- \betael -- (\dx,0) -- cycle; +\fill[color=colorsix,opacity=\opa] (0,0) -- \betafl -- (\dx,0) -- cycle; +\fill[color=colorseven,opacity=\opa] (0,0) -- \betagl -- (\dx,0) -- cycle; +\fill[color=coloreight,opacity=\opa] (0,0) -- \betahl -- (\dx,0) -- cycle; +\fill[color=colornine,opacity=\opa] (0,0) -- \betail -- (\dx,0) -- cycle; +\fill[color=colorten,opacity=\opa] (0,0) -- \betajl -- (\dx,0) -- cycle; +\fill[color=coloreleven,opacity=\opa] (0,0) -- \betakl -- (\dx,0) -- cycle; +\fill[color=colortwelve,opacity=\opa] (0,0) -- \betall -- (\dx,0) -- cycle; + +\draw[color=colorone] \betaal; +\draw[color=colortwo] \betabl; +\draw[color=colorthree] \betacl; +\draw[color=colorfour] \betadl; +\draw[color=colorfive] \betael; +\draw[color=colorsix] \betafl; +\draw[color=colorseven] \betagl; +\draw[color=coloreight] \betahl; +\draw[color=colornine] \betail; +\draw[color=colorten] \betajl; +\draw[color=coloreleven] \betakl; +\draw[color=colortwelve] \betall; +\end{scope} + +\achsen + +\farbviereck + +\farbpunkt{\alphatwelve}{\betatwelve}{colortwelve} +\farbpunkt{\alphaeleven}{\betatwelve}{coloreleven} +\farbpunkt{\alphaten}{\betatwelve}{colorten} +\farbpunkt{\alphanine}{\betatwelve}{colornine} +\farbpunkt{\alphaeight}{\betatwelve}{coloreight} +\farbpunkt{\alphaseven}{\betatwelve}{colorseven} +\farbpunkt{\alphasix}{\betatwelve}{colorsix} +\farbpunkt{\alphafive}{\betatwelve}{colorfive} +\farbpunkt{\alphafour}{\betatwelve}{colorfour} +\farbpunkt{\alphathree}{\betatwelve}{colorthree} +\farbpunkt{\alphatwo}{\betatwelve}{colortwo} +\farbpunkt{\alphaone}{\betatwelve}{colorone} + +\end{scope} + +\end{tikzpicture} +\end{document} + diff --git a/buch/chapters/040-rekursion/images/betadist.m b/buch/chapters/040-rekursion/images/betadist.m new file mode 100644 index 0000000..5b466a6 --- /dev/null +++ b/buch/chapters/040-rekursion/images/betadist.m @@ -0,0 +1,58 @@ +# +# betadist.m +# +# (c) 2022 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule +# +global N; +N = 201; +global nmin; +global nmax; +nmin = -4; +nmax = 7; +n = nmax - nmin + 1 +A = 3; + +t = (nmin:nmax) / nmax; +alpha = 1 + A * t .* abs(t) +#alpha(1) = 0.01; + +#alpha = [ 1, 1.03, 1.05, 1.1, 1.25, 1.5, 2, 2.5, 3, 4, 5 ]; +beta = alpha; +names = [ "one"; "two"; "three"; "four"; "five"; "six"; "seven"; "eight"; + "nine"; "ten"; "eleven"; "twelve" ] + +function retval = Beta(a, b, x) + retval = x^(a-1) * (1-x)^(b-1) / beta(a, b); + if (retval > 100) + retval = 100 + end +end + +function plotbeta(fn, a, b, name) + global N; + fprintf(fn, "\\def\\beta%s{\n", strtrim(name)); + fprintf(fn, "\t({%.4f*\\dx},{%.4f*\\dy})", 0, Beta(a, b, 0)); + for x = (1:N-1)/(N-1) + X = (1-cos(pi * x))/2; + fprintf(fn, "\n\t--({%.4f*\\dx},{%.4f*\\dy})", + X, Beta(a, b, X)); + end + fprintf(fn, "\n}\n"); +end + +fn = fopen("betapaths.tex", "w"); + +for i = (1:n) + fprintf(fn, "\\def\\alpha%s{%f}\n", strtrim(names(i,:)), alpha(i)); + fprintf(fn, "\\def\\beta%s{%f}\n", strtrim(names(i,:)), beta(i)); +end + +for i = (1:n) + for j = (1:n) + printf("working on %d,%d:\n", i, j); + plotbeta(fn, alpha(i), beta(j), + char(['a' + i - 1, 'a' + j - 1])); + end +end + +fclose(fn); diff --git a/buch/chapters/040-rekursion/images/loggammaplot.m b/buch/chapters/040-rekursion/images/loggammaplot.m new file mode 100644 index 0000000..5456e4f --- /dev/null +++ b/buch/chapters/040-rekursion/images/loggammaplot.m @@ -0,0 +1,43 @@ +# +# loggammaplot.m +# +# (c) 2022 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule +# +xmax = 10; +xmin = 0.1; +N = 500; + +fn = fopen("loggammadata.tex", "w"); + +fprintf(fn, "\\def\\loggammapath{\n ({%.4f*\\dx},{%.4f*\\dy})", + xmax, log(gamma(xmax))); +xstep = (xmax - 1) / N; +for x = (xmax:-xstep:1) + fprintf(fn, "\n\t-- ({%.4f*\\dx},{%.4f*\\dy})", x, log(gamma(x))); +endfor +for k = (0:0.2:10) + x = exp(-k); + fprintf(fn, "\n\t-- ({%.4f*\\dx},{%.4f*\\dy})", x, log(gamma(x))); +endfor +fprintf(fn, "\n}\n"); + +function retval = lgp(fn, x0, name) + fprintf(fn, "\\def\\loggammaplot%s{\n", name); + fprintf(fn, "\\draw[color=red,line width=1pt] "); + for k = (-7:0.1:7) + x = x0 + 0.5 * tanh(k); + if (k > -5) + fprintf(fn, "\n\t-- "); + end + fprintf(fn, "({%.4f*\\dx},{%.4f*\\dy})", x, log(gamma(x))); + endfor + fprintf(fn, ";\n}\n"); +endfunction + +lgp(fn, -0.5, "zero"); +lgp(fn, -1.5, "one"); +lgp(fn, -2.5, "two"); +lgp(fn, -3.5, "three"); +lgp(fn, -4.5, "four"); + +fclose(fn); diff --git a/buch/chapters/040-rekursion/images/loggammaplot.pdf b/buch/chapters/040-rekursion/images/loggammaplot.pdf Binary files differnew file mode 100644 index 0000000..a2963f2 --- /dev/null +++ b/buch/chapters/040-rekursion/images/loggammaplot.pdf diff --git a/buch/chapters/040-rekursion/images/loggammaplot.tex b/buch/chapters/040-rekursion/images/loggammaplot.tex new file mode 100644 index 0000000..8ca4e1c --- /dev/null +++ b/buch/chapters/040-rekursion/images/loggammaplot.tex @@ -0,0 +1,89 @@ +% +% tikztemplate.tex -- template for standalon tikz images +% +% (c) 2021 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule +% +\documentclass[tikz]{standalone} +\usepackage{amsmath} +\usepackage{times} +\usepackage{txfonts} +\usepackage{pgfplots} +\usepackage{csvsimple} +\usetikzlibrary{arrows,intersections,math} +\begin{document} +\def\skala{1} +\input{loggammadata.tex} +\begin{tikzpicture}[>=latex,thick,scale=\skala] + +% add image content here + +\def\dx{1} +\def\dy{0.6} +\def\xmax{8} +\def\xmin{-4.9} +\def\ymax{8} +\def\ymin{-3.1} + +\fill[color=blue!20] ({\xmin*\dx},{\ymin*\dy}) rectangle ({-4*\dx},{\ymax*\dy}); +\fill[color=blue!20] ({-3*\dx},{\ymin*\dy}) rectangle ({-2*\dx},{\ymax*\dy}); +\fill[color=blue!20] ({-1*\dx},{\ymin*\dy}) rectangle ({-0*\dx},{\ymax*\dy}); + +\draw[->] ({\xmin*\dx-0.1},0) -- ({\xmax*\dx+0.3},0) + coordinate[label={$x$}]; +\draw[->] (0,{\ymin*\dy-0.1}) -- (0,{\ymax*\dy+0.3}) + coordinate[label={right:$y$}]; + +\begin{scope} +\clip ({\xmin*\dx},{\ymin*\dy}) rectangle ({\xmax*\dx},{\ymax*\dy}); + +\foreach \x in {-1,-2,-3,-4}{ + \draw[color=blue,line width=0.3pt] + ({\x*\dx},{\ymin*\dy}) -- ({\x*\dx},{\ymax*\dy}); +} + +\draw[color=red,line width=1pt] \loggammapath; + +\loggammaplotzero +\loggammaplotone +\loggammaplottwo +\loggammaplotthree +\loggammaplotfour + +\end{scope} + +\foreach \y in {0.1,10,100,1000,1000}{ + \draw[line width=0.3pt] + ({\xmin*\dx},{ln(\y)*\dy}) + -- + ({\xmax*\dx},{ln(\y)*\dy}) ; +} + +\foreach \x in {1,...,8}{ + \draw ({\x*\dx},{-0.05}) -- ({\x*\dx},{0.05}); + \node at ({\x*\dx},0) [below] {$\x$}; +} + +\foreach \x in {-1,...,-4}{ + \draw ({\x*\dx},{-0.05}) -- ({\x*\dx},{0.05}); +} +\foreach \x in {-1,...,-3}{ + \node at ({\x*\dx},0) [below right] {$\x$}; +} +\node at ({-4*\dx},0) [below left] {$-4$}; + +\def\htick#1#2{ + \draw (-0.05,{ln(#1)*\dy}) -- (0.05,{ln(#1)*\dy}); + \node at (0,{ln(#1)*\dy}) [above right] {#2}; +} + +\htick{10}{$10^1$} +\htick{100}{$10^2$} +\htick{1000}{$10^3$} +\htick{0.1}{$10^{-1}$} + +\node[color=red] at ({3*\dx},{ln(30)*\dy}) {$y=\log|\Gamma(x)|$}; + + +\end{tikzpicture} +\end{document} + diff --git a/buch/chapters/040-rekursion/images/order.m b/buch/chapters/040-rekursion/images/order.m new file mode 100644 index 0000000..762f458 --- /dev/null +++ b/buch/chapters/040-rekursion/images/order.m @@ -0,0 +1,119 @@ +# +# order.m +# +# (c) 2022 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule +# +global N; +N = 10; +global subdivisions; +subdivisions = 100; +global P; +P = 0.5 + +function retval = orderF(p, n, k) + retval = 0; + for i = (k:n) + retval = retval + nchoosek(n,i) * p^i * (1-p)^(n-i); + end +end + +function retval = orderd(p, n, k) + retval = 0; + for i = (k:n) + s = i * p^(i-1) * (1-p)^(n-i); + s = s - p^i * (n-i) * (1-p)^(n-i-1); + retval = retval + nchoosek(n,i) * s; + end +end + +function retval = orders(p, n, k) + retval = k * nchoosek(n, k) * p^(k-1) * (1-p)^(n-k); +end + +function orderpath(fn, k, name) + fprintf(fn, "\\def\\order%s{\n\t(0,0)", name); + global N; + global subdivisions; + for i = (0:subdivisions) + p = i/subdivisions; + fprintf(fn, "\n\t-- ({%.4f*\\dx},{%.4f*\\dy})", + p, orderF(p, N, k)); + end + fprintf(fn, "\n}\n"); +end + +function orderdpath(fn, k, name) + fprintf(fn, "\\def\\orderd%s{\n\t(0,0)", name); + global N; + global subdivisions; + for i = (1:subdivisions-1) + p = i/subdivisions; + fprintf(fn, "\n\t-- ({%.4f*\\dx},{%.4f*\\dy})", + p, orderd(p, N, k)); + end + fprintf(fn, "\n\t-- ({1*\\dx},0)"); + fprintf(fn, "\n}\n"); +end + +function orderspath(fn, k, name) + fprintf(fn, "\\def\\orders%s{\n\t(0,0)", name); + global N; + global subdivisions; + for i = (1:subdivisions-1) + p = i/subdivisions; + fprintf(fn, "\n\t-- ({%.4f*\\dx},{%.4f*\\dy})", + p, orders(p, N, k)); + end + fprintf(fn, "\n\t-- ({1*\\dx},0)"); + fprintf(fn, "\n}\n"); +end + +fn = fopen("orderpath.tex", "w"); + +orderpath(fn, 0, "zero"); +orderdpath(fn, 0, "zero"); +orderspath(fn, 0, "zero"); + +orderpath(fn, 1, "one"); +orderdpath(fn, 1, "one"); +orderspath(fn, 1, "one"); + +orderpath(fn, 2, "two"); +orderdpath(fn, 2, "two"); +orderspath(fn, 2, "two"); + +orderpath(fn, 3, "three"); +orderdpath(fn, 3, "three"); +orderspath(fn, 3, "three"); + +orderpath(fn, 4, "four"); +orderdpath(fn, 4, "four"); +orderspath(fn, 4, "four"); + +orderpath(fn, 5, "five"); +orderdpath(fn, 5, "five"); +orderspath(fn, 5, "five"); + +orderpath(fn, 6, "six"); +orderdpath(fn, 6, "six"); +orderspath(fn, 6, "six"); + +orderpath(fn, 7, "seven"); +orderdpath(fn, 7, "seven"); +orderspath(fn, 7, "seven"); + +orderpath(fn, 8, "eight"); +orderdpath(fn, 8, "eight"); +orderspath(fn, 8, "eight"); + +orderpath(fn, 9, "nine"); +orderdpath(fn, 9, "nine"); +orderspath(fn, 9, "nine"); + +orderpath(fn, 10, "ten"); +orderdpath(fn, 10, "ten"); +orderspath(fn, 10, "ten"); + +fclose(fn); + + diff --git a/buch/chapters/040-rekursion/images/order.pdf b/buch/chapters/040-rekursion/images/order.pdf Binary files differnew file mode 100644 index 0000000..88b2b08 --- /dev/null +++ b/buch/chapters/040-rekursion/images/order.pdf diff --git a/buch/chapters/040-rekursion/images/order.tex b/buch/chapters/040-rekursion/images/order.tex new file mode 100644 index 0000000..0284735 --- /dev/null +++ b/buch/chapters/040-rekursion/images/order.tex @@ -0,0 +1,125 @@ +% +% order.tex -- Verteilungsfunktion für Ordnungsstatistik +% +% (c) 2021 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule +% +\documentclass[tikz]{standalone} +\usepackage{amsmath} +\usepackage{times} +\usepackage{txfonts} +\usepackage{pgfplots} +\usepackage{csvsimple} +\usetikzlibrary{arrows,intersections,math} +\begin{document} +\def\skala{8} +\definecolor{darkgreen}{rgb}{0,0.6,0} + +\def\n{10} +\def\E#1#2{ + \draw[color=#2] + ({\dx*#1/(\n+1)},{-0.1/\skala}) -- ({\dx*#1/(\n+1)},{4.4*\dy}); + \node[color=#2] at ({\dx*#1/(\n+1)},{3.2*\dy}) + [rotate=90,above right] {$k=#1$}; +} +\def\var#1#2{ + \pgfmathparse{\dx*sqrt(#1*(\n-#1+1)/((\n+1)*(\n+1)*(\n+2)))} + \xdef\var{\pgfmathresult} + \fill[color=#2,opacity=0.5] + ({\dx*#1/(\n+1)-\var},0) rectangle ({\dx*#1/(\n+1)+\var},{4.4*\dy}); +} + +\input{orderpath.tex} +\begin{tikzpicture}[>=latex,thick,scale=\skala] + +\def\dx{1.6} +\def\dy{0.5} + +\def\pfad#1#2{ +\draw[color=#2,line width=1.4pt] ({-0.1/\skala},0) + -- + #1 + -- + ({1*\dx+0.1/\skala},0.5); +} + +\pfad{\orderzero}{darkgreen!20} +\pfad{\orderone}{darkgreen!20} +\pfad{\ordertwo}{darkgreen!20} +\pfad{\orderthree}{darkgreen!20} +\pfad{\orderfour}{darkgreen!20} +\pfad{\orderfive}{darkgreen!20} +\pfad{\ordersix}{darkgreen!20} +\pfad{\ordereight}{darkgreen!20} +\pfad{\ordernine}{darkgreen!20} +\pfad{\orderten}{darkgreen!20} +\pfad{\orderseven}{darkgreen} + +\draw[->] ({-0.1/\skala},0) -- ({1.03*\dx},0) coordinate[label={$x$}]; +\draw[->] (0,{-0.1/\skala}) -- (0,0.6) coordinate[label={right:$F(X)$}]; +\foreach \x in {0,0.2,0.4,0.6,0.8,1}{ + \draw ({\x*\dx},{-0.1/\skala}) -- ({\x*\dx},{0.1/\skala}); + \node at ({\x*\dx},{-0.1/\skala}) [below] {$\x$}; +} +\foreach \y in {0.5,1}{ + \draw ({-0.1/\skala},{\y*\dy}) -- ({0.1/\skala},{\y*\dy}); + \node at ({-0.1/\skala},{\y*\dy}) [left] {$\y$}; +} + +\node[color=darkgreen] at ({0.64*\dx},{0.56*\dy}) [rotate=42] {$k=7$}; + +\begin{scope}[yshift=-0.7cm] +\def\dy{0.125} + +\foreach \k in {1,2,3,4,5,6,8,9,10}{ + \E{\k}{blue!30} +} +\def\k{7} +\var{\k}{orange!40} +\node[color=blue] at ({\dx*\k/(\n+1)},{4.3*\dy}) [above] {$E(X_{7:n})$}; + +\def\pfad#1#2{ + \draw[color=#2,line width=1.4pt] ({-0.1/\skala},0) + -- + #1 + -- + ({1*\dx+0.1/\skala},0.0); +} + +\begin{scope} +\clip ({-0.1/\skala},{-0.1/\skala}) + rectangle ({1*\dx+0.1/\skala},{0.56+0.1/\skala}); + +\pfad{\orderdzero}{red!20} +\pfad{\orderdone}{red!20} +\pfad{\orderdtwo}{red!20} +\pfad{\orderdthree}{red!20} +\pfad{\orderdfour}{red!20} +\pfad{\orderdfive}{red!20} +\pfad{\orderdsix}{red!20} +\pfad{\orderdeight}{red!20} +\pfad{\orderdnine}{red!20} +\pfad{\orderdten}{red!20} +\E{\k}{blue} +\pfad{\orderdseven}{red} + +\end{scope} + +\draw[->] ({-0.1/\skala},0) -- ({1.03*\dx},0) coordinate[label={$x$}]; +\draw[->] (0,{-0.1/\skala}) -- (0,0.6) coordinate[label={right:$\varphi(X)$}]; +\foreach \x in {0,0.2,0.4,0.6,0.8,1}{ + \draw ({\x*\dx},{-0.1/\skala}) -- ({\x*\dx},{0.1/\skala}); + \node at ({\x*\dx},{-0.1/\skala}) [below] {$\x$}; +} +\foreach \y in {1,2,3,4}{ + \draw ({-0.1/\skala},{\y*\dy}) -- ({0.1/\skala},{\y*\dy}); + \node at ({-0.1/\skala},{\y*\dy}) [left] {$\y$}; +} + +\node[color=red] at ({0.67*\dx},{2.7*\dy}) [above] {$k=7$}; + + +\end{scope} + +\end{tikzpicture} +\end{document} + |