Debian Codegraph @

texmf-dist/doc/generic/pst-func/pst-func-doc.tex

raw
1 \RequirePackage{pdfmanagement-testphase}
2 \DeclareDocumentMetadata{}
3 %% $Id: pst-func-doc.tex 885 2024-03-31 07:25:14Z herbert $
4 \documentclass[fontsize=11pt,english,BCOR=10mm,DIV=12,bibliography=totoc,parskip=false,headings=small,
5 headinclude=false,footinclude=false,oneside]{pst-doc}
6 \usepackage{pst-func}
7 \let\pstFuncFV\fileversion
8 \usepackage{pst-math}
9 \usepackage{pstricks-add}
10 \usepackage{animate}
11 \renewcommand\bgImage{%
12 \psset{yunit=4cm,xunit=3}
13 \begin{pspicture}(-2,-0.2)(2,1.4)
14 \psaxes[Dy=0.25]{->}(0,0)(-2,0)(2,1.25)[$x$,0][$y$,90]
15 \rput[lb](1,0.75){\textcolor{red}{$\sigma =0.5$}}
16 \rput[lb](1,0.5){\textcolor{blue}{$\sigma =1$}}
17 \rput[lb](-2,0.5){$f(x)=\dfrac{1}{\sigma\sqrt{2\pi}}\,e^{-\dfrac{(x-\mu)^2}{2\sigma{}^2}}$}
18 \psGauss[linecolor=red, linewidth=2pt]{-1.75}{1.75}%
19 \psGaussI[linewidth=1pt]{-2}{2}%
20 \psGauss[linecolor=cyan, mue=0.5, linewidth=2pt]{-1.75}{1.75}%
21 \psGauss[sigma=1, linecolor=blue, linewidth=2pt]{-1.75}{1.75}
22 \end{pspicture}%
23 }
24
25 %\usepackage[style=dtk]{biblatex}
26 \addbibresource{pst-func-doc.bib}
27
28
29 \lstset{language=PSTricks,
30 morekeywords={psGammaDist,psChiIIDist,psTDist,psFDist,psBetaDist,psPlotImpl},basicstyle=\footnotesize\ttfamily,
31 literate=%
32 {Ö}{{\"O}}1
33 {Ä}{{\"A}}1
34 {Ü}{{\"U}}1
35 {ß}{{\ss}}1
36 {ü}{{\"u}}1
37 {ä}{{\"a}}1
38 {ö}{{\"o}}1
39 {~}{{\textasciitilde}}1
40 }
41 %
42 \psset{labelFontSize=\scriptstyle}% for mathmode
43 %\def\pshlabel#1{\footnotesize#1}
44 %\def\psvlabel#1{\footnotesize#1}
45 %
46 \begin{document}
47
48 \title{\texttt{pst-func}}
49 \subtitle{Plotting special mathematical functions; v.\pstFuncFV}
50 \author{Herbert Vo\ss}
51 \docauthor{}
52 \date{\today}
53 \settitle
54
55 \tableofcontents
56 \psset{unit=1cm}
57
58
59 \clearpage
60
61 \begin{abstract}
62 \noindent
63 \LPack{pst-func} loads by default the following packages: \LPack{pst-plot},
64 \LPack{pstricks-add}, \LPack{pst-math}, \LPack{pst-xkey}, and, of course \LPack{pstricks}.
65 All should be already part of your local \TeX\ installation. If not, or in case
66 of having older versions, go to \url{http://www.CTAN.org/} and load the newest version.
67
68 \vfill\noindent
69 {\raggedright
70 Thanks to \\
71 Rafal Bartczuk,
72 Jean-C\^ome Charpentier,
73 Martin Chicoine,
74 Gerry Coombes,
75 Denis Girou,
76 John Frampton,
77 Leon Free,
78 Attila Gati,
79 Horst Gierhardt,
80 Jürgen Gilg,
81 Michel Hoppe,
82 Christophe Jorssen,
83 Lars Kotthoff,
84 Marcel Krüger,
85 Buddy Ledger,
86 Pablo Gonzáles Luengo,
87 Manuel Luque,
88 Patrice Mégret,
89 Svend Mortensen,
90 Matthias Rüss,
91 Thomas Söll,
92 Jose-Emilio Vila-Forcen,
93 Timothy Van Zandt,
94 Michael Zedler,
95 and last but not least
96 \url{http://mathworld.wolfram.com}.\par}
97 \end{abstract}
98
99
100
101 \section{\nxLcs{psBezier\#}}
102 This macro can plot a B\'ezier spline from order $1$ up to $9$ which needs
103 (order+$1$) pairs of given coordinates.
104 %
105 Given a set of $n+1$ control points $P_0$, $P_1$, \ldots, $P_n$,
106 the corresponding \Index{B\'ezier} curve (or \Index{Bernstein-B\'ezier} curve) is given by
107 %
108 \begin{align}
109 C(t)=\sum_{i=0}^n P_i B_{i,n}(t)
110 \end{align}
111 %
112 where $B_{i,n}(t)$ is a Bernstein polynomial $B_{i,n}(t)=\binom{n}{i}t^i(1-t)^{n-i}$,
113 and $t \in [0,1]$.
114 The Bézier curve starts through the first and last given point and
115 lies within the convex hull of all control points. The curve is tangent
116 to $P_1-P_0$ and $P_n-P_{n-1}$ at the endpoint.
117 Undesirable properties of \Index{Bézier curve}s are their numerical instability for
118 large numbers of control points, and the fact that moving a single control
119 point changes the global shape of the curve. The former is sometimes avoided
120 by smoothly patching together low-order Bézier curves.
121 %
122 The macro \Lcs{psBezier} (note the upper case B) expects the number of the order
123 and $n=\text{order}+1$ pairs of coordinates:
124
125 \begin{BDef}
126 \Lcs{psBezier}\Larg{\#}\OptArgs\coord0\coord1\coordn
127 \end{BDef}
128
129
130 The number of steps between the first and last control points is given
131 by the keyword \Lkeyword{plotpoints} and preset to $200$. It can be
132 changed in the usual way.
133
134 \begin{lstlisting}
135 \psset{showpoints=true,linewidth=1.5pt}
136 \begin{pspicture}(-2,-2)(2,2)% order 1 -- linear
137 \psBezier1{<->}(-2,0)(-2,2)
138 \end{pspicture}\qquad
139 %
140 \begin{pspicture}(-2,-2)(2,2)% order 2 -- quadratric
141 \psBezier2{<->}(-2,0)(-2,2)(0,2)
142 \end{pspicture}\qquad
143 %
144 \begin{pspicture}(-2,-2)(2,2)% order 3 -- cubic
145 \psBezier3{<->}(-2,0)(-2,2)(0,2)(2,2)
146 \end{pspicture}\qquad
147
148 \vspace{1cm}
149 \begin{pspicture}(-2,-2)(2,2)% order 4 -- quartic
150 \psBezier4{<->}(-2,0)(-2,2)(0,2)(2,2)(2,0)
151 \end{pspicture}\qquad
152 %
153 \begin{pspicture}(-2,-2)(2,2)% order 5 -- quintic
154 \psBezier5{<->}(-2,0)(-2,2)(0,2)(2,2)(2,0)(2,-2)
155 \end{pspicture}\qquad
156 %
157 \begin{pspicture}(-2,-2)(2,2)% order 6
158 \psBezier6{<->}(-2,0)(-2,2)(0,2)(2,2)(2,0)(2,-2)(0,-2)
159 \end{pspicture}\qquad
160
161 \vspace{1cm}
162 \begin{pspicture}(-2,-2)(2,2)% order 7
163 \psBezier7{<->}(-2,0)(-2,2)(0,2)(2,2)(2,0)(2,-2)(0,-2)(-2,-2)
164 \end{pspicture}\qquad
165 %
166 \begin{pspicture}(-2,-2)(2,2)% order 8
167 \psBezier8{<->}(-2,0)(-2,2)(0,2)(2,2)(2,0)(2,-2)(0,-2)(-2,-2)(-2,0)
168 \end{pspicture}\qquad
169 %
170 \begin{pspicture}(-2,-2)(2,2)% order 9
171 \psBezier9{<->}(-2,0)(-2,2)(0,2)(2,2)(2,0)(2,-2)(0,-2)(-2,-2)(-2,0)(0,0)
172 \end{pspicture}
173 \end{lstlisting}
174
175 \begingroup
176 \psset{showpoints=true,linewidth=1.5pt}
177 \begin{pspicture}(-2,-2)(2,2)% order 1 -- linear
178 \psBezier1{<->}(-2,0)(-2,2)
179 \end{pspicture}\qquad
180 %
181 \begin{pspicture}(-2,-2)(2,2)% order 2 -- quadratric
182 \psBezier2{<->}(-2,0)(-2,2)(0,2)
183 \end{pspicture}\qquad
184 %
185 \begin{pspicture}(-2,-2)(2,2)% order 3 -- cubic
186 \psBezier3{<->}(-2,0)(-2,2)(0,2)(2,2)
187 \end{pspicture}\qquad
188
189 \vspace{1cm}
190 \begin{pspicture}(-2,-2)(2,2)% order 4 -- quartic
191 \psBezier4{<->}(-2,0)(-2,2)(0,2)(2,2)(2,0)
192 \end{pspicture}\qquad
193 %
194 \begin{pspicture}(-2,-2)(2,2)% order 5 -- quintic
195 \psBezier5{<->}(-2,0)(-2,2)(0,2)(2,2)(2,0)(2,-2)
196 \end{pspicture}\qquad
197 %
198 \begin{pspicture}(-2,-2)(2,2)% order 6
199 \psBezier6{<->}(-2,0)(-2,2)(0,2)(2,2)(2,0)(2,-2)(0,-2)
200 \end{pspicture}\qquad
201
202 \vspace{1cm}
203 \begin{pspicture}(-2,-2)(2,2)% order 7
204 \psBezier7{<->}(-2,0)(-2,2)(0,2)(2,2)(2,0)(2,-2)(0,-2)(-2,-2)
205 \end{pspicture}\qquad
206 %
207 \begin{pspicture}(-2,-2)(2,2)% order 8
208 \psBezier8{<->}(-2,0)(-2,2)(0,2)(2,2)(2,0)(2,-2)(0,-2)(-2,-2)(-2,0)
209 \end{pspicture}\qquad
210 %
211 \begin{pspicture}(-2,-2)(2,2)% order 9
212 \psBezier9{<->}(-2,0)(-2,2)(0,2)(2,2)(2,0)(2,-2)(0,-2)(-2,-2)(-2,0)(0,0)
213 \end{pspicture}
214 \endgroup
215
216 \clearpage
217 \section{Polynomials}
218
219 \subsection{Chebyshev polynomials}
220 The polynomials of the first (\Lps{ChebyshevT}) kind are defined through the identity
221
222 \[ T_n(\cos\theta)=\cos(n\theta)\]
223
224 They can be obtained from the generating functions
225 \begin{align}
226 g_1(t,x) &= \frac{1-t^2}{1-2xt+t^2}\\
227 &= T_0(x)+2\sum_{n=1}^\infty T_n(x)t^n
228 \end{align}
229
230 and
231
232 \begin{align}
233 g_2(t,x) &= \frac{1-xt}{1-2xt+t^2}\\
234 &= \sum_{n=0}^\infty T_n(x)t^n
235 \end{align}
236
237 The polynomials of second kind (\Lps{ChebyshevU}) can be generated by
238
239 \begin{align}
240 g(t,x) &= \frac{1}{1-2xt+t^2}\\
241 &= \sum_{n=0}^\infty U_n(x)t^n
242 \end{align}
243
244 \LPack{pst-func} defines the \TeX-macros \Lcs{ChebyshevT} for the first kind
245 and \Lcs{ChebyshevU} for the second kind of \Index{Chebyshev polynomials}.
246 These \TeX-macros cannot be used outside of PostScript, they are only wrappers
247 for \verb+tx@FuncDict begin ChebyshevT end+ and the same for \Lcs{ChebyshevU}.
248
249 \begin{center}
250 \bgroup
251 \psset{arrowscale=1.5,unit=3cm}
252 \begin{pspicture}(-1.5,-1.5)(1.5,1.5)
253 \psaxes[ticks=none,labels=none]{->}(0,0)(-1.25,-1.25)(1.25,1.25)%
254 [Re$\{s_{21}\}$,0][Im$\{s_{21}\}$,90]
255 \pscircle(0,0){1}
256 \parametricplot[linecolor=blue,plotpoints=10000]{0}{1.5}{
257 /N 9 def
258 /x 2 N mul t \ChebyshevT def
259 /y 2 N mul 1 sub t \ChebyshevU def
260 x x 2 exp y 2 exp add div
261 y x 2 exp y 2 exp add div
262 }
263 \end{pspicture}
264 \egroup
265 \end{center}
266
267 \begin{lstlisting}
268 \psset{arrowscale=1.5,unit=3cm}
269 \begin{pspicture}(-1.5,-1.5)(1.5,1.5)
270 \psaxes[ticks=none,labels=none]{->}(0,0)(-1.25,-1.25)(1.25,1.25)%
271 [Re$\{s_{21}\}$,0][Im$\{s_{21}\}$,90]
272 \pscircle(0,0){1}
273 \parametricplot[linecolor=blue,plotpoints=10000]{0}{1.5}{
274 /N 9 def
275 /x 2 N mul t \ChebyshevT def
276 /y 2 N mul 1 sub t \ChebyshevU def
277 x x 2 exp y 2 exp add div
278 y x 2 exp y 2 exp add div
279 }
280 \end{pspicture}
281 \end{lstlisting}
282
283 \begin{center}
284 \bgroup
285 \psset{xunit=4cm,yunit=3cm,plotpoints=1000}
286 \begin{pspicture}(-1.2,-2)(2,1.5)
287 \psaxes[Dx=0.2]{->}(0,0)(-1.25,-1.2)(1.25,1.2)
288 \psset{linewidth=1.5pt}
289 \psplot[linestyle=dashed]{-1}{1}{1 x \ChebyshevT}
290 \psplot[linecolor=black]{-1}{1}{2 x \ChebyshevT}
291 \psplot[linecolor=black]{-1}{1}{3 x \ChebyshevT}
292 \psplot[linecolor=blue]{-1}{1}{4 x \ChebyshevT }
293 \psplot[linecolor=red]{-1}{1}{5 x \ChebyshevT }
294 \end{pspicture}
295 \egroup
296 \end{center}
297
298 \begin{lstlisting}
299 \psset{xunit=4cm,yunit=3cm,plotpoints=1000}
300 \begin{pspicture}(-1.2,-2)(2,1.5)
301 \psaxes[Dx=0.2]{->}(0,0)(-1.25,-1.2)(1.25,1.2)
302 \psset{linewidth=1.5pt}
303 \psplot[linestyle=dashed]{-1}{1}{1 x \ChebyshevT}
304 \psplot[linecolor=black]{-1}{1}{2 x \ChebyshevT}
305 \psplot[linecolor=black]{-1}{1}{3 x \ChebyshevT}
306 \psplot[linecolor=blue]{-1}{1}{4 x \ChebyshevT }
307 \psplot[linecolor=red]{-1}{1}{5 x \ChebyshevT }
308 \end{pspicture}
309 \end{lstlisting}
310
311 \begin{center}
312 \bgroup
313 \psset{xunit=4cm,yunit=3cm,plotpoints=1000}
314 \begin{pspicture*}(-1.5,-1.5)(1.5,1.5)
315 \psaxes[Dx=0.2]{->}(0,0)(-1.15,-1.1)(1.15,1.1)
316 \psset{linewidth=1.5pt}
317 \psplot[linecolor=black]{-1}{1}{2 x \ChebyshevU}
318 \psplot[linecolor=black]{-1}{1}{3 x \ChebyshevU}
319 \psplot[linecolor=blue]{-1}{1}{4 x \ChebyshevU }
320 \psplot[linecolor=red]{-1}{1}{5 x \ChebyshevU }
321 \end{pspicture*}
322 \egroup
323 \end{center}
324
325 \begin{lstlisting}
326 \psset{xunit=4cm,yunit=3cm,plotpoints=1000}
327 \begin{pspicture*}(-1.5,-1.5)(1.5,1.5)
328 \psaxes[Dx=0.2]{->}(0,0)(-1.15,-1.1)(1.15,1.1)
329 \psaxes[Dx=0.2]{->}(0,0)(-1.25,-1.2)(1.25,1.2)
330 \psset{linewidth=1.5pt}
331 \psplot[linecolor=black]{-1}{1}{2 x \ChebyshevU}
332 \psplot[linecolor=black]{-1}{1}{3 x \ChebyshevU}
333 \psplot[linecolor=blue]{-1}{1}{4 x \ChebyshevU}
334 \psplot[linecolor=red]{-1}{1}{5 x \ChebyshevU}
335 \end{pspicture*}
336 \end{lstlisting}
337
338 \begin{center}
339 \bgroup
340 \psset{xunit=4cm,yunit=3cm,plotpoints=1000}
341 \begin{pspicture}(-1.25,-1.2)(1.25,1.2)
342 \psaxes[Dx=0.2]{->}(0,0)(-1.25,-1.1)(1.25,1.1)
343 \psset{linewidth=1.5pt}
344 \psplot[linecolor=black]{-1}{1}{x ACOS 2 mul RadtoDeg cos}
345 \psplot[linecolor=black]{-1}{1}{x ACOS 3 mul RadtoDeg cos}
346 \psplot[linecolor=blue]{-1}{1}{x ACOS 4 mul RadtoDeg cos}
347 \psplot[linecolor=red]{-1}{1}{x ACOS 5 mul RadtoDeg cos}
348 \end{pspicture}
349 \egroup
350 \end{center}
351
352 \begin{lstlisting}
353 \psset{xunit=4cm,yunit=3cm,plotpoints=1000}
354 \begin{pspicture}(-1.25,-1.2)(1.25,1.2)
355 \psaxes[Dx=0.2]{->}(0,0)(-1.25,-1.2)(1.25,1.2)
356 \psset{linewidth=1.5pt}
357 \psplot[linecolor=black]{-1}{1}{x ACOS 2 mul RadtoDeg cos}
358 \psplot[linecolor=black]{-1}{1}{x ACOS 3 mul RadtoDeg cos}
359 \psplot[linecolor=blue]{-1}{1}{x ACOS 4 mul RadtoDeg cos}
360 \psplot[linecolor=red]{-1}{1}{x ACOS 5 mul RadtoDeg cos}
361 \end{pspicture}
362 \end{lstlisting}
363
364 \subsection{\Lcs{psPolynomial}}
365 The polynomial function is defined as
366 %
367 \begin{align}
368 f(x) &= a_0 + a_1x + a_2x^2 + a_3x^3 + \ldots +a_{n-1}x^{n-1} + a_nx^n\\
369 f^{\prime}(x) &= a_1 + 2a_2x + 3a_3x^2 + \ldots +(n-1)a_{n-1}x^{n-2} + na_nx^{n-1}\\
370 f^{\prime\prime}(x) &= 2a_2 + 6a_3x + \ldots +(n-1)(n-2)a_{n-1}x^{n-3} + n(n-1)a_nx^{n-2}
371 \end{align}
372
373 \noindent so \LPack{pst-func} needs only the \Index{coefficients}
374 of the polynomial to calculate the function. The syntax is
375
376 \begin{BDef}
377 \Lcs{psPolynomial}\OptArgs\Largb{xStart}\Largb{xEnd}
378 \end{BDef}
379
380 With the option \Lkeyword{xShift} one can do a horizontal shift to the graph of the function.
381 With another than the predefined value the macro replaces $x$ by $x-x\mathrm{Shift}$;
382 \Lkeyword{xShift}=1 moves the graph of the \Index{polynomial function} one unit to the right.
383
384 \begin{center}
385 \bgroup
386 \psset{yunit=0.5cm,xunit=1cm}
387 \begin{pspicture*}(-3,-5)(5,10)
388 \psaxes[Dy=2]{->}(0,0)(-3,-5)(5,10)
389 \psset{linewidth=1.5pt}
390 \psPolynomial[coeff=6 3 -1,linecolor=red]{-3}{5}
391 \psPolynomial[coeff=2 -1 -1 .5 -.1 .025,linecolor=blue]{-2}{4}
392 \psPolynomial[coeff=-2 1 -1 .5 .1 .025 .2 ,linecolor=magenta]{-2}{4}
393 \psPolynomial[coeff=-2 1 -1 .5 .1 .025 .2 ,linecolor=magenta,xShift=1,linestyle=dashed]{-2}{4}
394 \rput[lb](4,4){\textcolor{red}{$f(x)$}}
395 \rput[lb](4,8){\textcolor{blue}{$g(x)$}}
396 \rput[lb](2,4){\textcolor{magenta}{$h(x)$}}
397 \end{pspicture*}
398 \egroup
399 \end{center}
400
401 \begin{lstlisting}
402 \psset{yunit=0.5cm,xunit=1cm}
403 \begin{pspicture*}(-3,-5)(5,10)
404 \psaxes[Dy=2]{->}(0,0)(-3,-5)(5,10)
405 \psset{linewidth=1.5pt}
406 \psPolynomial[coeff=6 3 -1,linecolor=red]{-3}{5}
407 \psPolynomial[coeff=2 -1 -1 .5 -.1 .025,linecolor=blue]{-2}{4}
408 \psPolynomial[coeff=-2 1 -1 .5 .1 .025 .2 ,linecolor=magenta]{-2}{4}
409 \psPolynomial[coeff=-2 1 -1 .5 .1 .025 .2 ,linecolor=magenta,xShift=1,linestyle=dashed]{-2}{4}
410 \rput[lb](4,4){\textcolor{red}{$f(x)$}}
411 \rput[lb](4,8){\textcolor{blue}{$g(x)$}}
412 \rput[lb](2,4){\textcolor{magenta}{$h(x)$}}
413 \end{pspicture*}
414 \end{lstlisting}
415
416 The plot is easily clipped using the star version of the
417 \Lenv{pspicture} environment, so that points whose coordinates
418 are outside of the desired range are not plotted.
419 The plotted polynomials are:
420 %
421 \begin{align}
422 f(x) & = 6 + 3x -x^2 \\
423 g(x) & = 2 -x -x^2 +0.5x^3 -0.1x^4 +0.025x^5\\
424 h(x) & = -2 +x -x^2 +0.5x^3 +0.1x^4 +0.025x^5+0.2x^6\\
425 h^*(x) & = -2 +(x-1) -(x-1)^2 +0.5(x-1)^3 +\nonumber\\
426 & \phantom{ = }+0.1(x-1)^4 +0.025(x-1)^5+0.2(x-1)^6
427 \end{align}
428 %
429 There are the following new options:
430
431 \noindent\medskip
432 {\tabcolsep=2pt
433 \begin{tabularx}{\linewidth}{@{}l>{\ttfamily}l>{\ttfamily}lX@{}}
434 Name & \textrm{Value} & \textrm{Default}\\\hline
435 \Lkeyword{coeff} & a0 a1 a2 ... & 0 0 1 & The coefficients must have the order $a_0\ a_1\ a_2 \ldots$ and
436 be separated by \textbf{spaces}. The number of coefficients
437 is limited only by the memory of the computer ... The default
438 value of the parameter \Lkeyword{coeff} is \verb+0 0 1+, which gives
439 the parabola $y=a_0+a_1x+a_2x^2=x^2$.\\
440 \Lkeyword{xShift} & <number> & 0 & $(x-xShift)$ for the horizontal shift of the polynomial\\
441 \Lkeyword{Derivation} & <number> & 0 & the default is the function itself\\
442 \Lkeyword{markZeros} & false|true & false & dotstyle can be changed\\
443 \Lkeyword{epsZero} & <value> & 0.1 & The distance between two zeros, important for
444 the iteration function to test, if the zero value still
445 exists\\
446 \Lkeyword{dZero} & <value> & 0.1 & When searching for all zero values, the function is scanned
447 with this step\\
448 \Lkeyword{zeroLineTo} & <number> & false & plots a line from the zero point to the value of the
449 zeroLineTo's Derivation of the polynomial function\\
450 \Lkeyword{zeroLineStyle} & <line style> & \Lkeyval{dashed} & the style is one of the for \PST valid styles.\\
451 \Lkeyword{zeroLineColor} & <color> & \Lkeyval{black} & any valid xolor is possible\\
452 \Lkeyword{zeroLineWidth} & <width> & \rlap{0.5\textbackslash pslinewidth} & \\
453 \end{tabularx}
454 }
455
456 \bigskip
457 The above parameters are only
458 valid for the \Lcs{psPolynomial} macro, except \verb+x0+, which can also be used for the Gauss function. All
459 options can be set in the usual way with \Lcs{psset}.
460
461 \bigskip
462 \begin{LTXexample}
463 \psset{yunit=0.5cm,xunit=2cm}
464 \begin{pspicture*}(-3,-5)(3,10)
465 \psaxes[Dy=2]{->}(0,0)(-3,-5)(3,10)
466 \psset{linewidth=1.5pt}
467 \psPolynomial[coeff=-2 1 -1 .5 .1 .025 .2 ,linecolor=magenta]{-2}{4}
468 \psPolynomial[coeff=-2 1 -1 .5 .1 .025 .2 ,linecolor=red,%
469 linestyle=dashed,Derivation=1]{-2}{4}
470 \psPolynomial[coeff=-2 1 -1 .5 .1 .025 .2 ,linecolor=blue,%
471 linestyle=dotted,Derivation=2]{-2}{4}
472 \rput[lb](2,4){\textcolor{magenta}{$h(x)$}}
473 \rput[lb](1,1){\textcolor{red}{$h^{\prime}(x)$}}
474 \rput[lb](-1,6){\textcolor{blue}{$h^{\prime\prime}(x)$}}
475 \end{pspicture*}
476 \end{LTXexample}
477 %$
478 \begin{LTXexample}
479 \psset{yunit=0.5cm,xunit=2cm}
480 \begin{pspicture*}(-3,-5)(3,10)
481 \psaxes[Dy=2]{->}(0,0)(-3,-5)(3,10)
482 \psset{linewidth=1.5pt}
483 \psPolynomial[coeff=0 0 0 1,linecolor=blue]{-2}{4}
484 \psPolynomial[coeff=0 0 0 1,linecolor=red,%
485 linestyle=dashed,Derivation=2]{-2}{4}
486 \psPolynomial[coeff=0 0 0 1,linecolor=cyan,%
487 linestyle=dotted,Derivation=3]{-2}{4}
488 \rput[lb](1.8,4){\textcolor{blue}{$f(x)=x^3$}}
489 \rput[lb](0.2,8){\textcolor{red}{$f^{\prime\prime}(x)=6x$}}
490 \rput[lb](-2,5){\textcolor{cyan}{$f^{\prime\prime\prime}(x)=6$}}
491 \end{pspicture*}
492 \end{LTXexample}
493 %$
494 \begin{LTXexample}
495 \begin{pspicture*}(-5,-5)(5,5)
496 \psaxes{->}(0,0)(-5,-5)(5,5)%
497 \psset{dotscale=2}
498 \psPolynomial[markZeros,linecolor=red,linewidth=2pt,coeff=-1 1 -1 0 0.15]{-4}{3}%
499 \psPolynomial[markZeros,linecolor=blue,linewidth=1pt,linestyle=dashed,%
500 coeff=-1 1 -1 0 0.15,Derivation=1,zeroLineTo=0]{-4}{3}%
501 \psPolynomial[markZeros,linecolor=magenta,linewidth=1pt,linestyle=dotted,%
502 coeff=-1 1 -1 0 0.15,Derivation=2,zeroLineTo=0]{-4}{3}%
503 \psPolynomial[markZeros,linecolor=magenta,linewidth=1pt,linestyle=dotted,%
504 coeff=-1 1 -1 0 0.15,Derivation=2,zeroLineTo=1]{-4}{3}%
505 \end{pspicture*}
506 \end{LTXexample}
507
508 \begin{LTXexample}
509 \psset{xunit=1.5}
510 \begin{pspicture*}(-5,-5)(5,5)
511 \psaxes{->}(0,0)(-5,-5)(5,5)%
512 \psset{dotscale=2,dotstyle=x,zeroLineStyle=dotted,zeroLineWidth=1pt}
513 \psPolynomial[markZeros,linecolor=red,linewidth=2pt,coeff=-1 1 -1 0 0.15]{-4}{3}%
514 \psPolynomial[markZeros,linecolor=blue,linewidth=1pt,linestyle=dashed,%
515 coeff=-1 1 -1 0 0.15,Derivation=1,zeroLineTo=0]{-4}{3}%
516 \psPolynomial[markZeros,linecolor=magenta,linewidth=1pt,linestyle=dotted,%
517 coeff=-1 1 -1 0 0.15,Derivation=2,zeroLineTo=0]{-4}{3}%
518 \psPolynomial[markZeros,linecolor=magenta,linewidth=1pt,linestyle=dotted,%
519 coeff=-1 1 -1 0 0.15,Derivation=2,zeroLineTo=1]{-4}{3}%
520 \end{pspicture*}
521 \end{LTXexample}
522
523
524 \clearpage
525 \subsection{\Lcs{psBernstein}}
526 The polynomials defined by
527 %
528 \[ B_{i,n}(t)=\binom{n}{i}t^i(1-t)^{n-i} \]
529 %
530 where $\tbinom{n}{k}$ is a binomial coefficient are named Bernstein polynomials of degree $n$.
531 They form a basis for the power polynomials of degree $n$.
532 The Bernstein polynomials satisfy symmetry
533 \[B_{i,n}(t)=B_{n-i,n}(1-t)\]
534 positivity \[B_{i,n}(t)\ge0 \mbox{\qquad for } 0\le t\le1\]
535 normalization \[\sum_{i=0}^nB_{i,n}(t)=1\]
536 and $B_{i,n}$ with $i!=0$, $n$ has a single unique local maximum of
537 \[i^in^{-n}(n-i)^{n-i}\binom{n}{i}\]
538 occurring at $t=\frac{i}{n}$.
539 The envelope $f_n(x)$ of the Bernstein polynomials $B_{i,n}(x)$ for $i=0,1,\ldots,n$
540 is given by \[f_n(x)=\frac{1}{\sqrt{\pi n\cdot x(1-x)}}\]
541 illustrated below for $n=20$.
542
543 \begin{BDef}
544 \Lcs{psBernstein}\OptArgs\Largr{tStart,tEnd}\Largr{i,n}
545 \end{BDef}
546
547 The (\Lkeyword{tStart}, \Lkeyword{tEnd}) are \emph{optional} and preset by \verb=(0,1)=.
548 The only new optional argument is the boolean key \Lkeyword{envelope},
549 which plots the envelope curve instead of the Bernstein polynomial.
550
551 \begin{LTXexample}[width=5cm,pos=l]
552 \psset{xunit=4.5cm,yunit=3cm}
553 \begin{pspicture}(1,1.1)
554 \psaxes{->}(0,0)(1,1)[$t$,0][$B_{0,0}$,90]
555 \psBernstein[linecolor=red,linewidth=1pt](0,0)
556 \end{pspicture}
557 \end{LTXexample}
558
559 \begin{LTXexample}[width=5cm,pos=l]
560 \psset{xunit=4.5cm,yunit=3cm}
561 \begin{pspicture}(1,1.1)
562 \psaxes{->}(0,0)(1,1)[$t$,0][$B_{i,1}$,90]
563 \psBernstein[linecolor=blue,linewidth=1pt](0,1)
564 \psBernstein[linecolor=blue,linewidth=1pt](1,1)
565 \end{pspicture}
566 \end{LTXexample}
567
568 \begin{LTXexample}[width=5cm,pos=l]
569 \psset{xunit=4.5cm,yunit=3cm}
570 \begin{pspicture}(1,1.1)
571 \psaxes{->}(0,0)(1,1)[$t$,0][$B_{i,2}$,90]
572 \multido{\i=0+1}{3}{\psBernstein[linecolor=red,
573 linewidth=1pt](\i,2)}
574 \end{pspicture}
575 \end{LTXexample}
576
577 \begin{LTXexample}[width=5cm,pos=l]
578 \psset{xunit=4.5cm,yunit=3cm}
579 \begin{pspicture}(1,1.1)
580 \psaxes{->}(0,0)(1,1)[$t$,0][$B_{i,3}$,90]
581 \multido{\i=0+1}{4}{\psBernstein[linecolor=magenta,
582 linewidth=1pt](\i,3)}
583 \end{pspicture}
584 \end{LTXexample}
585
586 \begin{LTXexample}[width=5cm,pos=l]
587 \psset{xunit=4.5cm,yunit=3cm}
588 \begin{pspicture}(1,1.1)
589 \psaxes{->}(0,0)(1,1)[$t$,0][$B_{i,4}$,90]
590 \multido{\i=0+1}{5}{\psBernstein[linecolor=cyan,
591 linewidth=1pt](\i,4)}
592 \end{pspicture}
593 \end{LTXexample}
594
595 \begin{LTXexample}[width=5cm,pos=l]
596 \psset{xunit=4.5cm,yunit=3cm}
597 \begin{pspicture}(-0.1,-0.05)(1.1,1.1)
598 \multido{\i=0+1}{20}{\psBernstein[linecolor=green,
599 linewidth=1pt](\i,20)}
600 \psBernstein[envelope,linecolor=black](0.02,0.98)(0,20)
601 \psaxes{->}(0,0)(1,1)[$t$,0][$B_{i,20}$,180]
602 \end{pspicture}
603 \end{LTXexample}
604
605 \begin{LTXexample}[width=5cm,pos=l]
606 \psset{xunit=4.5cm,yunit=3cm}
607 \begin{pspicture*}(-0.2,-0.05)(1.1,1.1)
608 \psaxes{->}(0,0)(1,1)[$t$,0][$B_{env}$,180]
609 \multido{\i=2+1}{20}{\psBernstein[envelope,
610 linewidth=1pt](0.01,0.99)(0,\i)}
611 \end{pspicture*}
612 \end{LTXexample}
613
614
615 \clearpage
616
617
618 \subsection{\Lcs{psLaguerre} -- Laguerre Polynomial}
619 It is defined as
620 \[
621 L_n(x)=\sum_{k=0}^n\frac{(-1)^k}{k!}\binom{n}{k}x^k
622 \]
623
624 \begin{LTXexample}
625 \psset{xunit=1.5}
626 \begin{pspicture}(-1,-4)(6,6)
627 \psaxes{->}(0,0)(-1,-4)(5,6)
628 \psset{yMaxValue=5,plotpoints=100,linewidth=1pt}
629 \psLaguerre[n=0,linecolor=red](-1,5)\uput[0](5,1){$L_0$}
630 \psLaguerre[n=1,linecolor=green](-1,5)\uput[0](4,-2.5){$L_1$}
631 \psLaguerre[n=2,linecolor=blue](-1,5)\uput[0](4.5,2){$L_2$}
632 \psLaguerre[n=3,linecolor=yellow](-1,5)\uput[0](5,2.5){$L_3$}
633 \psLaguerre[n=4,linecolor=brown](-1,5)\uput[0](5,-1){$L_4$}
634 \end{pspicture}
635 \end{LTXexample}
636
637
638 \psset{unit=1cm}
639
640 \clearpage
641
642
643 \subsection{\Lcs{psLegendre} -- Legendre Polynomial}
644 It is defined by the contour integral:
645 \[
646 P_n(x)=\frac1{2\pi} \oint(1-2tx+t^2)^{-1/2}t^{-n-1}\mathrm dt
647 %\int\limits_{-1}^{+1}P_m(x)(P_n(x)\mathrm dx=0, \text{ with } n\ne m
648 \]
649
650 For the computatíon we use a recursive definition:
651
652 \begin{align*}
653 P_0(x) &= 1\\
654 P_{1}(x) &= x\\
655 n\cdot P_{n}(x) &= (2n-1)x\cdot P_{n-1}(x)-(n-1)P_{n-2}(x)
656 \end{align*}
657
658
659 \begin{LTXexample}
660 \psset{xunit=3,yunit=2}
661 \begin{pspicture}[showgrid](-2,-2)(2,2)
662 \psaxes[labels=none]{->}(0,0)(-2,-2)(2,2)
663 \psset{yMaxValue=1.9,yMinValue=-2,plotpoints=200,linewidth=1.5pt}
664 \psLegendre[n=0,linecolor=red](-2,2)\uput[0](2,1){\textcolor{red}{$L_0$}}
665 \psLegendre[n=1,linecolor=green](-2,2)\uput[0](2,2){\textcolor{green}{$L_1$}}
666 \psLegendre[n=2,linecolor=blue](-2,2)\uput[0](1.3,1.8){\textcolor{blue}{$L_2$}}
667 \psLegendre[n=3,linecolor=yellow](-2,2)\uput*[0](-1,-1.8){\textcolor{yellow}{$L_3$}}
668 \psLegendre[n=4,linecolor=brown](-2,2)\uput*[0](-1,2){\textcolor{brown}{$L_4$}}
669 \end{pspicture}
670 \end{LTXexample}
671
672
673 \psset{unit=1cm}
674
675
676
677
678 \clearpage
679 \section{Calculating the zeros of a function or the the intermediate point of two function}
680
681 \begin{BDef}
682 \Lcs{psZero}\OptArgs\Largr{$x_0,x_1$}\Largb{functionA}\OptArg{functionB}\Largb{node name}
683 \end{BDef}
684
685 If the second function is not given the macro calculates and displays the zeros of
686 the first function. If the second function is defined too, then the macro calculates the
687 intermediate point of the two functions. The intervall is defined as $[x_0,x_1]$.
688 Possible optional arguments are
689
690
691 \medskip
692 \begin{tabularx}{\linewidth}{ @{} l >{\ttfamily}l X @{} }\toprule
693 \emph{Name} & \emph{Default} & \emph{Meaning} \\\midrule
694 \Lkeyword{markZeros} & false & Mark the zeros/intermediate points with a symbol.\\
695 \Lkeyword{Newton} & false & Use Newton method instead of the bisector one.\\
696 \Lkeyword{PrintCoord} & false & Print the pair of coordinates of the zero/intermediate point, like $P(x|y)$.\\
697 \Lkeyword{onlyNode} & false & Calculate only the node, do not print anything, if markZeros $=$ false.\\
698 \Lkeyword{onlyYVal} & false & Print only the $y$-value.\\
699 \Lkeyword{xory} & false & Print $x=$ $x$-Value or, if onlyYVal $=$ true, $y=$ $y$-value.\\
700 \Lkeyword{approx} & true & Change the $=$, if xory $=$ true to $\approx$.\\
701 \Lkeyword{originV} & false & Put the values without an offset.\\
702 \Lkeyword{Framed} & false & Show a filled frame in backround, framesep, fillcolor, opacity or
703 linestyle are options to show different frames.\\
704 \Lkeyword{PointName} & I & The printed prefix for the calculated Points.\\
705 \Lkeyword{decimals} & 2 & The decimals for the $x$ value.\\
706 \Lkeyword{ydecimals} & 2 & The decimals for the $y$ value.\\
707 \Lkeyword{xShift} & 0 & $x$ move for the printed value.\\
708 \Lkeyword{yShift} & 0 & $y$ move for the printed value.\\
709 \bottomrule
710 \end{tabularx}
711
712 \medskip
713 The following examples where done by Jürgen Gilg and Thomas Söll.
714
715 \bigskip
716 \definecolor{BeigeTS}{rgb}{0.98,0.95,0.87}
717 \definecolor{CornBlauTS}{rgb}{0.39,0.59,0.93}
718 \definecolor{SandBraun}{rgb}{0.96,0.64,0.38}
719 \psset{yunit=1.25cm,arrowinset=0.02,arrowlength=2,linewidth=0.5pt,saveNodeCoors,NodeCoorPrefix=n,comma}
720 \def\funkf{2*sqrt(x)*cos(ln(x))*sin(x)}
721 \begin{pspicture}[plotpoints=500,algebraic,fontscale=5,markZeros,
722 PointName=N,dotscale=0.7](-0.5,-3)(10,2.5)
723 \psStep[fillstyle=solid,fillcolor=BeigeTS,opacity=0.7,linewidth=0.3pt,
724 linecolor=SandBraun!50](0.001,9.5){40}{\funkf}
725 \psStep[StepType=Riemann,fillstyle=solid,opacity=0.3,fillcolor=CornBlauTS,
726 linecolor=CornBlauTS,linewidth=0.3pt](0.001,9.5){40}{\funkf}
727 \psaxes[labelFontSize=\scriptstyle,ticksize=-0.1 0]{->}(0,0)(0,-2.75)(10,2.5)
728 \psplot[linecolor=BeigeTS!60,linewidth=0.8pt]{0.001}{9.75}{\funkf}
729 \psplotTangent[linecolor=blue,Derive={Derive(1,\funkf)}]{1.29}{1.5}{\funkf}
730 \uput[90](6,1.2){$f(x)=2\cdot\sqrt{x}\cdot\cos{(\ln{x})}\cdot\sin{x}$}
731 {\psset{dotscale=1.5,linecolor=blue!50!black!90,ydecimals=0,Framed,opacity=0.8,decimals=1,PrintCoord}
732 \psZero[xShift=-0.2,yShift=0.15,postString=1,Newton](0.5,1){\funkf}{N1}
733 \psZero[xShift=-0.05,yShift=0.15,postString=2](2,4){\funkf}{N2}
734 \psZero[xShift=-0.45,yShift=0.15,postString=3](4,6){\funkf}{N3}
735 \psZero[xShift=-0.45,yShift=0.15,postString=4](6,7){\funkf}{N4}
736 \psZero[xShift=-0.25,yShift=0.15,PointName=x,postString=5,xory,PrintCoord=false,linestyle=none,fillcolor=green,opacity=0.6](9,11){\funkf}{N5}
737 \psZero[xShift=-0.95,yShift=0,PointName=M,decimals=0,linestyle=none,fillcolor=SandBraun,
738 ydecimals=1,opacity=0.8,postString={m=1}](0.5,2){Derive(1,\funkf)-1+\funkf}[\funkf]{M}%
739 }
740 \pcline{->}(0.5,-1)(M)
741 \nbput[nrot=:U,labelsep=0.3,npos=0.2]{%
742 \scriptsize \psZero[originV=true,xory=true,onlyYVal=true,PointName=f(x),postString={m=1},Framed,
743 opacity=0.8,linestyle=none,markZeros=false,fontscale=10](0.5,2){Derive(1,\funkf)-1+\funkf}[\funkf]{R}}
744 \psdot[linecolor=green,strokeopacity=0.8](M)
745 \uput{0.5}[40](M){\psZero[originV=true,approx=false,xory=true,onlyYVal=true,
746 PointName=m,postString={m=1},markZeros=false,fontscale=8](0.5,2){Derive(1,\funkf)-1}[1]{R}}
747 \end{pspicture}
748
749
750 %\begin{LTXexample}[pos=t]
751 \begin{lstlisting}
752 \definecolor{BeigeTS}{rgb}{0.98,0.95,0.87}
753 \definecolor{CornBlauTS}{rgb}{0.39,0.59,0.93}
754 \definecolor{SandBraun}{rgb}{0.96,0.64,0.38}
755 \psset{yunit=1.25cm,arrowinset=0.02,arrowlength=2,linewidth=0.5pt,saveNodeCoors,NodeCoorPrefix=n,comma}
756 \def\funkf{2*sqrt(x)*cos(ln(x))*sin(x)}
757 \begin{pspicture}[plotpoints=500,algebraic,fontscale=5,markZeros,PrintCoord,
758 PointName=N,dotscale=0.7](-0.5,-3)(10,2.5)
759 \psStep[fillstyle=solid,fillcolor=BeigeTS,opacity=0.7,linewidth=0.3pt,
760 linecolor=SandBraun!50](0.001,9.5){40}{\funkf}
761 \psStep[StepType=Riemann,fillstyle=solid,opacity=0.3,fillcolor=CornBlauTS,
762 linecolor=CornBlauTS,linewidth=0.3pt](0.001,9.5){40}{\funkf}
763 \psaxes[labelFontSize=\scriptstyle,ticksize=-0.1 0]{->}(0,0)(0,-2.75)(10,2.5)
764 \psplot[linecolor=BeigeTS!60,linewidth=0.8pt]{0.001}{9.75}{\funkf}
765 \psplotTangent[linecolor=blue,Derive={Derive(1,\funkf)}]{1.29}{1.5}{\funkf}
766 \uput[90](6,1.2){$f(x)=2\cdot\sqrt{x}\cdot\cos{(\ln{x})}\cdot\sin{x}$}
767 {\psset{dotscale=1.5,linecolor=blue!50!black!90,ydecimals=0,Framed,opacity=0.8,decimals=1}
768 \psZero[xShift=-0.2,yShift=0.15,postString=1,Newton](0.5,1){\funkf}{N1}
769 \psZero[xShift=-0.05,yShift=0.15,postString=2](2,4){\funkf}{N2}
770 \psZero[xShift=-0.45,yShift=0.15,postString=3](4,6){\funkf}{N3}
771 \psZero[xShift=-0.45,yShift=0.15,postString=4](6,7){\funkf}{N4}
772 \psZero[xShift=-0.45,yShift=0.15,postString=5](9,11){\funkf}{N5}
773 \psZero[xShift=-1.15,yShift=0,PointName=M,decimals=0,linestyle=none,fillcolor=SandBraun,
774 opacity=0.8,postString={m=1}](0.5,2){Derive(1,\funkf)-1+\funkf}[\funkf]{M}%
775 }
776 \pcline{->}(0.5,-1)(M)
777 \nbput[nrot=:U,labelsep=0.01]{%
778 \scriptsize Steigung ist hier\phantom{i}
779 \psPrintValueNew[PSfont=Palatino-Roman,decimals=0,round,fontscale=7]{nMx,{Derive(1,\funkf)}}}
780 \psdot[linecolor=green,strokeopacity=0.8](*{nMx} {\funkf})
781 \uput[90](*{nMx} {\funkf}){$m=$
782 \psPrintValueNew[PSfont=Palatino-Roman,decimals=0,round,fontscale=8]{nMx,{Derive(1,\funkf)}}}
783 \end{pspicture}
784 \end{lstlisting}
785 %\end{LTXexample}
786
787 {\psset{yunit=0.8,comma,decimals=2,algebraic=true,markZeros=true,plotpoints=500,saveNodeCoors,NodeCoorPrefix=n}
788 %----------------- FUNKTIONSDEFINITIONEN in "algebraic" -----------------
789 \def\funkf{0.75*x^4-3*x^2-2}
790 \def\funkg{0.25*x+1}
791
792 \begin{pspicture}(-6.5,-5.5)(6.5,8.5)
793 %------ Gitter im Hintergrund (CLIPPED) -----------------
794 \begin{psclip}%
795 {\psframe[linestyle=none](-6.4,-5.4)(6.4,7.4)}
796 \psgrid[subgriddiv=2,gridlabels=0,gridwidth=0.3pt,gridcolor=black!50,subgridwidth=0.2pt,subgridcolor=black!30](-6.5,-7.5)(6.5,8.5)
797 \end{psclip}
798 %--------- Achsen ------------
799 \psaxes[xDecimals=0, yDecimals=0,labelFontSize=\scriptstyle,arrowscale=1.3,arrowinset=0.05,arrowlength=1.9, Dy=1,dy=1,dx=1,Dx=1,subticks=0,comma,tickwidth=0.5pt]{->}(0,0)(-6.5,-5.5)(6.5,7.5)[$x$,-90][$y$,180]% Achsen
800 %----- Funktionsgraphen plotten (Clippen, damit sie nicht aus dem Gitter ragen) -----------------
801 \begin{psclip}%
802 {\psframe[linestyle=none](-6.5,-5.4)(6.5,7.4)}
803 \psplot[linewidth=1pt,linecolor=Gray]{-6.5}{6.5}{\funkf}%
804 \psplot[linewidth=1pt,linecolor=BrickRed]{-6.5}{6.5}{\funkg}%
805 \end{psclip}
806 %----------------- SPEZIELLE PUNKTE -----------------
807 {\psset{fontscale=8,PrintCoord=true,linestyle=none,opacity=0.8,Framed=true,fillcolor=cyan!10}
808 %----------------- NULLSTELLEN -----------------
809 \psZero[xShift=-0.9,yShift=0.15,PointName={N},postString={1},ydecimals=0](-3,-2){\funkf}[0]{N1}
810 \psZero[xShift=-0.9,yShift=0.15,PointName={N},postString={2},ydecimals=0](2,3){\funkf}[0]{N2}
811 %----------------- EXTREMWERTE -----------------
812 \psZero[xShift=-0.9,yShift=-0.25,PointName={T},postString={1}](-2,0){Derive(1,\funkf)+\funkf}[\funkf]{T1}
813 \psZero[xShift=-0.9,yShift=0.25,PointName={H},postString={}](-1,1){Derive(1,\funkf)+\funkf}[\funkf]{H}
814 \psZero[xShift=-0.9,yShift=-0.25,PointName={T},postString={2}](0,2.5){Derive(1,\funkf)+\funkf}[\funkf]{T2}
815 %----------------- WENDEPUNKTE -----------------
816 \psZero[xShift=-1.2,yShift=-0.25,PointName={W},postString={1}](-1.5,-0.5){Derive(2,\funkf)+\funkf}[\funkf]{W1}
817 \psZero[xShift=-0.6,yShift=-0.25,PointName={W},postString={2}](0.5,1.5){Derive(2,\funkf)+\funkf}[\funkf]{W2}
818 \psZero[onlyNode=true,markZeros=false](-1.5,-0.5){Derive(2,\funkf)+Derive(1,\funkf)}[Derive(1,\funkf)]{mW1}%Steigung Wendepunkt 1 ist "nmW1y"
819 }
820 %----------------- GLEICHUNG WENDETANGENTE -----------------
821 \def\funkWende{nmW1y*(x-nW1x)+nW1y}
822 %----------------- GLEICHUNG WENDENORMALE -----------------
823 \def\funkNormal{-1/nmW1y*(x-nW1x)+nW1y} %m_n=-1/m_t
824 %----------------- Tangente und Normale in W1 plotten ------------------
825 \psplot[linewidth=1pt,linecolor=blue]{-1.3}{2.55}{\funkWende}%
826 \psplot[linewidth=1pt,linecolor=Green]{-6.5}{5}{\funkNormal}%
827 %----------------- Punkte und Werte NICHT anzeigen
828 {\psset{onlyNode=true,markZeros=false}
829 %----------------- Schnittpunkt: Wendetangente in W1 mit f -------------
830 \psZero(0,4){\funkWende}[\funkf]{WS1}
831 %----------------- Schnittpunkte: Wendenormale in W1 mit f -------------
832 \psZero(-4,0){\funkNormal}[\funkf]{WN1}
833 \psZero(0,1.5){\funkNormal}[\funkf]{WN2}
834 \psZero(1.5,3){\funkNormal}[\funkf]{WN3}
835 %----------------- NULLSTELLE von g -----------------
836 \psZero(-3,3){\funkg}[0]{Ng1}
837 %----------------- SCHNITTPUNKTE f und g -----------------
838 \psZero(0,3){\funkg}[\funkf]{S1}
839 \psZero(-3,0){\funkg}[\funkf]{S2}
840 }
841 %----------------- FLÄCHE mit x-ACHSE -----------------
842 \pscustom[fillstyle=solid,opacity=0.3,fillcolor=gray,linestyle=none]{%
843 \psplot{nN1x}{nW1x}{\funkf}
844 \lineto(!nW1x 0)
845 \closepath
846 }
847 %----------------- FLÄCHE ZWISCHEN WENDETANGENTE UND KURVE f -----------------
848 \pscustom[fillstyle=solid,opacity=0.3,fillcolor=blue,linestyle=none]{%
849 \psplot{nW1x}{nWS1x}{\funkWende}
850 \psplot{nWS1x}{nW1x}{\funkf}
851 \closepath
852 }
853 %----------------- FLÄCHE ZWISCHEN WENDENORMALE UND KURVE f (Zwei FlÄchenstücke!!!) ----
854 %----------------- linke FLÄCHE -----------------
855 \pscustom[fillstyle=solid,opacity=0.3,fillcolor=green,linestyle=none]{%
856 \psplot{nWN1x}{nW1x}{\funkNormal}
857 \psplot{nW1x}{nWN1x}{\funkf}
858 \closepath
859 }
860 %----------------- rechte FLÄCHE -----------------
861 \pscustom[fillstyle=solid,opacity=0.3,fillcolor=green,linestyle=none]{%
862 \psplot{nWN2x}{nWN3x}{\funkNormal}
863 \psplot{nWN3x}{nWN2x}{\funkf}
864 \closepath
865 }
866 %----------------- FLÄCHE zwischen den KURVEN f und g und beiden KOORDINATEN-ACHSEN -----
867 \pscustom[fillstyle=solid,opacity=0.3,fillcolor=yellow,linestyle=none]{%
868 \psplot{0}{nS1x}{\funkg}
869 \psplot{nS1x}{nN2x}{\funkf}
870 \lineto(0,0)
871 \closepath
872 }
873 % SPIELEREI: FLÄCHE mit f und PARALLELEN ZUR x-ACHSE
874 % Punkte und Werte NICHT anzeigen
875 {\psset{onlyNode=true,markZeros=false}
876 \psZero(-3,-2){\funkf}[2]{M1}
877 \psZero(-3,-2){\funkf}[4]{M2}
878 }
879 \pscustom[fillstyle=solid,opacity=0.3,fillcolor=magenta,linestyle=none]{%
880 \psplot{nM1x}{nM2x}{\funkf}
881 \lineto(0,4)
882 \lineto(0,2)
883 \closepath
884 }
885 \end{pspicture}}
886
887 \begin{lstlisting}
888 \psset{yunit=0.8,comma,decimals=2,algebraic=true,markZeros=true,plotpoints=500,saveNodeCoors,NodeCoorPrefix=n}
889 %----------------- FUNKTIONSDEFINITIONEN in "algebraic" -----------------
890 \def\funkf{0.75*x^4-3*x^2-2}
891 \def\funkg{0.25*x+1}
892
893 \begin{pspicture}(-6.5,-5.5)(6.5,8.5)
894 %------ Gitter im Hintergrund (CLIPPED) -----------------
895 \begin{psclip}%
896 {\psframe[linestyle=none](-6.4,-5.4)(6.4,7.4)}
897 \psgrid[subgriddiv=2,gridlabels=0,gridwidth=0.3pt,gridcolor=black!50,subgridwidth=0.2pt,subgridcolor=black!30](-6.5,-7.5)(6.5,8.5)
898 \end{psclip}
899 %--------- Achsen ------------
900 \psaxes[xDecimals=0, yDecimals=0,labelFontSize=\scriptstyle,arrowscale=1.3,arrowinset=0.05,arrowlength=1.9, Dy=1,dy=1,dx=1,Dx=1,subticks=0,comma,tickwidth=0.5pt]{->}(0,0)(-6.5,-5.5)(6.5,7.5)[$x$,-90][$y$,180]% Achsen
901 %----- Funktionsgraphen plotten (Clippen, damit sie nicht aus dem Gitter ragen) -----------------
902 \begin{psclip}%
903 {\psframe[linestyle=none](-6.5,-5.4)(6.5,7.4)}
904 \psplot[linewidth=1pt,linecolor=Gray]{-6.5}{6.5}{\funkf}%
905 \psplot[linewidth=1pt,linecolor=BrickRed]{-6.5}{6.5}{\funkg}%
906 \end{psclip}
907 %----------------- SPEZIELLE PUNKTE -----------------
908 {\psset{fontscale=8,PrintCoord=true,linestyle=none,opacity=0.8,Framed=true,fillcolor=cyan!10}
909 %----------------- NULLSTELLEN -----------------
910 \psZero[xShift=-0.9,yShift=0.15,PointName={N},postString={1},ydecimals=0](-3,-2){\funkf}[0]{N1}
911 \psZero[xShift=-0.9,yShift=0.15,PointName={N},postString={2},ydecimals=0](2,3){\funkf}[0]{N2}
912 %----------------- EXTREMWERTE -----------------
913 \psZero[xShift=-0.9,yShift=-0.25,PointName={T},postString={1}](-2,0){Derive(1,\funkf)+\funkf}[\funkf]{T1}
914 \psZero[xShift=-0.9,yShift=0.25,PointName={H},postString={}](-1,1){Derive(1,\funkf)+\funkf}[\funkf]{H}
915 \psZero[xShift=-0.9,yShift=-0.25,PointName={T},postString={2}](0,2.5){Derive(1,\funkf)+\funkf}[\funkf]{T2}
916 %----------------- WENDEPUNKTE -----------------
917 \psZero[xShift=-1.2,yShift=-0.25,PointName={W},postString={1}](-1.5,-0.5){Derive(2,\funkf)+\funkf}[\funkf]{W1}
918 \psZero[xShift=-0.6,yShift=-0.25,PointName={W},postString={2}](0.5,1.5){Derive(2,\funkf)+\funkf}[\funkf]{W2}
919 \psZero[onlyNode=true,markZeros=false](-1.5,-0.5){Derive(2,\funkf)+Derive(1,\funkf)}[Derive(1,\funkf)]{mW1}%Steigung Wendepunkt 1 ist "nmW1y"
920 }
921 %----------------- GLEICHUNG WENDETANGENTE -----------------
922 \def\funkWende{nmW1y*(x-nW1x)+nW1y}
923 %----------------- GLEICHUNG WENDETANGENTE -----------------
924 \def\funkNormal{-1/nmW1y*(x-nW1x)+nW1y} %m_n=-1/m_t
925 %----------------- Tangente und Normale in W1 plotten ------------------
926 \psplot[linewidth=1pt,linecolor=blue]{-1.3}{2.55}{\funkWende}%
927 \psplot[linewidth=1pt,linecolor=Green]{-6.5}{5}{\funkNormal}%
928 %----------------- Punkte und Werte NICHT anzeigen
929 {\psset{onlyNode=true,markZeros=false}
930 %----------------- Schnittpunkt: Wendetangente in W1 mit f -------------
931 \psZero(0,4){\funkWende}[\funkf]{WS1}
932 %----------------- Schnittpunkte: Wendenormale in W1 mit f -------------
933 \psZero(-4,0){\funkNormal}[\funkf]{WN1}
934 \psZero(0,1.5){\funkNormal}[\funkf]{WN2}
935 \psZero(1.5,3){\funkNormal}[\funkf]{WN3}
936 %----------------- NULLSTELLE von g -----------------
937 \psZero(-3,3){\funkg}[0]{Ng1}
938 %----------------- SCHNITTPUNKTE f und g -----------------
939 \psZero(0,3){\funkg}[\funkf]{S1}
940 \psZero(-3,0){\funkg}[\funkf]{S2}
941 }
942 %----------------- FLÄCHE mit x-ACHSE -----------------
943 \pscustom[fillstyle=solid,opacity=0.3,fillcolor=gray,linestyle=none]{%
944 \psplot{nN1x}{nW1x}{\funkf}
945 \lineto(!nW1x 0)
946 \closepath
947 }
948 %----------------- FLÄCHE ZWISCHEN WENDETANGENTE UND KURVE f -----------------
949 \pscustom[fillstyle=solid,opacity=0.3,fillcolor=blue,linestyle=none]{%
950 \psplot{nW1x}{nWS1x}{\funkWende}
951 \psplot{nWS1x}{nW1x}{\funkf}
952 \closepath
953 }
954 %----------------- FLÄCHE ZWISCHEN WENDENORMALE UND KURVE f (Zwei FlÄchenstücke!!!) ----
955 %----------------- linke FLÄCHE -----------------
956 \pscustom[fillstyle=solid,opacity=0.3,fillcolor=green,linestyle=none]{%
957 \psplot{nWN1x}{nW1x}{\funkNormal}
958 \psplot{nW1x}{nWN1x}{\funkf}
959 \closepath
960 }
961 %----------------- rechte FLÄCHE -----------------
962 \pscustom[fillstyle=solid,opacity=0.3,fillcolor=green,linestyle=none]{%
963 \psplot{nWN2x}{nWN3x}{\funkNormal}
964 \psplot{nWN3x}{nWN2x}{\funkf}
965 \closepath
966 }
967 %----------------- FLÄCHE zwischen den KURVEN f und g und beiden KOORDINATEN-ACHSEN -----
968 \pscustom[fillstyle=solid,opacity=0.3,fillcolor=yellow,linestyle=none]{%
969 \psplot{0}{nS1x}{\funkg}
970 \psplot{nS1x}{nN2x}{\funkf}
971 \lineto(0,0)
972 \closepath}
973 % SPIELEREI: FLÄCHE mit f und PARALLELEN ZUR x-ACHSE
974 % Punkte und Werte NICHT anzeigen
975 {\psset{onlyNode=true,markZeros=false}
976 \psZero(-3,-2){\funkf}[2]{M1}
977 \psZero(-3,-2){\funkf}[4]{M2}}
978 \pscustom[fillstyle=solid,opacity=0.3,fillcolor=magenta,linestyle=none]{%
979 \psplot{nM1x}{nM2x}{\funkf}
980 \lineto(0,4)
981 \lineto(0,2)
982 \closepath}
983 \end{pspicture}
984 \end{lstlisting}
985
986
987
988 %\begin{LTXexample}[pos=t]
989 \begin{lstlisting}
990 \definecolor{BeigeTS}{rgb}{0.98,0.95,0.87}
991 \definecolor{CornBlauTS}{rgb}{0.39,0.59,0.93}
992 \definecolor{SandBraun}{rgb}{0.96,0.64,0.38}
993 \psset{yunit=1.25cm,arrowinset=0.02,arrowlength=2,linewidth=0.5pt,saveNodeCoors,NodeCoorPrefix=n}
994 \def\funkf{2*sqrt(x)*cos(ln(x))*sin(x)}
995 \begin{pspicture}[plotpoints=500,algebraic,fontscale=5,markZeros,PrintCoord,
996 PointName=N,dotscale=0.7](-0.5,-3)(10,2.5)
997 \psStep[fillstyle=solid,fillcolor=BeigeTS,opacity=0.7,linewidth=0.3pt,
998 linecolor=SandBraun!50](0.001,9.5){40}{\funkf}
999 \psStep[StepType=Riemann,fillstyle=solid,opacity=0.3,fillcolor=CornBlauTS,
1000 linecolor=CornBlauTS,linewidth=0.3pt](0.001,9.5){40}{\funkf}
1001 \psaxes[labelFontSize=\scriptstyle,ticksize=-0.1 0]{->}(0,0)(0,-2.75)(10,2.5)
1002 \psplot[linecolor=BeigeTS!60,linewidth=0.8pt]{0.001}{9.75}{\funkf}
1003 \psplotTangent[linecolor=blue,Derive={Derive(1,\funkf)}]{1.29}{1.5}{\funkf}
1004 \uput[90](6,1.2){$f(x)=2\cdot\sqrt{x}\cdot\cos{(\ln{x})}\cdot\sin{x}$}
1005 {\psset{dotscale=1.5,linecolor=blue!50!black!90,ydecimals=0}
1006 \psZero[xShift=-0.2,yShift=0.15,postString=1,Newton](0.5,1){\funkf}{N1}
1007 \psZero[xShift=-0.05,yShift=0.15,postString=2](2,4){\funkf}{N2}
1008 \psZero[xShift=-0.45,yShift=0.15,postString=3](4,6){\funkf}{N3}
1009 \psZero[xShift=-0.45,yShift=0.15,postString=4](6,7){\funkf}{N4}
1010 \psZero[xShift=-0.45,yShift=0.15,postString=5](9,11){\funkf}{N5}
1011 \psZero[xShift=-1.15,yShift=0,PointName=M,
1012 postString={m=1}](0.5,2){Derive(1,\funkf)-1+\funkf}[\funkf]{M}%
1013 }
1014 \pcline{->}(0.5,-1)(M)
1015 \nbput[nrot=:U,labelsep=0.01]{%
1016 \scriptsize Steigung ist hier
1017 \psPrintValueNew[PSfont=Palatino-Roman,decimals=0,round,fontscale=7]{nMx,{Derive(1,\funkf)}}}
1018 \psdot[linecolor=green,strokeopacity=0.8](*{nMx} {\funkf})
1019 \uput[90](*{nMx} {\funkf}){$m=$
1020 \psPrintValueNew[PSfont=Palatino-Roman,decimals=0,round,fontscale=8]{nMx,{Derive(1,\funkf)}}}
1021 \end{pspicture}
1022 \end{lstlisting}
1023 %\end{LTXexample}
1024
1025
1026 As an alternative the values of the zeros can be placed by using the optional arguments
1027 \Lkeyword{labelangle} and
1028 \Lkeyword{labeldistance}:
1029
1030
1031 \begin{LTXexample}[pos=t]
1032 \definecolor{BeigeTS}{rgb}{0.98,0.95,0.87}
1033 \definecolor{CornBlauTS}{rgb}{0.39,0.59,0.93}
1034 \definecolor{SandBraun}{rgb}{0.96,0.64,0.38}
1035 \psset{yunit=1.25cm,arrowinset=0.02,arrowlength=2,linewidth=0.5pt,saveNodeCoors,NodeCoorPrefix=n,comma}
1036 \def\funkf{2*sqrt(x)*cos(ln(x))*sin(x)}
1037 \begin{pspicture}[plotpoints=500,algebraic,fontscale=5,markZeros,
1038 PointName=N,dotscale=0.7](-0.5,-3)(10,2.5)
1039 \psStep[fillstyle=solid,fillcolor=BeigeTS,opacity=0.7,linewidth=0.3pt,
1040 linecolor=SandBraun!50](0.001,9.5){40}{\funkf}
1041 \psStep[StepType=Riemann,fillstyle=solid,opacity=0.3,fillcolor=CornBlauTS,
1042 linecolor=CornBlauTS,linewidth=0.3pt](0.001,9.5){40}{\funkf}
1043 \psaxes[labelFontSize=\scriptstyle,ticksize=-0.1 0]{->}(0,0)(0,-2.75)(10,2.5)
1044 \psplot[linecolor=BeigeTS!60,linewidth=0.8pt]{0.001}{9.75}{\funkf}
1045 \psplotTangent[linecolor=blue,Derive={Derive(1,\funkf)}]{1.29}{1.5}{\funkf}
1046 \uput[90](6,1.2){$f(x)=2\cdot\sqrt{x}\cdot\cos{(\ln{x})}\cdot\sin{x}$}
1047 {\psset{dotscale=1.5,linecolor=blue!50!black!90,ydecimals=0,Framed,opacity=0.8,decimals=1,PrintCoord}
1048 \psZero[labelangle=-90,labeldistance=0.3,postString=1,Newton](0.5,1){\funkf}{N1}
1049 \psZero[labelangle=-90,labeldistance=0.3,postString=2](2,4){\funkf}{N2}
1050 \psZero[labelangle=-90,labeldistance=0.3,postString=3](4,6){\funkf}{N3}
1051 \psZero[labelangle=-90,labeldistance=0.3,postString=4](6,7){\funkf}{N4}
1052 \psZero[labelangle=-90,labeldistance=0.3,PointName=x,postString=5,xory,PrintCoord=false,
1053 linestyle=none,fillcolor=green,opacity=0.6](9,11){\funkf}{N5}
1054 \psZero[labelangle=-90,labeldistance=0.3,PointName=M,decimals=0,linestyle=none,fillcolor=SandBraun,
1055 ydecimals=1,opacity=0.8,postString={m=1}](0.5,2){Derive(1,\funkf)-1+\funkf}[\funkf]{M}%
1056 }
1057 \pcline{->}(0.5,-1)(M)
1058 \nbput[nrot=:U,labelsep=0.3,npos=0.2]{%
1059 \scriptsize \psZero[originV=true,xory=true,onlyYVal=true,PointName=f(x),postString={m=1},Framed,
1060 opacity=0.8,linestyle=none,markZeros=false,fontscale=10](0.5,2){Derive(1,\funkf)-1+\funkf}[\funkf]{R}}
1061 \psdot[linecolor=green,strokeopacity=0.8](M)
1062 \uput{0.5}[40](M){\psZero[originV=true,approx=false,xory=true,onlyYVal=true,
1063 PointName=m,postString={m=1},markZeros=false,fontscale=8](0.5,2){Derive(1,\funkf)-1}[1]{R}}
1064 \end{pspicture}
1065 \end{LTXexample}
1066
1067
1068
1069 \psset{unit=1cm}
1070
1071
1072 \clearpage
1073 \section{\Lcs{psFourier}}
1074 A Fourier sum has the form:
1075 %
1076 \begin{align}
1077 s(x) = \frac{a_0}{2} & + a_1\cos{\omega x} + a_2\cos{2\omega x} +
1078 a_3\cos{3\omega x} +
1079 \ldots + a_n\cos{n\omega x}\\
1080 & + b_1\sin{\omega x} + b_2\sin{2\omega x} + b_3\sin{3\omega x} +
1081 \ldots + b_m\sin{m\omega x}
1082 \end{align}
1083 %
1084 \noindent The macro \Lcs{psFourier} plots \Index{Fourier sums}. The
1085 syntax is similiar to \Lcs{psPolynomial}, except that there are
1086 two kinds of coefficients:
1087
1088 \begin{BDef}
1089 \Lcs{psFourier}\OptArgs\Largb{xStart}\Largb{xEnd}
1090 \end{BDef}
1091
1092 The coefficients must have the orders $cosCoeff=a_0\ a_1\ a_2\ \ldots$
1093 and $sinCoeff=b_1\ b_2\ b_3\ \ldots$ and be separated by
1094 \textbf{spaces}. The default is \Lkeyword{cosCoeff}=0,\Lkeyword{sinCoeff}=1,
1095 which gives the standard \verb+sin+ function. Note that
1096 %%JF, I think it is better without the angle brackets, but
1097 %%you know the conventions used better than I do, so you
1098 %%may disagree.
1099 %the constant value can only be set with \verb+cosCoeff=<a0>+.
1100 the constant value can only be set with \Lkeyword{cosCoeff}=\verb+a0+.
1101
1102 \begin{LTXexample}
1103 \begin{pspicture}(-5,-3)(5,5.5)
1104 \psaxes{->}(0,0)(-5,-2)(5,4.5)
1105 \psset{plotpoints=500,linewidth=1pt}
1106 \psFourier[cosCoeff=2, linecolor=green]{-4.5}{4.5}
1107 \psFourier[cosCoeff=0 0 2, linecolor=magenta]{-4.5}{4.5}
1108 \psFourier[cosCoeff=2 0 2, linecolor=red]{-4.5}{4.5}
1109 \end{pspicture}
1110 \end{LTXexample}
1111
1112 \begin{LTXexample}
1113 \psset{yunit=0.75}
1114 \begin{pspicture}(-5,-6)(5,7)
1115 \psaxes{->}(0,0)(-5,-6)(5,7)
1116 \psset{plotpoints=500}
1117 \psFourier[linecolor=red,linewidth=1pt]{-4.5}{4.5}
1118 \psFourier[sinCoeff= -1 1 -1 1 -1 1 -1 1,%
1119 linecolor=blue,linewidth=1.5pt]{-4.5}{4.5}
1120 \end{pspicture}
1121 \end{LTXexample}
1122
1123 \begin{LTXexample}
1124 \begin{pspicture}(-5,-5)(5,5.5)
1125 \psaxes{->}(0,0)(-5,-5)(5,5)
1126 \psset{plotpoints=500,linewidth=1.5pt}
1127 \psFourier[sinCoeff=-.5 1 1 1 1 ,cosCoeff=-.5 1 1 1 1 1,%
1128 linecolor=blue]{-4.5}{4.5}
1129 \end{pspicture}
1130 \end{LTXexample}
1131
1132 \clearpage
1133 \section{\Lcs{psBessel}}
1134 \subsection{Default type}
1135 The Bessel function of order $n$ is defined as
1136 %
1137 \begin{align}
1138 J_n(x) &=\frac{1}{\pi}\int_0^\pi\cos(x\sin t-nt)\dt\\
1139 &=\sum_{k=0}^{\infty}\frac{(-1)^k \left(\frac{x}{2}\right)^{n+2k}}{k!\Gamma(n+k+1)}
1140 \end{align}
1141 %
1142 \noindent The syntax of the macro is
1143
1144 \begin{BDef}
1145 \Lcs{psBessel}\OptArgs\Largb{order}\Largb{xStart}\Largb{xEnd}
1146 \end{BDef}
1147
1148 There are two special parameters for the Bessel function, and also the
1149 settings of many \LPack{pst-plot} or \LPack{pstricks} parameters
1150 affect the plot.
1151 These two ``constants'' have the following meaning:
1152 %
1153 \[
1154 f(t) = constI \cdot J_n + constII
1155 \]
1156 %
1157 \noindent
1158 where \Lkeyword{constI} and \Lkeyword{constII} must be real PostScript expressions, e.g.
1159
1160 \begin{lstlisting}[style=syntax]
1161 \psset{constI=2.3,constII=t toDegrees sin 1.2 mul 0.37 add}
1162 \end{lstlisting}
1163
1164 The Bessel function is plotted with the parametricplot macro, this is the
1165 reason why the variable is named \verb+t+. The internal procedure \verb+k+
1166 converts the value t from radian into degrees. The above setting is the same as
1167 %
1168 \[
1169 f(t) = 2.3 \cdot J_n + 1.2\cdot \sin t + 0.37
1170 \]
1171 %
1172 In particular, note that the default for
1173 \Lkeyword{plotpoints} is 500. If the plotting computations are too
1174 time consuming at this setting, it can be decreased in the usual
1175 way, at the cost of some reduction in graphics resolution.
1176
1177 \begin{LTXexample}[pos=t]
1178 \psset{xunit=0.25,yunit=5}
1179 \begin{pspicture}(-13,-.85)(13,1.25)
1180 \rput(13,0.8){%
1181 $\displaystyle J_n(x)=\frac{1}{\pi}\int_0^\pi\cos(x\sin t-nt)\dt$}
1182 \psaxes[Dy=0.2,Dx=4]{->}(0,0)(-30,-.8)(30,1.2)
1183 \psset{linewidth=1pt}
1184 \psBessel[linecolor=red]{0}{-28}{28}%
1185 \psBessel[linecolor=blue]{1}{-28}{28}%
1186 \psBessel[linecolor=green]{2}{-28}{28}%
1187 \psBessel[linecolor=magenta]{3}{-28}{28}%
1188 \end{pspicture}
1189 \end{LTXexample}
1190
1191
1192 \begin{LTXexample}[pos=t]
1193 \psset{xunit=0.25,yunit=2.5}
1194 \begin{pspicture}(-13,-1.5)(13,3)
1195 \rput(13,0.8){%
1196 $\displaystyle f(t) = 2.3 \cdot J_0 + 1.2\cdot \sin t + 0.37$}
1197 \psaxes[Dy=0.8,dy=2cm,Dx=4]{->}(0,0)(-30,-1.5)(30,3)
1198 \psset{linewidth=1pt}
1199 \psBessel[linecolor=red,constI=2.3,constII={t toDegrees sin 1.2 mul 0.37 add}]{0}{-28}{28}%
1200 \end{pspicture}
1201 \end{LTXexample}
1202
1203
1204 %\clearpage
1205 \subsection{Modfied Bessel function of first order}
1206 The modified Bessel function of first order is defined as
1207 %
1208 \begin{align}
1209 I_\nu(x) &= \left(\frac12 x\right)^\nu
1210 \sum\limits_{k=0}^{\infty} \frac{{\left(\frac14 x^2\right)}^k}{k!\Gamma(\nu+k+1)}
1211 \end{align}
1212 %
1213 \noindent The syntax of the macro is
1214
1215
1216 \begin{BDef}
1217 \Lcs{psModBessel}\OptArgs\Largb{xStart}\Largb{xEnd}
1218 \end{BDef}
1219
1220 The only valid optional argument for the function is \Lkeyword{nue}, which
1221 is preset to 0, it shows $I_0$.
1222
1223
1224
1225
1226
1227
1228 \begin{LTXexample}
1229 \begin{pspicture}(0,-0.5)(5,5)
1230 \psaxes[ticksize=-5pt 0]{->}(5,5)
1231 \psModBessel[yMaxValue=5,nue=0,linecolor=red]{0}{5}
1232 \psModBessel[yMaxValue=5,nue=1,linecolor=green]{0}{5}
1233 \psModBessel[yMaxValue=5,nue=2,linecolor=blue]{0}{5}
1234 \psModBessel[yMaxValue=5,nue=3,linecolor=cyan]{0}{5}
1235 \end{pspicture}
1236 \end{LTXexample}
1237
1238 \clearpage
1239
1240
1241
1242 \section{\Lcs{psSi}, \Lcs{pssi} and \Lcs{psCi}}
1243 The integral sin and cosin are defined as
1244 %
1245 \begin{align}
1246 \mathrm{Si}(x) &= \int_0^x\dfrac{\sin t}{t}\dt\\
1247 \mathrm{si}(x) &= - \int_x^{\infty}\dfrac{\sin t}{t}\dt=\mathrm{Si}(x)-\frac{\pi}{2}\\
1248 \mathrm{Ci}(x) &= -\int_x^{\infty}\dfrac{\cos t}{t}\dt=\gamma+\ln x +\int_0^{x}\dfrac{\cos t -1}{t}\dt
1249 \end{align}
1250 %
1251 \noindent The syntax of the macros is
1252
1253 \begin{BDef}
1254 \Lcs{psSi}\OptArgs\Largb{xStart}\Largb{xEnd}\\
1255 \Lcs{pssi}\OptArgs\Largb{xStart}\Largb{xEnd}\\
1256 \Lcs{psCi}\OptArgs\Largb{xStart}\Largb{xEnd}
1257 \end{BDef}
1258
1259 \begin{LTXexample}[pos=t]
1260 \psset{xunit=0.5}
1261 \begin{pspicture}(-15,-4.5)(15,2)
1262 \psaxes[dx=1cm,Dx=2]{->}(0,0)(-14.1,-4)(14,2)
1263 \psplot[plotpoints=1000]{-12.5}{12.5}{ x RadtoDeg sin x div }
1264 \psSi[plotpoints=1500,linecolor=red,linewidth=1pt]{-13.5}{13.5}
1265 \pssi[plotpoints=1500,linecolor=blue,linewidth=1pt]{-13.5}{13.5}
1266 \rput(-5,1.5){\color{red}$Si(x)=\int\limits_{0}^x \frac{\sin(t)}{t}\dt$}
1267 \rput(8,-1.5){\color{blue}$si(x)=-\int\limits_{x}^{\infty} \frac{\sin(t)}{t}\dt=Si(x)-\frac{\pi}{2}$}
1268 \rput(8,.5){$f(x)= \frac{\sin(t)}{t}$}
1269 \end{pspicture}
1270 \end{LTXexample}
1271
1272
1273
1274 \begin{LTXexample}[pos=t]
1275 \psset{xunit=0.5}
1276 \begin{pspicture*}(-13,-4.2)(13,4.2)
1277 \psaxes[dx=1cm,Dx=2]{->}(0,0)(-12.1,-4)(12,4)
1278 \psplot[plotpoints=1000]{-14.5}{14.5}{ x RadtoDeg cos x Div }
1279 \psCi[plotpoints=500,linecolor=red,linewidth=1pt]{-11.5}{11.5}
1280 \psci[plotpoints=500,linecolor=blue,linewidth=1pt]{-11.5}{11.5}
1281 \rput(-8,1.5){\color{red}$Ci(x)=-\int\limits_{x}^{\infty} \frac{\cos(t)}{t}\dt$}
1282 \rput(8,1.5){\color{blue}$ci(x)=-Ci(x)+\ln(x)+\gamma$}
1283 \end{pspicture*}
1284 \end{LTXexample}
1285
1286 \clearpage
1287 \section{\nxLcs{psIntegral}, \nxLcs{psCumIntegral}, and \nxLcs{psConv}}
1288 These new macros\footnote{Created by Jose-Emilio Vila-Forcen}
1289 allows to plot the result of an integral using the Simpson numerical integration rule.
1290 The first one is the result of the integral of a function with two variables, and
1291 the integral is performed over one of them. The second one is the cumulative
1292 integral of a function (similar to \Lcs{psGaussI} but valid for all functions).
1293 The third one is the result of a convolution. They are defined as:
1294 %
1295 \begin{align}
1296 \text{\Lcs{psIntegral}}(x) &= \int\limits_a^b f(x,t)\mathrm{d}t \\
1297 \text{\Lcs{psCumIntegral}}(x) &= \int\limits_{\text{xStart}}^{x} f(t)\mathrm{d}t \\
1298 \text{\Lcs{psConv}}(x) &= \int\limits_a^b f(t)g(x-t)\mathrm{d}t
1299 \end{align}
1300 %
1301 In the first one, the integral is performed from $a$ to $b$ and the function $f$ depends
1302 on two parameters. In the second one, the function $f$ depends on only one parameter, and the
1303 integral is performed from the minimum value specified for $x$ (\Lkeyword{xStart}) and the current
1304 value of $x$ in the plot. The third one uses the \Lcs{psIntegral} macro to perform an approximation
1305 to the convolution, where the integration is performed from $a$ to $b$.
1306
1307 The syntax of these macros is:
1308
1309 \begin{BDef}
1310 \Lcs{psIntegral}\OptArgs\Largb{xStart}\Largb{xEnd}\Largr{a,b}\Largb{ function }\\
1311 \Lcs{psCumIngegral}\OptArgs\Largb{xStart}\Largb{xEnd}\Largb{ function }\\
1312 \Lcs{psConv}\OptArgs\Largb{xStart}\Largb{xEnd}\Largr{a,b}\Largb{ function f }\Largb{ function g }
1313 \end{BDef}
1314
1315 In the first macro, the function should be created such that it accepts two values: \verb|<x t function>|
1316 should be a value. For the second and the third functions, they only need to accept one
1317 parameter: \verb|<x function>| should be a value.
1318
1319 There are no new parameters for these functions. The two most important ones are \Lkeyword{plotpoints},
1320 which controls the number of points of the plot (number of divisions on $x$ for the plot) and
1321 \Lkeyword{Simpson}, which controls the precision of the integration (a larger number means a smallest
1322 step). The precision and the smoothness of the plot depend strongly on these two parameters.
1323
1324 \bigskip
1325 \begin{LTXexample}
1326 %\usepackage{pst-math}
1327 \psset{xunit=0.5cm,yunit=2cm}
1328 \begin{pspicture}[linewidth=1pt](-10,-.5)(10,1.5)
1329 \psaxes[dx=1cm,Dx=2]{->}(0,0)(-10,0)(10,1.5)
1330 \psCumIntegral[plotpoints=200,Simpson=10]{-10}{10}{0 1 GAUSS}
1331 \psIntegral[plotpoints=200,Simpson=100,linecolor=green]{.1}{10}(-3,3){0 exch GAUSS}
1332 \psIntegral[plotpoints=200,Simpson=10,linecolor=red,
1333 fillcolor=red!40,fillstyle=solid,opacity=0.5]{-10}{10}(-4,6){1 GAUSS}
1334 \end{pspicture}
1335 \end{LTXexample}
1336
1337 In the example, the cumulative integral of a Gaussian is presented in black. In red, a
1338 Gaussian is varying its mean from -10 to 10, and the result is the integral from -4 to 6.
1339 Finally, in green it is presented the integral of a Gaussian from -3 to 3, where the
1340 variance is varying from 0.1 to 10.
1341
1342
1343 \psset{algebraic=false}
1344
1345 \begin{LTXexample}
1346 \psset{xunit=1cm,yunit=4cm}
1347 \begin{pspicture}[linewidth=1pt](-5,-.2)(5,0.75)
1348 \psaxes[dx=1cm,Dx=1,Dy=0.5]{->}(0,0)(-5,0)(5,0.75)
1349 \psplot[linecolor=blue,plotpoints=200]{-5}{5}{x abs 2 le {0.25}{0} ifelse}
1350 \psplot[linecolor=green,plotpoints=200]{-5}{5}{x abs 1 le {.5}{0} ifelse}
1351 \psConv[plotpoints=100,Simpson=1000,linecolor=red]{-5}{5}(-10,10)%
1352 {abs 2 le {0.25}{0} ifelse}{abs 1 le {.5} {0} ifelse}
1353 \end{pspicture}
1354 \end{LTXexample}
1355
1356 In the second example, a convolution is performed using two rectangle functions.
1357 The result (in red) is a \Index{trapezoid function}.
1358
1359
1360 \begin{LTXexample}
1361 \psset{xunit=0.5cm,yunit=4cm}
1362 \begin{pspicture}[linewidth=1pt](-11,-1.5)(11,1.5)
1363 \psaxes[dx=1cm,Dx=2]{->}(0,0)(-10.5,-1.25)(10.5,1.25)
1364 \psCumIntegral[plotpoints=2000,Simpson=10,algebraic]{-10}{10}{-sin(x/2)/2}
1365 \psplot[plotpoints=2000,linestyle=dashed,linecolor=red,algebraic]{-10}{10}{cos(x/2)}
1366 \rput(4,0.5){\textcolor{red}{$\displaystyle\cos\left(\frac{x}2\right)$}}
1367 \rput*(0,-1.1){$\displaystyle\int\limits\frac{-\sin(\frac{x}2)}{2}\mathrm dx$}
1368 \end{pspicture}
1369 \end{LTXexample}
1370
1371
1372 %$
1373
1374 \clearpage
1375 \section{Distributions}
1376 All distributions which use the $\Gamma$- or $\ln\Gamma$-function need the \LPack{pst-math} package,
1377 it defines the PostScript functions \Lps{GAMMA} and \Lps{GAMMALN}. \LPack{pst-func} reads by default the PostScript
1378 file \LFile{pst-math.pro}. It is part of any \TeX\ distribution and should also be on
1379 your system, otherwise install or update it from \textsc{CTAN}. It must be the latest version.
1380
1381 \begin{LTXexample}[pos=l,width=7cm]
1382 \begin{pspicture*}(-0.5,-0.5)(6.2,5.2)
1383 \psaxes{->}(0,0)(6,5)
1384 \psset{plotpoints=100,linewidth=1pt}
1385 \psplot[linecolor=red]{0.01}{4}{ x GAMMA }
1386 \psplot[linecolor=blue]{0.01}{5}{ x GAMMALN }
1387 \end{pspicture*}
1388 \end{LTXexample}
1389
1390 \clearpage
1391 \subsection{Normal distribution (Gauss)}
1392 The Gauss function is defined as
1393 %
1394 \begin{align}
1395 f(x) &= \dfrac{1}{\sigma\sqrt{2\pi}}\,e^{-\dfrac{\left(x-\mu\right)^2}{2\sigma{}^2}}
1396 \end{align}
1397 %
1398 \noindent The syntax of the macros is
1399
1400 \begin{BDef}
1401 \Lcs{psGauss}\OptArgs\Largb{xStart}\Largb{xEnd}\\
1402 \Lcs{psGaussI}\OptArgs\Largb{xStart}\Largb{xEnd}
1403 \end{BDef}
1404
1405 \noindent where the only new parameter are \Lkeyword{sigma}=<value>+ and \Lkeyword{mue}=<value>+
1406 for the horizontal shift, which can also be set in the usual way with \Lcs{psset}.
1407 It is significant only for the \Lcs{psGauss} and \Lcs{psGaussI} macro. The default is
1408 \Lkeyword{sigma}=0.5 and \Lkeyword{mue}=0. The integral is caclulated wuth the Simson algorithm
1409 and has one special option, called \Lkeyword{Simpson}, which defines the number of intervals per step
1410 and is predefined with 5.
1411
1412 \begin{LTXexample}[pos=t,preset=\centering,wide=true]
1413 \psset{yunit=4cm,xunit=3}
1414 \begin{pspicture}(-2,-0.2)(2,1.4)
1415 % \psgrid[griddots=10,gridlabels=0pt, subgriddiv=0]
1416 \psaxes[Dy=0.25]{->}(0,0)(-2,0)(2,1.25)
1417 \uput[-90](6,0){x}\uput[0](0,1){y}
1418 \rput[lb](1,0.75){\textcolor{red}{$\sigma =0.5$}}
1419 \rput[lb](1,0.5){\textcolor{blue}{$\sigma =1$}}
1420 \rput[lb](-2,0.5){$f(x)=\dfrac{1}{\sigma\sqrt{2\pi}}\,e^{-\dfrac{(x-\mu)^2}{2\sigma{}^2}}$}
1421 \psGauss[linecolor=red, linewidth=2pt]{-1.75}{1.75}%
1422 \psGaussI[linewidth=1pt]{-2}{2}%
1423 \psGauss[linecolor=cyan, mue=0.5, linewidth=2pt]{-1.75}{1.75}%
1424 \psGauss[sigma=1, linecolor=blue, linewidth=2pt]{-1.75}{1.75}
1425 \end{pspicture}
1426 \end{LTXexample}
1427
1428
1429
1430
1431
1432 \clearpage
1433
1434
1435
1436 \subsection{Binomial distribution}\label{sec:bindistri}
1437 \begin{sloppypar}
1438 The following five macros plot binomial probability mass function \Lcs{psBinomial} and \Lcs{psBinomialC} in curve style, the normalized one is \Lcs{psBinomialN}. The cumulative distribution function
1439 $F$ \Lcs{psBinomialF} and the complement of the cumulative distribution function ($1-F$) \Lcs{psBinomialFS}
1440 The vertical range for the plots is the $y$-Intervall $[0;1]$.
1441 Rescaling other values can be done by setting the \Lkeyword{yunit} option
1442 to any other value.
1443 \end{sloppypar}
1444
1445 The binomial distribution \Lcs{psBinomial} gives the discrete probability distribution $P_p(n|N)$ $n$ successes out of $N$ Bernoulli trials (where the result of each Bernoulli trial is true with probability $p$ and false with probability $q=1-p$). The binomial distribution is therefore given by
1446
1447 \begin{align}
1448 P_p(n|N) &= \binom{N}{n}p^nq^{N-n} \\
1449 &= \frac{N!}{n!(N-n)!}p^n(1-p)^{N-n},
1450 \end{align}
1451
1452 where $(N; n)$ is a binomial coefficient and $P$ the probability.
1453
1454 The syntax is:
1455
1456 \begin{BDef}
1457 \Lcs{psBinomial}\OptArgs\Largb{N}\Largb{probability p}\\
1458 \Lcs{psBinomial}\OptArgs\Largb{m,N}\Largb{probability p}\\
1459 \Lcs{psBinomial}\OptArgs\Largb{m,n,N}\Largb{probability p}\\
1460 \Lcs{psBinomialC}\OptArgs\Largb{N}\Largb{probability p}\\
1461 \Lcs{psBinomialN}\OptArgs\Largb{N}\Largb{probability p}\\
1462 \Lcs{psBinomialF}\OptArgs\Largb{N}\Largb{probability p}\\
1463 \Lcs{psBinomialF}\OptArgs\Largb{m,N}\Largb{probability p}\\
1464 \Lcs{psBinomialF}\OptArgs\Largb{m,n,N}\Largb{probability p}\\
1465 \Lcs{psBinomialFS}\OptArgs\Largb{N}\Largb{probability p}\\
1466 \Lcs{psBinomialFS}\OptArgs\Largb{m,N}\Largb{probability p}\\
1467 \Lcs{psBinomialFS}\OptArgs\Largb{m,n,N}\Largb{probability p}
1468 \end{BDef}
1469
1470 \begin{itemize}
1471 \item with one argument $N$ the sequence $0\ldots N$ is calculated and plotted
1472 \item with two arguments $m,N$ the sequence $0\ldots N$ is calculated and
1473 the sequence $m\ldots N$ is plotted
1474 \item with three arguments $m,n,N$ the sequence $0\ldots N$ is calculated and
1475 the sequence $m\ldots n$ is plotted
1476 \end{itemize}
1477
1478 Now \Lcs{psBinomial}, \Lcs{psBinomialF} and \Lcs{psBinomialFS} uses a new code, so the old restriction in using the value for $N$ (old: $N<100$) is no longer valid. A new limit vor $N$ is not searched and it's not found.
1479 The valid options for the macros are \Lkeyword{markZeros} to draw rectangles instead
1480 of a continous line and \Lkeyword{printValue} for printing the $y$-values in the color LabelColor $=$ color on top of the lines in distance labelsep and xlabelsep, rotated by labelangle $=\alpha$. For this option all other options from section~1
1481 for the macro \Lcs{psPrintValue} are valid, too.~ \cite{pst-tools} Important is the keyword \Lkeyword{valuewidth}
1482 which is preset to 15. If your value has more characters when converting into a string, it will
1483 not be printed or cause an GhostScript error.
1484
1485 Special options are
1486 \begin{itemize}
1487 \item \Lkeyword{barwidth}, which is a factor (no dimension) and set by default to 1. This option is not valid for
1488 the macro \Lcs{psBinomialN}!
1489 \item \Lkeyword{alternateColors} is a new fillstyle, so the colors alternates between \Lkeyword{fillcolorA} and \Lkeyword{fillcolorB}, only valid for \Lcs{psBinomial}.
1490 \item \Lkeyword{fillcolorA} alternate color one.
1491 \item \Lkeyword{fillcolorB} alternate color two.
1492 \item \Lkeyword{labelangle} is the rotation of the printed values, default is 90\textdegree
1493 \item \Lkeyword{xlabelsep} is the x-separation of the printed values, default is 0 (no dimension)
1494 \item \Lkeyword{labelsep} is the y-separation of the printed values, default is 0.2 (no dimension)
1495 \item \Lkeyword{LabelColor} is the color of the printed values, default is black
1496 \item \Lkeyword{PrintVLimit} is the value limit for the printed values, default is $1e-64$, smaller values are not printed.
1497 \item \Lkeyword{Switch2Log} is the value for $N$ where the new calculation is used, default is $80$.
1498 \item \Lkeyword{LineEnding} this boolean is only valid for the macros \Lcs{psBinomialF} and \Lcs{psBinomialFS}, default is true. Draws circles at the end of the lines
1499 \item \Lkeyword{VLines} this option is only valid for the macros \Lcs{psBinomialF} and \Lcs{psBinomialFS}, default is false. Draws the vertical lines dashed.
1500 \item \Lkeyword{rightEnd}, this option is only valid for the macros \Lcs{psBinomialF} and \Lcs{psBinomialFS} when LineEnding=true (default) and $n=N$, default is 2
1501 \item \Lkeyword{leftEnd}, this option is only valid for the macros \Lcs{psBinomialF} and \Lcs{psBinomialFS} when LineEnding=true (default) and $m=0$, default is 1
1502 \item \Lkeyword{radiusout}, this option is only valid for the macros \Lcs{psBinomialF} and \Lcs{psBinomialFS} when LineEnding=true (default) for the outer radius of the both dots left and right, default is 2
1503 \item \Lkeyword{radiusinL}, this option is only valid for the macros \Lcs{psBinomialF} and \Lcs{psBinomialFS} when LineEnding=true (default) for the inner radius of the left dot, default is 0
1504 \item \Lkeyword{radiusinR}, this option is only valid for the macros \Lcs{psBinomialF} and \Lcs{psBinomialFS} when LineEnding=true (default) for the inner radius of the right dot, default is 1.5
1505 \item \Lkeyword{LineEndColorL} this option is only valid for the macros \Lcs{psBinomialF} and \Lcs{psBinomialFS} when LineEnding=true (default) for the color of the left dot, default is green
1506 \item \Lkeyword{LineEndColorR} this option is only valid for the macros \Lcs{psBinomialF} and \Lcs{psBinomialFS} when LineEnding=true (default) for the inner radius of the right dot, default is red
1507 \item \Lkeyword{LeftClipX} gives the left end of the clipping area for \Lcs{psBinomialC}, default is $-1$.
1508 \item \Lkeyword{RightClipX} gives the distance to $N$ for the right end of the clipping area for \Lcs{psBinomialC}, default is $1$.
1509 \end{itemize}
1510
1511
1512
1513 \begin{LTXexample}[pos=t,preset=\centering]
1514 \psset{xunit=0.7cm,yunit=7cm}%
1515 \begin{pspicture}[showgrid=false](-1.5,-0.1)(10.5,1.2)%
1516 \psset{arrowscale=1.3,arrowinset=0.05,arrowlength=1.9,comma}%
1517 \psaxes[labelFontSize=\scriptstyle,xticksize=0 1.07,yticksize=0 10,tickcolor=gray!50,
1518 Dy=0.1,dy=0.1,Dx=1,dx=1,Ox=0]{->}(0,0)(-0.9,0)(10,1.1)[$z$,0][$P_{0,15}^{100}(Z=z)$,0]
1519 \psBinomialF[linecolor=red,fillstyle=solid,fillcolor=yellow,barwidth=1,linewidth=1pt,
1520 opacity=0.5,LineEndColorL=red,rightEnd=5]{4}{0.5}
1521 \end{pspicture}
1522 \end{LTXexample}
1523
1524
1525
1526 \psset[pst-func]{barwidth=1}
1527 \begin{LTXexample}[pos=t,preset=\centering]
1528 \psset{xunit=1cm,yunit=5cm}%
1529 \begin{pspicture}(-1,-0.15)(7,0.6)%
1530 \psaxes[Dy=0.2,dy=0.2\psyunit]{->}(0,0)(-1,0)(7,0.5)
1531 \uput[-90](7,0){$k$} \uput[90](0,0.5){$P(X=k)$}
1532 \psBinomial[markZeros,printValue,fillstyle=vlines,
1533 labelangle=80,LabelColor=blue]{6}{0.4}
1534 \end{pspicture}
1535 \end{LTXexample}
1536
1537 \begin{LTXexample}[pos=t,preset=\centering]
1538 \psset{xunit=1cm,yunit=10cm}%
1539 \begin{pspicture}(-1,-0.05)(8,0.6)%
1540 \psaxes[Dy=0.2,dy=0.2\psyunit]{->}(0,0)(-1,0)(8,0.5)
1541 \uput[-90](8,0){$k$} \uput[90](0,0.5){$P(X=k)$}
1542 \psBinomialC[fillstyle=solid,opacity=0.5,fillcolor=cyan]{7}{0.6}
1543 \psBinomial[linecolor=red,markZeros,printValue,fillstyle=solid,
1544 fillcolor=blue,barwidth=0.2,xlabelsep=-0.05]{7}{0.6}
1545 \end{pspicture}
1546 \end{LTXexample}
1547
1548 \begin{LTXexample}[pos=t,preset=\centering]
1549 \psset{xunit=1cm,yunit=10cm}%
1550 \begin{pspicture}(-1,-0.05)(8,0.6)%
1551 \psaxes[Dy=0.2,dy=0.2\psyunit]{->}(0,0)(-1,0)(8,0.5)
1552 \uput[-90](8,0){$k$} \uput[90](0,0.5){$P(X=k)$}
1553 \psBinomial[linecolor=black!30]{0,7}{0.6}
1554 \psBinomial[linecolor=blue,markZeros,printValue,fillstyle=solid,
1555 fillcolor=blue,barwidth=0.4]{2,5,7}{0.6}
1556 \psBinomialC[showpoints=true]{7}{0.6}
1557 \end{pspicture}
1558 \end{LTXexample}
1559
1560 %$
1561
1562 \begin{LTXexample}[pos=t,preset=\centering]
1563 \psset{xunit=0.25cm,yunit=10cm}
1564 \begin{pspicture*}(-1,-0.05)(61,0.52)
1565 \psaxes[Dx=5,dx=5\psxunit,Dy=0.2,dy=0.2\psyunit]{->}(60,0.5)
1566 \uput[-90](60,0){$k$} \uput[0](0,0.5){$P(X=k)$}
1567 \psBinomial[markZeros,linecolor=red]{4}{.5}
1568 \psset{linewidth=1pt}
1569 \psBinomial[linecolor=green]{5}{.5} \psBinomial[linecolor=blue]{10}{.5}
1570 \psBinomial[linecolor=red]{20}{.5} \psBinomial[linecolor=magenta]{50}{.5}
1571 \psBinomial[linecolor=cyan]{0,55,75}{.5}
1572 \end{pspicture*}
1573 \end{LTXexample}
1574
1575 \begin{LTXexample}[pos=t,preset=\centering]
1576 \psset{xunit=0.8cm,yunit=8cm}%
1577 \begin{pspicture*}[showgrid=false](-1.5,-0.1)(16,1.2)%
1578 \psset{arrowscale=1.3,arrowinset=0.05,arrowlength=1.9,comma}%
1579 \psaxes[labelFontSize=\scriptstyle,xticksize=0 1.07,yticksize=0 16,tickcolor=gray!50,
1580 Dy=0.1,dy=0.1,Dx=1,dx=1,Ox=0]{->}(0,0)(-0.9,0)(16,1.1)
1581 \uput[-90](15.8,0){$z$}\uput[0](0,1.1){$P_{0,15}^{100}(Z=z)$}
1582 \psBinomialC[linecolor=cyan,fillstyle=solid,fillcolor=cyan!50,opacity=0.4]{40}{0.15}%
1583 \psBinomial[markZeros,linecolor=BrickRed,fillstyle=solid,fillcolor=BrickRed,barwidth=0.75,opacity=0.6]{1,16,40}{0.15}%
1584 \psBinomialFS[markZeros,linecolor=Green,fillstyle=solid,fillcolor=orange,barwidth=0.3,opacity=0.6]{0,16,40}{0.15}%
1585 \psBinomialF[linecolor=gray,fillstyle=solid,fillcolor=yellow,barwidth=0.4,opacity=0.5]{3,16,40}{0.15}
1586 \end{pspicture*}
1587 \end{LTXexample}
1588
1589 \begin{LTXexample}[pos=t,preset=\centering]
1590 \psset{xunit=0.75cm,yunit=7.5cm}%
1591 \begin{pspicture*}[showgrid=false](-1.3,-0.067)(14.67,1.13)%
1592 \psset{arrowscale=1.3,arrowinset=0.05,arrowlength=1.9,comma}
1593 \psaxes[labelFontSize=\scriptstyle,xticksize=0 1.07,yticksize=0 12,tickcolor=gray!50,Dy=0.1,dy=0.1,Dx=1,dx=1,Ox=0]{->}(0,0)(-0.9,0)(14,1.1)
1594 \uput[-90](13.8,0){$z$} \uput[0](0,1.08){$F_{0,7}^{10}(Z\leq z)$}
1595 \psBinomial[markZeros,linecolor=orange,fillstyle=solid,fillcolor=orange,barwidth=1,opacity=0.5]{0,10,10}{0.7}
1596 \psBinomialF[markZeros,linecolor=blue,linewidth=0.7pt,barwidth=0.2,
1597 opacity=0.5,fillstyle=solid,fillcolor=blue,valuewidth=15]{0,13,10}{0.7}
1598 \psBinomialFS[LineEnding=false,linecolor=BrickRed,linewidth=0.9pt,VLines=true]{0,10,10}{0.7}
1599 \psBinomialF[linecolor=Green,printValue=false,linewidth=1.2pt,LineEndColorR=BrickRed,LineEndColorL=Green!70,
1600 radiusout=3.5,radiusinL=0,radiusinR=2,LineEnding=true,leftEnd=1,rightEnd=3]{0,10,10}{0.7}
1601 \end{pspicture*}
1602 \end{LTXexample}
1603
1604 \begin{LTXexample}[pos=t,preset=\centering]
1605 \begin{pspicture}[showgrid=false](-.75,-1.8)(13.2,4.7)%
1606 {\psset{xunit=1cm,yunit=12cm}%
1607 \psset{plotpoints=500,arrowscale=1.3,arrowinset=0.05,arrowlength=1.9,comma}
1608 \psaxes[labelFontSize=\scriptstyle,xticksize=0 0,yticksize=0 12,tickcolor=gray!50,Dy=0.05,dy=0.05,Dx=1,dx=1,Ox=0]{-}(0,0)(-0.9,0)(10.8,0.34)
1609 \uput[-90](11.9,0){$z$} \uput[0](0,0.36){$P_{0,8}^{10}(Z=z)$}\uput[0](0,0.32){$P_{0,7}^{10}(Z=z)$}
1610 \rput(-0.05,0){%
1611 \psBinomialC[linecolor=Green,fillstyle=solid,fillcolor=gray,opacity=0.25,plotstyle=curve,linestyle=dashed]{10}{0.8}}
1612 \rput(0.05,0){%
1613 \psBinomialC[linecolor=cyan,fillstyle=solid,fillcolor=cyan,opacity=0.25,plotstyle=curve,linestyle=dashed]{10}{0.7}%
1614 \psBinomial[markZeros,linecolor=cyan,fillstyle=solid,fillcolor=cyan,barwidth=0.2,opacity=0.85]{0,8,10}{0.7}%,printValue
1615 \psBinomial[markZeros,linecolor=magenta,fillstyle=solid,fillcolor=magenta,barwidth=0.2,opacity=0.85]{9,10,10}{0.7}
1616 }
1617 \rput(-0.05,0){%
1618 \psBinomialC[linecolor=Green,fillstyle=solid,fillcolor=gray,opacity=0.25,plotstyle=curve,linestyle=dashed]{10}{0.8}
1619 \psBinomial[markZeros,linecolor=DeepSkyBlue4,fillstyle=solid,fillcolor=DeepSkyBlue4,barwidth=0.2,opacity=0.85]{0,8,10}{0.8}%,printValue
1620 \psBinomial[markZeros,linecolor=BrickRed,fillstyle=solid,fillcolor=BrickRed,barwidth=0.2,opacity=0.85]{9,10,10}{0.8}
1621 }
1622 \psaxes[labels=none,xticksize=-2pt 0,yticksize=-2pt 0,tickcolor=black!70,Dy=0.05,dy=0.05\psyunit,Dx=1,dx=1\psxunit,Ox=0]{->}(0,0)(-0.9,0)(12,0.35)
1623 \rput(5,0.33){\psframebox[fillstyle=solid,fillcolor=orange!30,linestyle=none]{$n=10$}}
1624 }
1625 \end{pspicture}
1626 \end{LTXexample}
1627
1628 \begin{LTXexample}[pos=t,preset=\centering]
1629 \begin{pspicture}[showgrid=false](-.75,-1.8)(13.2,4.7)%
1630 {\psset{xunit=1cm,yunit=12cm}%
1631 \psset{plotpoints=500,arrowscale=1.3,arrowinset=0.05,arrowlength=1.9,comma}
1632 \psaxes[labelFontSize=\scriptstyle,xticksize=0 0,yticksize=0 12,tickcolor=gray!50,Dy=0.05,dy=0.05,Dx=1,dx=1,Ox=0]{-}(0,0)(-0.9,0)(10.8,0.34)
1633 \uput[-90](11.9,0){$z$} \uput[0](0,0.32){$P_{0,7}^{10}(Z=z)$}
1634 \psBinomialC[linecolor=cyan,fillstyle=solid,fillcolor=cyan,opacity=0.25,plotstyle=curve,linestyle=dashed,LeftClipX=4,RightClipX=-3]{10}{0.7}%
1635 \psBinomial[markZeros,linecolor=cyan,fillstyle=solid,fillcolor=cyan,barwidth=0.2,opacity=0.85]{0,8,10}{0.7}%,printValue
1636 \psBinomial[markZeros,linecolor=magenta,fillstyle=solid,fillcolor=magenta,barwidth=0.2,opacity=0.85]{9,10,10}{0.7}
1637 \psaxes[labels=none,xticksize=-2pt 0,yticksize=-2pt 0,tickcolor=black!70,Dy=0.05,dy=0.05\psyunit,Dx=1,dx=1\psxunit,Ox=0]{->}(0,0)(-0.9,0)(12,0.35)
1638 \rput(5,0.33){\psframebox[fillstyle=solid,fillcolor=orange!30,linestyle=none]{$n=10$}}
1639 }
1640 \end{pspicture}
1641 \end{LTXexample}
1642
1643 \begin{LTXexample}[pos=t,preset=\centering]
1644 {\psset{xunit=0.07cm,yunit=10cm}%
1645 \begin{pspicture}[showgrid=false](-6,-0.1)(220,1.1)%
1646 \psset{plotpoints=500,arrowscale=1.3,arrowinset=0.05,arrowlength=1.9,comma}
1647 \psaxes[labelFontSize=\scriptstyle,xticksize=0 1,yticksize=0 218,tickcolor=gray!50,Dy=0.05,dy=0.05,Dx=10,dx=10,showorigin=false]{->}(0,0)(219,1.05)
1648 \uput[-90](219,0){$k$} \uput[0](0,1.05){$P(X=k)=B(300;\frac{1}{3};k)$}
1649 \psBinomial[linecolor=Green,fillstyle=solid,fillcolor=cyan,opacity=0.5,printValue=true,markZeros,fontscale=4,xlabelsep=-0.175,LabelColor=Green,labelangle=80,PrintVLimit=0.01]{1,210,300}{1 3 div}%,printValue
1650 \psBinomialF[radiusout=1.3,radiusinR=0.9,linecolor=cyan,leftEnd=4,rightEnd=5,linewidth=0.8pt,LineEndColorR=DeepSkyBlue4,LineEndColorL=DeepSkyBlue4,VLines,printValue,fontscale=4,LabelColor=cyan]{0,230,300}{1 3 div}
1651 \psBinomialFS[radiusout=1.3,radiusinR=0.9,linecolor=red,leftEnd=4,rightEnd=5,linewidth=0.8pt,LineEndColorR=DeepSkyBlue4,LineEndColorL=red,VLines,printValue,fontscale=4,labelangle=50,LabelColor=orange]{0,200,300}{1 3 div}
1652 \end{pspicture}}
1653 \end{LTXexample}
1654
1655 The default binomial distribution has the mean of $\mu=E(X)=N\cdot p$
1656 and a variant of $\sigma^2=\mu\cdot(1-p)$.
1657 The normalized distribution has a mean of $0$. Instead of $P(X=k)$
1658 we use $P(Z=z)$ with $Z=\dfrac{X-E(X)}{\sigma(X)}$ and $P\leftarrow P\cdot\sigma$.
1659 The macros use the recursive definition of the binomial distribution:
1660 %
1661 \begin{align}
1662 P(k) = P(k-1)\cdot\frac{N-k+1}{k}\cdot\frac{p}{1-p}
1663 \end{align}
1664
1665 \begin{LTXexample}[pos=t,preset=\centering]
1666 \psset{xunit=1cm,yunit=5cm}%
1667 \begin{pspicture}(-3,-0.15)(4,0.55)%
1668 \psaxes[Dy=0.2,dy=0.2\psyunit]{->}(0,0)(-3,0)(4,0.5)
1669 \uput[-90](4,0){$z$} \uput[0](0,0.5){$P(Z=z)$}
1670 \psBinomialN[markZeros,fillstyle=vlines]{6}{0.4}
1671 \end{pspicture}
1672 \end{LTXexample}
1673
1674 \begin{LTXexample}[pos=t,preset=\centering]
1675 \psset{yunit=10}
1676 \begin{pspicture*}(-8,-0.07)(8.1,0.55)
1677 \psaxes[Dy=0.2,dy=0.2\psyunit]{->}(0,0)(-8,0)(8,0.5)
1678 \uput[-90](8,0){$z$} \uput[0](0,0.5){$P(Z=z)$}
1679 \psBinomialN{125}{.5}
1680 \psBinomialN[markZeros,linewidth=1pt,linecolor=red]{4}{.5}
1681 \end{pspicture*}
1682 \end{LTXexample}
1683
1684 \begin{LTXexample}[pos=t,preset=\centering]
1685 \psset{yunit=10}
1686 \begin{pspicture*}(-8,-0.07)(8.1,0.52)
1687 \psaxes[Dy=0.2,dy=0.2\psyunit]{->}(0,0)(-8,0)(8,0.5)
1688 \uput[-90](8,0){$z$} \uput[0](0,0.5){$P(Z=z)$}
1689 \psBinomialN[markZeros,linecolor=red]{4}{.5}
1690 \psset{linewidth=1pt}
1691 \psBinomialN[linecolor=green]{5}{.5}\psBinomialN[linecolor=blue]{10}{.5}
1692 \psBinomialN[linecolor=red]{20}{.5} \psBinomialN[linecolor=gray]{50}{.5}
1693 \end{pspicture*}
1694 \end{LTXexample}
1695
1696 For the normalized distribution the plotstyle can be set to \Lkeyval{curve} (\Lkeyset{plotstyle=curve}),
1697 then the binomial distribution looks like a normal distribution. This option is only
1698 valid for \Lcs{psBinomialN}. The option \Lkeyword{showpoints} is valid if \Lkeyval{curve} was chosen.
1699
1700 \begin{LTXexample}[pos=t,preset=\centering]
1701 \psset{xunit=1cm,yunit=10cm}%
1702 \begin{pspicture*}(-4,-0.06)(4.1,0.57)%
1703 \psaxes[Dy=0.2,dy=0.2\psyunit]{->}(0,0)(-4,0)(4,0.5)%
1704 \uput[-90](4,0){$z$} \uput[90](0,0.5){$P(Z=z)$}%
1705 \psBinomialN[linecolor=red,fillstyle=vlines,showpoints=true,markZeros]{36}{0.5}%
1706 \psBinomialN[linecolor=blue,showpoints=true,plotstyle=curve]{36}{0.5}%
1707 \end{pspicture*}
1708 \end{LTXexample}
1709
1710 \begin{LTXexample}[pos=t,preset=\centering]
1711 \psset{xunit=1cm,yunit=10cm}%
1712 \begin{pspicture*}(-4,-0.06)(4.2,0.57)%
1713 \psaxes[Dy=0.2,dy=0.2\psyunit]{->}(0,0)(-4,0)(4,0.5)%
1714 \uput[-90](4,0){$z$} \uput[90](0,0.5){$P(Z=z)$}%
1715 \psBinomialN[linecolor=red]{10}{0.6}%
1716 \psBinomialN[linecolor=blue,showpoints=true,plotstyle=curve]{10}{0.6}%
1717 \end{pspicture*}
1718 \end{LTXexample}
1719
1720
1721
1722 \begin{LTXexample}[pos=t,preset=\centering]
1723 \definecolor{A1}{RGB}{28, 134, 238}
1724 \definecolor{A2}{RGB}{124, 205, 124}
1725 \psset{xunit=4mm,yunit=70cm,arrowscale=1.5}%
1726 \begin{pspicture*}(-2,-0.01)(30,0.25)
1727 \psBinomial[fillstyle=alternateColors,
1728 fillcolorA=A1,fillcolorB=A2,
1729 markZeros]{60}{0.25}
1730 \psaxes[Dx=5,dx=5\psxunit,Dy=0.1,dy=0.1\psyunit,
1731 arrows=D>]{->}(28,0.13)[\Large$k$,-90][\Large$P(X=k)$,0]
1732 \end{pspicture*}%
1733 \end{LTXexample}
1734
1735
1736
1737
1738
1739
1740
1741 \clearpage
1742 \subsection{Poisson distribution}
1743 Given a Poisson process\footnote{\url{http://mathworld.wolfram.com/PoissonProcess.html}},
1744 the probability of obtaining exactly $n$ successes in $N$ trials is given by the
1745 limit of a binomial distribution (see Section~\ref{sec:bindistri})
1746 %
1747 \begin{align}
1748 P_p(n|N) = \frac{N!}{n!(N-n)!}\cdot p^n(1-p)^{N-n}\label{eq:normaldistri}
1749 \end{align}
1750 %
1751 Viewing the distribution as a function of the expected number of successes;
1752 %
1753 \begin{align}\label{eq:nu}
1754 \lambda = N\cdot p
1755 \end{align}
1756 %
1757 instead of the sample size $N$ for fixed $p$, equation (2) then becomes
1758 \eqref{eq:normaldistri};
1759 %
1760 \begin{align}\label{eq:nuN}
1761 P_{\frac{\lambda}{n}}(n|N) = \frac{N!}{n!(N-n)!}{\frac{\lambda}{N}}^n {\frac{1-\lambda}{N}}^{N-n}
1762 \end{align}
1763 %
1764 Viewing the distribution as a function of the expected number of successes;
1765 %
1766 \[ P_\lambda(X=k)=\frac{\lambda^k}{k!}\,e^{-\lambda} \].
1767 %
1768 Letting the sample size become large ($N\to\infty$), the distribution then
1769 approaches (with $p=\frac{\lambda}{n}$):
1770 %
1771 \begin{align}
1772 \lim_{n\to\infty} P(X=k) &= \lim_{n\to\infty}\frac{n!}{(n-k)!\,k!}
1773 \left(\frac{\lambda}{n}\right)^k \left(1-\frac{\lambda}{n}\right)^{n-k} \\
1774 &= \lim_{n\to\infty} \left(\frac{(n-k)!\cdot (n-k+1)\cdots(n-2)(n-1)n}{(n-k)!\,n^k}\right)\cdot\\
1775 &\qquad \left(\frac{\lambda^k}{k!}\right)\left(1-\frac{\lambda}{n}\right)^n
1776 \left(1-\frac{\lambda}{n}\right)^{-k}\\
1777 &= \frac{\lambda^k}{k!}\cdot \lim_{n\to\infty}
1778 \underbrace{\left(\frac{n}{n}\cdot \frac{n-1}{n}\cdot\frac{n-2}{n}\cdot\ldots\cdot
1779 \frac{n-k+1}{n}\right)}_{\to 1} \cdot\\
1780 &\qquad \underbrace{\left(1-\frac{\lambda}{n}\right)^n}_{\to{e^{-\lambda}}}
1781 \underbrace{\left(1-\frac{\lambda}{n}\right)^{-k}}_{\to 1}\\
1782 &= \lambda^k e^{\frac{-\lambda}{k!}}
1783 \end{align}
1784 %
1785 which is known as the Poisson distribution and has the follwing syntax:
1786
1787 \begin{BDef}
1788 \Lcs{psPoisson}\OptArgs\Largb{N}\Largb{lambda}\\
1789 \Lcs{psPoisson}\OptArgs\Largb{M,N}\Largb{lambda}
1790 \end{BDef}
1791
1792 in which \texttt{M} is an optional argument with a default of 0.
1793
1794 \begin{LTXexample}[pos=t,preset=\centering]
1795 \psset{xunit=1cm,yunit=20cm}%
1796 \begin{pspicture}(-1,-0.05)(14,0.25)%
1797 \uput[-90](14,0){$k$} \uput[90](0,0.2){$P(X=k)$}
1798 \psPoisson[linecolor=red,markZeros,fillstyle=solid,
1799 fillcolor=blue!10,printValue,valuewidth=20]{13}{6} % N lambda
1800 \psaxes[Dy=0.1,dy=0.1\psyunit]{->}(0,0)(-1,0)(14,0.2)
1801 \end{pspicture}
1802 \end{LTXexample}
1803
1804 \begin{LTXexample}[pos=t,preset=\centering]
1805 \psset{xunit=1cm,yunit=20cm}%
1806 \begin{pspicture}(-1,-0.05)(14,0.25)%
1807 \uput[-90](14,0){$k$} \uput[90](0,0.2){$P(X=k)$}
1808 \psPoisson[linecolor=blue,markZeros,fillstyle=solid,barwidth=0.4,
1809 fillcolor=blue!10,printValue,valuewidth=20]{10}{6} % N lambda
1810 \psaxes[Dy=0.1,dy=0.1\psyunit]{->}(0,0)(-1,0)(11,0.2)
1811 \end{pspicture}
1812 \end{LTXexample}
1813
1814 \begin{LTXexample}[pos=t,preset=\centering]
1815 \psset{xunit=1cm,yunit=20cm}%
1816 \begin{pspicture}(-1,-0.05)(14,0.25)%
1817 \uput[-90](14,0){$k$} \uput[90](0,0.2){$P(X=k)$}
1818 \psPoisson[printValue,valuewidth=20]{2,11}{6} % M,N lambda
1819 \psaxes[Dy=0.1,dy=0.1\psyunit]{->}(0,0)(-1,0)(14,0.2)
1820 \end{pspicture}
1821 \end{LTXexample}
1822
1823 \clearpage
1824 \subsection{Gamma distribution}
1825 A gamma distribution is a general type of statistical distribution that is related
1826 to the beta distribution and arises naturally in processes for which the waiting
1827 times between Poisson distributed events are relevant. Gamma distributions have
1828 two free parameters, labeled $\alpha$ and $\beta$. It is defined as
1829 %
1830 \[
1831 f(x)=\frac{\beta(\beta x)^{\alpha-1}e^{-\beta x}}{\Gamma(\alpha)} \qquad
1832 \text{for $x>0$ and $\alpha$, $\beta>0$}
1833 \]
1834 %
1835 and has the syntax
1836
1837 \begin{BDef}
1838 \Lcs{psGammaDist}\OptArgs\Largb{x0}\Largb{x1}
1839 \end{BDef}
1840
1841 \begin{LTXexample}[pos=t,preset=\centering]
1842 \psset{xunit=1.2cm,yunit=10cm,plotpoints=200}
1843 \begin{pspicture*}(-0.75,-0.05)(9.5,0.6)
1844 \psGammaDist[linewidth=1pt,linecolor=red]{0.01}{9}
1845 \psGammaDist[linewidth=1pt,linecolor=blue,alpha=0.3,beta=0.7]{0.01}{9}
1846 \psaxes[Dy=0.1]{->}(0,0)(9.5,.6)
1847 \end{pspicture*}
1848 \end{LTXexample}
1849
1850 \clearpage
1851 %\subsection{$\chi^2$-distribution}
1852 The $\chi^2$-distribution is a continuous probability distribution. It
1853 usually arises when a $k$-dimensional vector's orthogonal components are
1854 independent and each follow a standard normal distribution.
1855 The length of the vector will then have a $\chi^2$-distribution.
1856
1857 \iffalse
1858 If Y_i have normal independent distributions with mean 0 and variance 1, then
1859 chi^2=sum_(i==1)^rY_i^2
1860 (1)
1861
1862 is distributed as chi^2 with r degrees of freedom. This makes a chi^2 distribution
1863 a gamma distribution with theta=2 and alpha=r/2, where r is the number of degrees of freedom.
1864
1865 More generally, if chi_i^2 are independently distributed according to a chi^2
1866 distribution with r_1, r_2, ..., r_k degrees of freedom, then
1867 sum_(j==1)^kchi_j^2
1868
1869 is distributed according to chi^2 with r=sum_(j==1)^(k)r_j degrees of freedom.
1870 \fi
1871
1872 The $\chi^2$ with parameter $\nu$ is the same as a Gamma distribution
1873 with $\alpha=\nu/2$ and $\beta=1/2$ and the syntax
1874
1875 \begin{BDef}
1876 \Lcs{psChiIIDist}\OptArgs\Largb{x0}\Largb{x1}
1877 \end{BDef}
1878
1879 \begin{LTXexample}[pos=t,preset=\centering]
1880 \psset{xunit=1.2cm,yunit=10cm,plotpoints=200}
1881 \begin{pspicture*}(-0.75,-0.05)(9.5,.65)
1882 \multido{\rnue=0.5+0.5,\iblue=0+10}{10}{%
1883 \psChiIIDist[linewidth=1pt,linecolor=blue!\iblue,nue=\rnue]{0.01}{9}}
1884 \psaxes[Dy=0.1]{->}(0,0)(9.5,.6)
1885 \end{pspicture*}
1886 \end{LTXexample}
1887
1888 \iffalse
1889 The cumulative distribution function is
1890 %
1891 \begin{align*}
1892 D_r(\chi^2) &= int_0^{\chi^2}\frac{t^{r/2-1}e^{-t/2}\mathrm{d}t}{\Gamma(1/2r)2^{r/2}\\
1893 &= 1-\frac{\Gamma(1/2r,1/2\chi^2)}{\Gamma(1/2r)}
1894 \end{align*}
1895 \fi
1896
1897 \clearpage
1898 \subsection{Student's $t$-distribution}
1899
1900 A \Index{statistical distribution} published by \Index{William Gosset} in 1908
1901 under his pseudonym ``Student''. The $t$-distribution with parameter $\nu$ has
1902 the \Index{density function}
1903 %
1904 \[
1905 f(x)=\frac1{\sqrt{\nu\pi}}\cdot
1906 \frac{\Gamma[(\nu+1)/2]}{\Gamma(\nu/2)}\cdot\frac1{[1+(x^2/\nu)]^{(\nu+1)/2}} \qquad
1907 \text{for $-\infty<x<\infty$ and $\nu>0$}
1908 \]
1909 %
1910 and the following syntax
1911
1912 \begin{BDef}
1913 \Lcs{psTDist}\OptArgs\Largb{x0}\Largb{x1}
1914 \end{BDef}
1915
1916 \begin{LTXexample}[pos=t,preset=\centering]
1917 \psset{xunit=1.25cm,yunit=10cm}
1918 \begin{pspicture}(-6,-0.1)(6,.5)
1919 \psaxes[Dy=0.1]{->}(0,0)(-4.5,0)(5.5,0.5)
1920 \psset{linewidth=1pt,plotpoints=100}
1921 \psGauss[mue=0,sigma=1]{-4.5}{4.5}
1922 \psTDist[linecolor=blue]{-4}{4}
1923 \psTDist[linecolor=red,nue=4]{-4}{4}
1924 \end{pspicture}
1925 \end{LTXexample}
1926
1927 %The $t_\nu$-distribution has mode 0.
1928
1929 \subsection{Student's noncentral $t$-distribution}
1930
1931
1932 A generalization of Student's t-distribution known as the noncentral Student's t-distribution is given by
1933
1934 \[
1935 P(x)=\frac{\nu^{\nu/2}\nu!}{2^{\nu}e^{\lambda^2/2}(\nu+x^2)^{\nu/2}\Gamma(\frac12\nu)}
1936 \left\{
1937 \frac{\sqrt{2}\lambda x\, {}_1F_1\left(\frac12 \nu+1;\, \frac32; \,\frac{\lambda^2x^2}{2(\nu+x^2)}\right)}
1938 {(\nu+x^2)\Gamma[\frac12(\nu+1)]}
1939 + \frac{{}_1F_1\left(\frac12(\nu+1);\, \frac12; \, \frac{\lambda^2x^2}{2(\nu+x^2)}\right)}{\sqrt{\nu+x^2}\Gamma(\frac12\nu+1)}\right\}
1940 \]
1941
1942 where $\Gamma(z)$ is the gamma function and ${}_1F_1(a;b;z)$ is a confluent hypergeometric function of the first kind.~\parencite{weisstein}
1943
1944
1945 \[ {}_1F_1(a;b;z) = 1+\frac ab z + \frac{a(a+1)}{b(b+1)} \frac{z^2}{2!}+ \cdots=\sum_{k=0}^\infty\frac{(a)_k}{(b)_k} \frac{z^k}{k!} \]
1946
1947
1948 %mu = lambdasqrt(n/2)(Gamma(1/2(n-1)))/(Gamma(1/2n))
1949 %sigma^2 = ((lambda^2+1)n)/(n-2)-(lambda^2n[Gamma(1/2(n-1))]^2)/(2[Gamma(1/2n)]^2).
1950
1951 The macro has the same syntax as the centered Student's distribution:
1952
1953 \begin{BDef}
1954 \Lcs{psNonCentralTDist}\OptArgs\Largb{x0}\Largb{x1}
1955 \end{BDef}
1956
1957
1958 There exists an additional optional parameter \Lkeyword{lambda}, which is preset to 0.5.
1959
1960
1961 \begin{LTXexample}[pos=t,preset=\centering]
1962 \psset{xunit=0.75cm,yunit=10cm}
1963 \begin{pspicture}(-6,-0.1)(11,.5)
1964 \psaxes[Dy=0.1]{->}(0,0)(-4.5,0)(10,0.5)
1965 \psset{linewidth=1pt,plotpoints=100}
1966 \psNonCentralTDist[linecolor=red,lambda=0,nue=1]{-5}{10}% same as \psTDist
1967 \psNonCentralTDist[linecolor=green,lambda=0,nue=4]{-5}{10}% dito
1968 \psNonCentralTDist[linecolor=red,lambda=2,nue=1]{-5}{10}
1969 \psNonCentralTDist[linecolor=green,lambda=2,nue=4]{-5}{10}
1970 \end{pspicture}
1971 \end{LTXexample}
1972
1973
1974
1975
1976
1977 \begin{LTXexample}[pos=t,preset=\centering]
1978 \psset{xunit=1.25cm,yunit=10cm}
1979 \begin{pspicture}(-6,-0.1)(6,.5)
1980 \psaxes[Dy=0.1]{->}(0,0)(-4.5,0)(5.5,0.5)
1981 \psset{linewidth=1pt,plotpoints=100}
1982 \psTDist[linecolor=blue]{-4}{4}
1983 \psNonCentralTDist[linecolor=red]{-4}{5}
1984 \psNonCentralTDist[linecolor=green,nue=4,lambda=2]{-4}{5}
1985 \end{pspicture}
1986 \end{LTXexample}
1987
1988
1989
1990
1991
1992
1993 \clearpage
1994 \subsection{$F$-distribution}
1995 A continuous statistical distribution which arises in the testing of
1996 whether two observed samples have the same variance.
1997
1998 The $F$-distribution with parameters $\mu$ and $\nu$ has the probability function
1999 \[
2000 f_{\mu,\nu}(x)=\frac{\Gamma[(\mu+\nu)/2]}{\Gamma(\mu/2)\Gamma(\nu/2)}\cdot
2001 \left(\mu/\nu\right)^{\mu/2}\frac{x^{(\mu/2)-1}}{[1+(\mu x/\nu)]^{(\mu+\nu)/2}}\quad
2002 \text{ for $x>0$ and $\mu$, $\nu>0$}\]
2003 %
2004 and the syntax
2005
2006 \begin{BDef}
2007 \Lcs{psFDist}\OptArgs\Largb{x0}\Largb{x1}
2008 \end{BDef}
2009 %
2010 The default settings are $\mu=1$ and $\nu=1$.
2011
2012 \begin{LTXexample}[pos=t,preset=\centering]
2013 \psset{xunit=2cm,yunit=10cm,plotpoints=100}
2014 \begin{pspicture*}(-0.5,-0.07)(5.5,0.8)
2015 \psline[linestyle=dashed](0.5,0)(0.5,0.75)
2016 \psline[linestyle=dashed](! 2 7 div 0)(! 2 7 div 0.75)
2017 \psset{linewidth=1pt}
2018 \psFDist{0.1}{5}
2019 \psFDist[linecolor=red,nue=3,mue=12]{0.01}{5}
2020 \psFDist[linecolor=blue,nue=12,mue=3]{0.01}{5}
2021 \psaxes[Dy=0.1]{->}(0,0)(5,0.75)
2022 \end{pspicture*}
2023 \end{LTXexample}
2024
2025 \clearpage
2026
2027 \subsection{Noncentral $F$-distribution}
2028
2029 The noncentral F-distribution is given by
2030
2031
2032 \begin{align}
2033 P(x)=\sum\limits_{k=0}^{\infty}{\frac{e^{-\lambda/2}(\lambda/2)^{k}}
2034 {B\left({\frac {\nu_{2}}{2}},{\frac {\nu _{1}}{2}}+k\right)k!}}
2035 \left({\frac {\nu _{1}}{\nu _{2}}}\right)^{{\frac {\nu _{1}}{2}}+k}
2036 \left({\frac {\nu _{2}}{\nu_{2}
2037 +\nu _{1}f}}\right)^{{\frac{\nu_{1}
2038 +\nu _{2}}{2}}+k}x^{\nu_{1}/2-1+k}
2039 \end{align}
2040
2041
2042 \iffalse
2043 \begin{align}
2044 P(x) &= e^\frac{\frac{-\lambda}2+(\lambda n_1x)}{2(n_2+n_1x)}
2045 n_1^{\frac{n_1}2} n_2^{\frac{n_2}2} x^{\frac{n_1}2-1}
2046 (n_2+n_1x)^{\frac{-(n_1+n_2)}2}
2047 \frac{\Gamma(\frac12 n_1)\Gamma\left(1+\frac12 n_2\right)
2048 \mathop{L}_\frac{n_2}2^{\frac{n_1}2-1}\left(-\frac{\lambda n_1 x}{2(n_2+n_1x)}\right)}
2049 {B\left(\frac12 n_1,\frac12 n_2\right)\Gamma\left(\frac12 (n_1+n_2)\right)}
2050 \\
2051 &= \frac1{B\left(\frac12 n_1,\frac12 n_2\right)}
2052 \left(
2053 e^{\frac\lambda2}n_1^{\frac{n_1}2} n_2^{\frac{n_2}2} x^{\frac{n_1}2-1}
2054 (n_2+n_1x)^{\frac{-(n_1+n_2)}2}
2055 {}_1F_1\left( \frac12(n_1+n_2); \, \frac12n_1; \, \frac{\lambda n_1 x}{2(n_2+n_1x)} \right)
2056 \right)
2057 \end{align}
2058
2059
2060 %(e^(lambda/2)x^(n_1/2-1)(xn_1+n_2)^(-(n_1+n_2)/2)n_1^(n_1/2)n_2^(n_2/2)_1F_1(1/2(n_1+n_2);1/2n_1;(xlambdan_1)/(2(xn_1+n_2)))),
2061 %\]
2062
2063 \fi
2064
2065
2066 where %$\Gamma(z)$ is the gamma function,
2067 $B(\alpha,\beta)$ is the beta function
2068
2069 \begin{align}
2070 B(p,q) &= \frac{\Gamma(p)\Gamma(q)}{\Gamma(p+q)}\\
2071 &= \frac{(p-1)!(q-1)!}{(p+q-1)!}
2072 \end{align}
2073
2074 \iffalse
2075 and $L_m^n(z)$ is a generalized Laguerre polynomial.
2076
2077 \begin{align}
2078 % L_n(x) &= \sum_{k=0}^n \frac{(-1)^k}{k!} \binom{n}{k} x^k \\
2079 L_n^{k(x)} &= \frac{e^xx^{-k}}{n!} \frac{d^n}{dx^n} e^{-x}x^{n+k} \\
2080 &= (-1)^k \frac{d^k}{dx^k} L_{n+k}(x)\\
2081 &= \frac{(-1)^nx^(-(k+1)/2)}{n!} e^\frac x2 W_{\frac k2+n+\frac12, \frac k2}(x)\\
2082 &= \sum_{m=0}^n(-1)^m \frac{(n+k)!}{(n-m)!(k+m)!m!}x^m
2083 \end{align}
2084
2085 where $W_{k,m}(x)$ is a Whittaker function.
2086
2087 \fi
2088
2089
2090
2091 \begin{BDef}
2092 \Lcs{psNonCentralFDist}\OptArgs\Largb{x0}\Largb{x1}
2093 \end{BDef}
2094 %
2095 The default settings are $\mu=1$, $\nu=1$ and $\lambda=0$, which is the same as the default F-distribution.
2096
2097 \begin{LTXexample}[pos=t,preset=\centering]
2098 \psset{xunit=1cm,yunit=10cm}
2099 \begin{pspicture*}(-2,-0.02)(10.5,1.1)
2100 \psset{linewidth=1pt}
2101 % \psFDist[linecolor=blue,mue=5,nue=20,lambda=0]{0.01}{5}
2102 \psaxes[Dy=0.1]{->}(0,0)(10,1)
2103 \psFDist[linecolor=red,mue=5,nue=20]{0.01}{10}
2104 \psNonCentralFDist[linecolor=green,mue=5,nue=20,lambda=1.6]{0.01}{10}
2105 \end{pspicture*}
2106 \end{LTXexample}
2107
2108
2109 \begin{LTXexample}[pos=t,preset=\centering]
2110 \psset{xunit=2cm,yunit=10cm,plotpoints=100}
2111 \begin{pspicture*}(-0.5,-0.07)(5.5,0.8)
2112 \psline[linestyle=dashed](0.5,0)(0.5,0.75)
2113 \psline[linestyle=dashed](! 2 7 div 0)(! 2 7 div 0.75)
2114 \psset{linewidth=1pt}
2115 \psFDist{0.1}{5}
2116 \psFDist[linecolor=red,mue=5,nue=20]{0.01}{5}
2117 \psNonCentralFDist[linecolor=green,mue=5,nue=20,lambda=1.6]{0.01}{5}
2118 \psNonCentralFDist[linecolor=blue,nue=5,mue=20,lambda=1.6]{0.01}{5}
2119 \psFDist[linecolor=blue,mue=12,nue=3]{0.01}{5}
2120 \psNonCentralFDist[linecolor=green,mue=12,nue=3,lambda=1.6]{0.01}{5}
2121 \psaxes[Dy=0.1]{->}(0,0)(5,0.75)
2122 \end{pspicture*}
2123 \end{LTXexample}
2124
2125
2126
2127
2128
2129 \clearpage
2130
2131 \subsection{Beta distribution}
2132
2133 A general type of statistical distribution which is related to the gamma distribution.
2134 Beta distributions have two free parameters, which are labeled according to one of two
2135 notational conventions. The usual definition calls these $\alpha$ and $\beta$, and the other
2136 uses $\beta^\prime=\beta-1$ and $\alpha^\prime=\alpha-1$. The beta distribution is
2137 used as a prior distribution for binomial proportions in \Index{Bayesian analysis}.
2138 %
2139 %The plots are for various values of ($\alpha,\beta$) with $\alpha=1$ and $\beta$ ranging from 0.25 to 3.00.
2140 %
2141 The domain is $[0,1]$, and the probability function $P(x)$ is given by
2142 %
2143 \[
2144 P(x) = \frac{\Gamma(\alpha+\beta)}{\Gamma(\alpha)\Gamma(\beta)}(1-x)^{\beta-1}x^{\alpha-1}
2145 \quad\text{ $\alpha,\beta>0$}
2146 \]
2147 %
2148 and has the syntax (with a default setting of $\alpha=1$ and $\beta=1$):
2149
2150 \begin{BDef}
2151 \Lcs{psBetaDist}\OptArgs\Largb{x0}\Largb{x1}
2152 \end{BDef}
2153 %
2154 \begin{LTXexample}[pos=t,preset=\centering]
2155 \psset{xunit=10cm,yunit=5cm}
2156 \begin{pspicture*}(-0.1,-0.1)(1.1,2.05)
2157 \psset{linewidth=1pt}
2158 \multido{\rbeta=0.25+0.25,\ired=0+5,\rblue=50.0+-2.5}{20}{%
2159 \psBetaDist[beta=\rbeta,linecolor=red!\ired!blue!\rblue]{0.01}{0.99}}
2160 \psaxes[Dy=0.2,Dx=0.1]{->}(0,0)(1,2.01)
2161 \end{pspicture*}
2162 \end{LTXexample}
2163
2164 \clearpage
2165 \subsection{Cauchy distribution}
2166 The \Index{Cauchy distribution}, also called the \Index{Lorentz distribution}, is a continuous distribution
2167 describing resonance behavior. It also describes the distribution of horizontal distances at
2168 which a line segment tilted at a random angle cuts the $x$-axis.
2169
2170 The general Cauchy distribution and its cumulative distribution can be written as
2171 \begin{align}
2172 P(x) &= \frac{1}{\pi} \frac{b}{\left(x-m\right)^2+b^2}\\
2173 D(x) &= \frac12 +\frac{1}{\pi} \arctan\left(\frac{x-m}{b}\right)
2174 \end{align}
2175
2176 where \Lkeyword{b} is the half width at half maximum and \Lkeyword{m} is the statistical median.
2177 The macro has the syntax (with a default setting of $m=0$ and $b=1$):
2178
2179 \begin{BDef}
2180 \Lcs{psCauchy}\OptArgs\Largb{x0}\Largb{x1}\\
2181 \Lcs{psCauchyI}\OptArgs\Largb{x0}\Largb{x1}\\
2182 \end{BDef}
2183
2184 \Lcs{psCauchyI} is the integral or the cumulative distribution and often named as $D(x)$.
2185
2186 \begin{LTXexample}[pos=t,preset=\centering]
2187 \psset{xunit=2,yunit=3cm}
2188 \begin{pspicture*}(-3,-0.3)(3.1,2.1)
2189 \psset{linewidth=1pt}
2190 \multido{\rb=0.1+0.2,\rm=0.0+0.2}{4}{%
2191 \psCauchy[b=\rb,m=\rm,linecolor=red]{-2.5}{2.5}
2192 \psCauchyI[b=\rb,m=\rm,linecolor=blue]{-2.5}{2.5}}
2193 \psaxes[Dy=0.4,dy=0.4,Dx=0.5,dx=0.5]{->}(0,0)(-3,0)(3,2)
2194 \end{pspicture*}
2195 \end{LTXexample}
2196 \iffalse
2197
2198 \clearpage
2199 \subsection{Bose-Einstein distribution}
2200 A distribution which arises in the study of integer \Index{spin particles} in physics,
2201 \[
2202 P(x)=\frac{x^s}{e^{x-\mu}-1}\qquad\text{with $s\in\mathbb{Z}$ and $\mu\in\mathbb{R}$}
2203 \]
2204 %$
2205 and has the syntax (with a default setting of $s=1$ and $\mu=1$):
2206
2207 \begin{BDef}
2208 \Lcs{psBoseEinsteinDist}\OptArgs\Largb{x0}\Largb{x1}
2209 \end{BDef}
2210 \fi
2211
2212 \clearpage
2213 \subsection{Weibull distribution}
2214 In probability theory and statistics, the Weibull distribution is a continuous probability
2215 distribution. The probability density function of a Weibull random variable $x$ is:
2216
2217 \begin{align}
2218 P(x) &= \alpha\beta^{-\alpha} x^{\alpha-1} e^{-\left(\frac{x}{\beta}\right)^\alpha}\\
2219 D(x) &= 1-e^{-\left(\frac{x}{\beta}\right)^\alpha}
2220 \end{align}
2221
2222 or slightly different as
2223
2224 \begin{align}
2225 P(x) &= \frac{\alpha}{\beta}\,x^{\alpha-1} e^{-\frac{x^\alpha}{\beta}}\\
2226 D(x) &= 1 - e^{-\frac{x^\alpha}{\beta}}
2227 \end{align}
2228
2229 always for $x\in[0;\infty)$, where $\alpha > 0$ is the shape parameter
2230 and $\beta > 0$ is the scale parameter of the distribution.
2231
2232 $D(x)$ is the cumulative distribution function of the Weibull distribution. The values for
2233 $\alpha$ and $\beta$ are preset to 1, but can be changed in the usual way.
2234
2235 The Weibull distribution is related to a number of other probability distributions; in
2236 particular, it interpolates between the exponential distribution $(\alpha = 1)$ and
2237 the Rayleigh distribution $(\alpha = 2)$.
2238
2239 \begin{center}
2240 \psset{unit=2}
2241 \begin{pspicture*}(-0.5,-0.5)(2.6,2.6)
2242 \psaxes{->}(0,0)(2.5,2.5)[$x$,-90][$y$,180]
2243 \multido{\rAlpha=0.5+0.5}{5}{%
2244 \psWeibull[alpha=\rAlpha]{0}{2.5}
2245 \psWeibullI[alpha=\rAlpha,linestyle=dashed]{0}{2.4}}
2246 \end{pspicture*}
2247 %
2248 \begin{pspicture*}(-0.5,-0.5)(2.6,2.6)
2249 \psaxes{->}(0,0)(2.5,2.5)[$x$,-90][$y$,180]
2250 \multido{\rAlpha=0.5+0.5,\rBeta=0.2+0.2}{5}{%
2251 \psWeibull[alpha=\rAlpha,beta=\rBeta]{0}{2.5}
2252 \psWeibullI[alpha=\rAlpha,beta=\rBeta,linestyle=dashed]{0}{2.4}}
2253 \end{pspicture*}
2254 \end{center}
2255
2256 \begin{lstlisting}
2257 \psset{unit=2}
2258 \begin{pspicture*}(-0.5,-0.5)(2.6,2.6)
2259 \psaxes{->}(0,0)(2.5,2.5)[$x$,-90][$y$,180]
2260 \multido{\rAlpha=0.5+0.5}{5}{%
2261 \psWeibull[alpha=\rAlpha]{0}{2.5}
2262 \psWeibullI[alpha=\rAlpha,linestyle=dashed]{0}{2.4}}
2263 \end{pspicture*}
2264 %
2265 \begin{pspicture*}(-0.5,-0.5)(2.6,2.6)
2266 \psaxes{->}(0,0)(2.5,2.5)[$x$,-90][$y$,180]
2267 \multido{\rAlpha=0.5+0.5,\rBeta=0.2+0.2}{5}{%
2268 \psWeibull[alpha=\rAlpha,beta=\rBeta]{0}{2.5}
2269 \psWeibullI[alpha=\rAlpha,beta=\rBeta,linestyle=dashed]{0}{2.4}}
2270 \end{pspicture*}
2271 \end{lstlisting}
2272 \psset{unit=1cm}
2273
2274 The starting value for $x$ should always be 0 or greater, if it is
2275 less than 0 then the macro draws a line from (\#1,0) to (0,0) and
2276 starts \Lcs{psWeinbull} with 0.
2277
2278 \clearpage
2279 \subsection{Vasicek distribution}
2280
2281 For a homogenous portfolio of infinite granularity the portfolio loss
2282 distribution is given by
2283 \[
2284 \mathbb{P}(L(P)<x)=1-\mathcal{N}
2285 \left(\frac{\mathcal{N}^{-1}(PD)-\sqrt{1-R2}\cdot\mathcal{N}^{-1}(x)}{R}
2286 \right)
2287 \]
2288 $L(P)$ denotes the portfolio loss in percent, $pd$ is the uniform default
2289 probability, and $R2$ is the uniform asset correlation.
2290
2291 They are preset to $pd=0.22$ and $R2=0.11$ and can be overwritten in the
2292 usual way. The macro uses the PostScript function norminv from the package
2293 \LPack{pst-math} which is loaded by default and also shown in the following
2294 example.
2295
2296 \begin{LTXexample}[pos=t]
2297 \psset{xunit=5}
2298 \begin{pspicture}(-0.1,-3)(1.1,4)
2299 \psaxes{->}(0,0)(0,-3)(1.1,4)
2300 \psVasicek[plotpoints=200,linecolor=blue]{0}{0.9999}
2301 \psVasicek[plotpoints=200,linecolor=red,pd=0.2,R2=0.3]{0}{0.9999}
2302 \psplot[plotpoints=200,algebraic,linestyle=dashed]{0}{0.9999}{norminv(x)}
2303 \end{pspicture}
2304 \end{LTXexample}
2305
2306 \clearpage
2307 \section{Special Functions}
2308 \subsection{\nxLcs{psLorenz} -- Lorenz curve}
2309 The so-called \Index{Lorenz curve} is used in economics to describe inequality in
2310 wealth or size. The Lorenz curve is a function of the cumulative proportion of
2311 \textit{ordered individuals} mapped onto the corresponding cumulative proportion
2312 of their size. Given a sample of $n^{\textup{th}}$ ordered individuals with
2313 $x_i^{\prime}$ the size of individual $i$ and $x_1^{\prime}<x_2^{\prime}<\cdots<x_n^{\prime}$,
2314 then the sample Lorenz curve is the \textit{polygon} joining the points $(h/n,L_h/L_n)$,
2315 where $h=0, 1, 2,\ldots n, L_0=0$ and $L_h=\sum_{i=1}^h x_i^{\prime}$.
2316
2317 \begin{BDef}
2318 \LcsStar{psLorenz}\OptArgs\OptArg*{<X data>}\Largb{Y data}
2319 \end{BDef}
2320
2321
2322 Without defining data for the x values the Y data will be sorted
2323 and then printed over the relativ x values. For example: 5 y values
2324 will be printed for $x\in[0, 0.2, 0.4, 0.6, 0.8, 1]$
2325
2326
2327 \begin{LTXexample}[pos=t,preset=\centering]
2328 \psset{lly=-6mm,llx=-5mm}
2329 \psgraph[Dx=0.2,Dy=0.2,axesstyle=frame](0,0)(1,1){6cm}{6cm}
2330 \psline[linestyle=dashed](1,1)
2331 \psLorenz*[linecolor=blue!30,linewidth=1.5pt]{0.50 0.10 0.3 0.09 0.01 }
2332 \psLorenz[linecolor=blue!30,plotstyle=bezier]{0.50 0.10 0.3 0.09 0.01 }
2333 \psLorenz[linecolor=red,linewidth=1.5pt]{0.50 0.10 0.3 0.09 0.01 }
2334 \endpsgraph
2335 \end{LTXexample}
2336
2337
2338
2339 \begin{LTXexample}[pos=t,preset=\centering]
2340 \psset{lly=-6mm,llx=-5mm}
2341 \psgraph[Dx=0.2,Dy=0.2,axesstyle=frame](0,0)(1,1){6cm}{6cm}
2342 \psline[linestyle=dashed](1,1)
2343 \psLorenz[linecolor=blue!30,linewidth=1.5pt,showpoints]{1 4 6 9 100}
2344 \psLorenz[linecolor=red!60,linewidth=1.5pt,showpoints]<83 104 134 143 185>{460 343 406 501 1662}
2345 \psLorenz[linecolor=green,linewidth=1.5pt]{0 0.577 0.934 0.947 0.969 0.986}
2346 \endpsgraph
2347 \end{LTXexample}
2348
2349 There exists an optional argument \Lkeyword{Gini} for the output of the \Index{Gini coefficient}.
2350 It is by default set to \false. With \true\ the value is caculated and printed below the
2351 origin of the coordinate system.
2352
2353 \begin{LTXexample}[pos=t,preset=\centering]
2354 \psset{lly=-13mm,llx=-5mm}
2355 \psgraph[Dx=0.2,Dy=0.2,axesstyle=frame](0,0)(1,1){6cm}{6cm}
2356 \psline[linestyle=dashed](1,1)
2357 \psLorenz[linewidth=1.5pt,Gini]<83 104 134 143 185>{460 343 406 501 1662}
2358 \psLorenz[plotstyle=dots,dotstyle=square,dotscale=1.5]<83 104 134 143 185>{460 343 406 501 1662}
2359 \endpsgraph
2360 \end{LTXexample}
2361
2362
2363 \begin{LTXexample}[pos=t,preset=\centering]
2364 \psset{lly=-13mm,llx=-5mm}
2365 \psgraph[Dx=0.2,Dy=0.2,axesstyle=frame](0,0)(1,1){6cm}{6cm}
2366 \psline[linestyle=dashed](1,1)
2367 \psLorenz[Gini,linecolor=red,linewidth=1.5pt]<.2 .2 .2 .2 .2>{.1 .1 .1 .35 .35 }
2368 \psLorenz[Gini,linecolor=blue,linestyle=dashed,linewidth=1.5pt]{.1 .1 .1 .35 .35 }
2369 \endpsgraph
2370 \end{LTXexample}
2371
2372
2373
2374
2375
2376
2377 \clearpage
2378 \subsection{\nxLcs{psLame} -- Lam\'e Curve, a superellipse}
2379 A superellipse is a curve with Cartesian equation
2380 %
2381 \begin{align}
2382 \left|\frac{x}{a}\right|^r + \left|\frac{y}{b}\right|^r =1
2383 \end{align}
2384 %
2385 first discussed in 1818 by Gabriel Lam\'e (1795--1870)%
2386 \footnote{Lam\'e worked on a wide variety of different topics.
2387 His work on differential geometry and contributions to Fermat's Last Theorem
2388 are important. He proved the theorem for $n = 7$ in 1839.}.
2389 A superellipse may be described parametrically by
2390 %
2391 \begin{align}
2392 x &= a\cdot\cos^{\frac{2}{r}} t\\
2393 y &= b\cdot\sin^{\frac{2}{r}} t
2394 \end{align}
2395 %
2396 \Index{Superellipses} with $a=b$ are also known as \Index{Lam\'e} curves
2397 or Lam\'e ovals and the restriction to $r>2$ is sometimes also made.
2398 The following table summarizes a few special cases.
2399 \Index{Piet Hein} used $\frac{5}{2}$ with a number of different
2400 $\frac{a}{b}$ ratios for various of his projects.
2401 For example, he used $\frac{a}{b}=\frac{6}{5}$ for Sergels Torg
2402 (Sergel's Square) in Stockholm, and $\frac{a}{b}=\frac{3}{2}$ for his table.
2403
2404 \begin{center}
2405 \begin{tabular}{@{}llm{1.5cm}@{}}
2406 r & curve type & example\\\hline
2407 $\frac{2}{3}$ & (squashed) astroid
2408 & \pspicture(-.5,-.5)(.5,.5)\psLame[radiusA=.5,radiusB=.5]{0.6667}\endpspicture\\
2409 1 & (squashed) diamond
2410 & \pspicture(-.5,-.5)(.5,.5)\psLame[radiusA=.5,radiusB=.5]{1}\endpspicture\\
2411 2 & ellipse
2412 & \pspicture(-.5,-.5)(.5,.5)\psLame[radiusA=.5,radiusB=.5]{2}\endpspicture\\
2413 $\frac{5}{2}$ & Piet Hein's ,,superellipse``
2414 & \pspicture(-.5,-.5)(.5,.5)\psLame[radiusA=.5,radiusB=.5]{2.5}\endpspicture
2415 \end{tabular}
2416 \end{center}
2417
2418 If $r$ is a rational, then a \Index{superellipse} is algebraic. However, for irrational $r$,
2419 it is transcendental. For even integers $r=n$, the curve becomes closer to a
2420 rectangle as $n$ increases. The syntax of the \Lcs{psLame} macro is:
2421
2422 \begin{BDef}
2423 \Lcs{psLame}\OptArgs\Largb{r}
2424 \end{BDef}
2425
2426 It is internally plotted as a \Index{parametric plot} with $0\le\alpha\le360$. Available keywords
2427 are \Lkeyword{radiusA} and \Lkeyword{radiusB}, both are preset to 1, but can have any valid value
2428 and unit.
2429
2430 \bgroup
2431 \begin{LTXexample}[pos=t,preset=\centering]
2432 \definecolorseries{col}{rgb}{last}{red}{blue}
2433 \resetcolorseries[41]{col}
2434 \psset{unit=.5}
2435 \pspicture(-9,-9)(9,9)
2436 \psaxes[Dx=2,Dy=2,tickstyle=bottom,ticksize=2pt]{->}(0,0)(-9,-9)(9,9)
2437 \multido{\rA=0.2+0.1,\iA=0+1}{40}{%
2438 \psLame[radiusA=8,radiusB=7,linecolor={col!![\iA]},linewidth=.5pt]{\rA}}
2439 \endpspicture
2440 \end{LTXexample}
2441 \egroup
2442
2443
2444
2445
2446 \bgroup
2447 \begin{LTXexample}[pos=t,preset=\centering]
2448 \definecolorseries{col}{rgb}{last}{red}{blue}
2449 \resetcolorseries[41]{col}
2450 \psset{unit=.5}
2451 \pspicture(-9,-9)(9,9)
2452 \psaxes[Dx=2,Dy=2,tickstyle=bottom,ticksize=2pt]{->}(0,0)(-9,-9)(9,9)
2453 \multido{\rA=0.2+0.1,\iA=0+1}{40}{%
2454 \psLame[radiusA=8,radiusB=7,startAngle=45,endAngle=315,
2455 linecolor={col!![\iA]},linewidth=.5pt]{\rA}}
2456 \endpspicture
2457 \end{LTXexample}
2458 \egroup
2459
2460 \clearpage
2461 \subsection{\nxLcs{psThomae} -- the popcorn function}
2462 \Index{Thomae's function}, also known as the \Index{popcorn function},
2463 the \Index{raindrop function}, the \Index{ruler function} or the
2464 \Index{Riemann function}, is a modification of the \Index{Dirichlet} function.
2465 This real-valued function $f(x)$ is defined as follows:
2466 %
2467 \[ f(x)=\begin{cases}
2468 \frac{1}{q}\mbox{ if }x=\frac{p}{q}\mbox{ is a rational number}\\
2469 0\mbox{ if }x\mbox{ is irrational}
2470 \end{cases}
2471 \]
2472 %
2473 It is assumed here that $\mathop{gcd}(p,q) = 1$ and $q > 0$ so that the function is well-defined
2474 and nonnegative. The syntax is:
2475
2476 \begin{BDef}
2477 \Lcs{psThomae}\OptArgs\Largr{x0,x1}\Largb{points}
2478 \end{BDef}
2479
2480 \verb+(x0,x1)+ is the plotted interval, both values must be grater zero and $x_1>x_0$.
2481 The plotted number of points is the third parameter.
2482
2483 \begin{LTXexample}[width=6cm,wide=false]
2484 \psset{unit=4cm}
2485 \begin{pspicture}(-0.1,-0.2)(2.5,1.15)
2486 \psaxes{->}(0,0)(2.5,1.1)
2487 \psThomae[dotsize=2.5pt,linecolor=red](0,2){300}
2488 \end{pspicture}
2489 \end{LTXexample}
2490
2491
2492 \clearpage
2493 \subsection{\nxLcs{psWeierstrass} -- a pathological function}
2494
2495 The Weierstrass function is an example of a pathological real-valued function
2496 on the real line. The function has the property that it is continuous
2497 everywhere but differentiable nowhere.
2498 %
2499 \[
2500 f_a(x)=\sum\limits_{k=1}^\infty\frac{\sin(\pi k^ax)}{\pi k^a}
2501 \]
2502 %f(p/q)=pi/(4q^2)sum_(k=1)^(q-1)(sin((k^2ppi)/q))/(sin^2((kpi)/(2q)))
2503 %
2504
2505 \begin{BDef}
2506 \Lcs{psWeierstrass}\OptArgs\Largr{$x_0,x_1$}\OptArg*{\Largs{a}}\Largb{a/b}
2507 \end{BDef}
2508
2509 Without the optional argument the mandatory one is $a$, otherwise it is $b$ and
2510 the optional one $a$. Without setting the optional argument \Lkeyword{epsilon} the value
2511 of 1.e-8 will be used.
2512
2513
2514 \begin{LTXexample}[width=6.5cm,wide=false]
2515 \psset{yunit=10,xunit=5}
2516 \begin{pspicture}(-0.1,-0.5)(2.1,0.5)
2517 \psaxes[Dx=0.2,Dy=0.1,ticksize=-2pt 0,
2518 labelFontSize=\scriptstyle]{->}(0,0)(0,-0.5)(2.1,0.5)
2519 \psWeierstrass[linecolor=red](0,2){2}
2520 \psWeierstrass[linecolor=green,epsilon=1.e-15](0,2){3}
2521 \psWeierstrass[linecolor=blue,epsilon=1.e-5](0,2){4}
2522 \end{pspicture}
2523 \end{LTXexample}
2524
2525
2526 The original Weierstraß function can be used with the optional argument:
2527 \[ f(x)= \sum_{n=0}^\infty a^n \cos(b^n \pi x) \]
2528
2529
2530
2531 \begin{LTXexample}[width=6.5cm,wide=false]
2532 \psset{unit=2cm,linewidth=0.5pt,plotpoints=5000}
2533 \begin{pspicture}(-2.1,-2.1)(2.1,2.1)
2534 \psaxes[Dx=0.5,Dy=0.5,ticksize=-2pt 0,
2535 labelFontSize=\scriptstyle]{->}(0,0)(-2,-2)(2,2)
2536 \psWeierstrass[linecolor=red](-2,2)[0.5]{3}
2537 \psWeierstrass[linecolor=blue!70](-2,2)[0.5]{10}
2538 \end{pspicture}
2539 \end{LTXexample}
2540
2541
2542
2543
2544 \clearpage
2545 \subsection{\nxLcs{psplotImp} -- plotting implicit defined functions}
2546 For a given area, the macro calculates in a first step row by row for every pixel (1pt)
2547 the function $f(x,y)$ and checks for a changing of the value from $f(x,y)<0$ to $f(x,y)>0$
2548 or vice versa. If this happens, then the pixel must be part of the curve of
2549 the function $f(x,y)=0$. In a second step the same is done column by column.
2550 This may take some time because an area of $400\times 300$ pixel needs 120 thousand calculations
2551 of the function value. The user still defines this area in his own coordinates,
2552 the translation into pixel (pt) is done internally by the macro itself.
2553 The only special keyword is \Lkeyword{stepFactor} which is preset to 0.67 and controls the horizontal
2554 and vertical step width.
2555
2556 \begin{BDef}
2557 \Lcs{psplotImp}\OptArgs\Largr{xMin,yMin}\Largr{xMax,yMax}\OptArg{PS code}\Largb{function f(x,y)}
2558 \end{BDef}
2559
2560 The function must be of $f(x,y)=0$ and described in \PS code, or alternatively with
2561 the option \Lkeyword{algebraic} (\LPack{pstricks-add}) in an algebraic form.
2562 No other value names than $x$ and $y$ are possible. In general, a starred \Lenv{pspicture*} environment
2563 maybe a good choice here.
2564
2565 \medskip
2566 \noindent
2567 \begin{tabularx}{\linewidth}{!{\color{Orange!85!Red}\vrule width 5pt} X @{}}
2568 The given area for \Lcs{psplotImp} should be \textbf{greater} than the given \Lenv{pspicture} area
2569 (see examples).
2570 \end{tabularx}
2571
2572 \begin{LTXexample}[preset=\centering]
2573 \begin{pspicture*}(-3,-3.2)(3.5,3.5)
2574 \psaxes{->}(0,0)(-3,-3)(3.2,3)%
2575 \psplotImp[linewidth=2pt,linecolor=red](-5,-2.1)(5,2.1){ x dup mul y dup mul add 4 sub }
2576 \uput[45](0,2){$x^2+y^2-4=0$}
2577 \psplotImp[linewidth=2pt,linecolor=blue,algebraic](-5,-3)(4,2.4){ (x+1)^2+y^2-4 }
2578 \end{pspicture*}
2579 \end{LTXexample}
2580
2581 \begin{LTXexample}[preset=\centering]
2582 \begin{pspicture*}(-3,-2.2)(3.5,2.5)
2583 \psaxes{->}(0,0)(-3,-2)(3.2,2)%
2584 \psplotImp[linewidth=2pt,linecolor=blue](-5,-2.2)(5,2.4){%
2585 /xqu x dup mul def
2586 /yqu y dup mul def
2587 xqu yqu add dup mul 2 dup add 2 mul xqu yqu sub mul sub }
2588 \uput*[0](-3,2){$\left(x^2+y^2\right)^2-8(x^2-y^2)=0$}
2589 \psplotImp[linewidth=1pt,linecolor=red,algebraic](-5,-2.2)(5,2.4){% Lemniskate a =2
2590 (x^2+y^2)^2-4*(x^2-y^2) }
2591 \end{pspicture*}
2592 \end{LTXexample}
2593
2594 \begin{LTXexample}[preset=\centering]
2595 \begin{pspicture*}(-3,-3.2)(3.5,3.5)
2596 \psaxes{->}(0,0)(-3,-3)(3.2,3)%
2597 \psplotImp[linewidth=2pt,linecolor=green](-6,-6)(4,2.4){%
2598 x 3 exp y 3 exp add 4 x y mul mul sub }
2599 \uput*[45](-2.5,2){$\left(x^3+y^3\right)-4xy=0$}
2600 \end{pspicture*}
2601 \end{LTXexample}
2602
2603 \begin{LTXexample}[preset=\centering]
2604 \begin{pspicture*}(-5,-3.2)(5.5,4.5)
2605 \psaxes{->}(0,0)(-5,-3)(5.2,4)%
2606 \psplotImp[algebraic,linecolor=red](-6,-4)(5,4){ y*cos(x*y)-0.2 }
2607 \psplotImp[algebraic,linecolor=blue](-6,-4)(5,4){ y*cos(x*y)-1.2 }
2608 \end{pspicture*}
2609 \end{LTXexample}
2610
2611 Using the \Lkeyword{polarplot} option implies using the variables $r$ and $phi$ for describing
2612 the function, $y$ and $x$ are not respected in this case. Using the \Lkeyword{algebraic} option
2613 for polar plots are also possible (see next example).
2614
2615 \begin{LTXexample}[preset=\centering]
2616 \begin{pspicture*}(-3,-2.5)(3.75,2.75)\psaxes{->}(0,0)(-3,-2.5)(3.2,2.5)%
2617 \psplotImp[linewidth=2pt,linecolor=cyan,polarplot](-6,-3)(4,2.4){ r 2 sub }% circle r=2
2618 \uput*[45](0.25,2){$f(r,\phi)=r-2=0$}
2619 \psplotImp[polarplot,algebraic](-6,-3)(4,2.4){ r-1 }% circle r=1
2620 \end{pspicture*}
2621 \end{LTXexample}
2622
2623 \begin{LTXexample}[preset=\centering]
2624 \begin{pspicture*}(-5,-2.2)(5.5,3.5)
2625 \pscircle(0,0){1}%
2626 \psaxes{->}(0,0)(-5,-2)(5.2,3)%
2627 \multido{\rA=0.01+0.2}{5}{%
2628 \psplotImp[linewidth=1pt,linecolor=blue,polarplot](-6,-6)(5,2.4){%
2629 r dup mul 1.0 r div sub phi sin dup mul mul \rA\space sub }}%
2630 \uput*[45](0,2){$f(r,\phi)=\left(r^2-\frac{1}{r}\right)\cdot\sin^2\phi=0$}
2631 \end{pspicture*}
2632 \end{LTXexample}
2633
2634 \begin{LTXexample}[preset=\centering]
2635 \begin{pspicture*}(-4,-3.2)(4.5,4.5)
2636 \psaxes{->}(0,0)(-4,-3)(4.2,4)%
2637 \psplotImp[algebraic,polarplot,linecolor=red](-5,-4)(5,4){ r+cos(phi/r)-2 }
2638 \end{pspicture*}
2639 \end{LTXexample}
2640
2641 The data of an implicit plot can be written into an external file for further purposes.
2642 Use the optional argument \Lkeyword[pstricks-add]{saveData} to write the $x|y$ values
2643 into the file \nxLcs{jobname.data}. The file name can be changed with
2644 the keyword \Lkeyword[pstricks-add]{filename}. When running a \TeX\ file from within a GUI
2645 it may be possible that you get a writeaccess error from GhostScript, because it prevents writing
2646 into a file when called from another program. In this case run GhostScript on the \PS-output from
2647 the command line.
2648
2649 \psset{mathLabel}
2650 \begin{LTXexample}[preset=\centering]
2651 \begin{pspicture*}(-3,-3)(3,3)
2652 \psaxes[linewidth=0.25pt,
2653 xlabelPos=top,
2654 labelFontSize=\scriptscriptstyle,
2655 labelsep=2pt,
2656 ticksize=0.05]{<->}(0,0)(-2,-1.75)(2,2)[x,0][y,90]
2657 \psplotImp[linecolor=red,linewidth=1pt,stepFactor=0.2,saveData,
2658 algebraic](-2.5,-1.75)(2.5,2.5){x^2+(5*y/4-sqrt(abs(x)))^2-2.5}
2659 \end{pspicture*}
2660 \end{LTXexample}
2661
2662 The values are saved pairwise in an array, e.\,g.:
2663 \begin{verbatim}
2664 ...
2665 [
2666 -1.53237 0.695058
2667 -1.53237 1.29957
2668 ]
2669 [
2670 -1.52534 0.666941
2671 -1.52534 1.32065
2672 ]
2673 ...
2674 \end{verbatim}
2675
2676 In one array all $y$ values for the same $x$ value are stored.
2677
2678 \iffalse
2679 The data then can be read back to get a continous line of the plot.
2680
2681 \begin{LTXexample}[preset=\centering]
2682 \readdata[nStep=20]{\data}{\jobname.data}
2683 \begin{pspicture*}(-3,-3)(3,3)
2684 \psaxes[linewidth=0.25pt,
2685 xlabelPos=top,
2686 labelFontSize=\scriptscriptstyle,
2687 labelsep=2pt,
2688 ticksize=0.05]{<->}(0,0)(-2,-1.75)(2,2)[x,0][y,90]
2689 \pslistplot[linecolor=red,linewidth=1pt,plotstyle=curve]{\data}
2690 \end{pspicture*}
2691 \end{LTXexample}
2692 \fi
2693
2694 \clearpage
2695 \subsection{\nxLcs{psVolume} -- Rotating functions around the x-axis}
2696 This macro shows the behaviour of a \Index{rotated function} around the $x$-axis.
2697
2698 \begin{BDef}
2699 \Lcs{psVolume}\OptArgs\Largr{xMin,xMax}\Largb{steps}\Largb{function $f(x)$}
2700 \end{BDef}
2701
2702 $f(x)$ has to be described as usual for the macro \Lcs{psplot}.
2703
2704 \makebox[\linewidth]{%
2705 \begin{pspicture}(-0.5,-2)(5,2.5)
2706 \psaxes{->}(0,0)(0,-2)(3,2.5)
2707 \psVolume[fillstyle=solid,fillcolor=magenta!30](0,4){1}{x sqrt}
2708 \psline{->}(4,0)(5,0)
2709 \end{pspicture}
2710 %
2711 \begin{pspicture}(-0.5,-2)(5,2.5)
2712 \psaxes{->}(0,0)(0,-2)(3,2.5)
2713 \psVolume[fillstyle=solid,fillcolor=red!40](0,4){2}{x sqrt}
2714 \psline{->}(4,0)(5,0)
2715 \end{pspicture}
2716 %
2717 \begin{pspicture}(-0.5,-2)(5,2.5)
2718 \psaxes{->}(0,0)(0,-2)(3,2.5)
2719 \psVolume[fillstyle=solid,fillcolor=blue!40](0,4){4}{x sqrt}
2720 \psline{->}(4,0)(5,0)
2721 \end{pspicture}
2722 }
2723
2724 \makebox[\linewidth]{%
2725 \begin{pspicture}(-0.5,-2)(5,2.5)
2726 \psaxes{->}(0,0)(0,-2)(3,2.5)
2727 \psVolume[fillstyle=solid,fillcolor=green!40](0,4){8}{x sqrt}
2728 \psline{->}(4,0)(5,0)
2729 \end{pspicture}
2730 %
2731 \begin{pspicture}(-0.5,-2)(5,2.5)
2732 \psaxes{->}(0,0)(0,-2)(3,2.5)
2733 \psVolume[fillstyle=solid,fillcolor=yellow!40](0,4){16}{x sqrt}
2734 \psline{->}(4,0)(5,0)
2735 \end{pspicture}
2736 %
2737 \begin{pspicture}(-0.5,-2)(5,2.5)
2738 \psaxes{->}(0,0)(0,-2)(3,2.5)
2739 \psVolume[fillstyle=solid,fillcolor=cyan!40](0,4){32}{x sqrt}
2740 \psline{->}(4,0)(5,0)
2741 \end{pspicture}
2742 }
2743
2744 \begin{lstlisting}
2745 \begin{pspicture}(-0.5,-2)(5,2.5)
2746 \psaxes{->}(0,0)(0,-2)(3,2.5)
2747 \psVolume[fillstyle=solid,fillcolor=magenta!30](0,4){1}{x sqrt}
2748 \psline{->}(4,0)(5,0)
2749 \end{pspicture}
2750 %
2751 \begin{pspicture}(-0.5,-2)(5,2.5)
2752 \psaxes{->}(0,0)(0,-2)(3,2.5)
2753 \psVolume[fillstyle=solid,fillcolor=red!40](0,4){2}{x sqrt}
2754 \psline{->}(4,0)(5,0)
2755 \end{pspicture}
2756 %
2757 \begin{pspicture}(-0.5,-2)(5,2.5)
2758 \psaxes{->}(0,0)(0,-2)(3,2.5)
2759 \psVolume[fillstyle=solid,fillcolor=blue!40](0,4){4}{x sqrt}
2760 \psline{->}(4,0)(5,0)
2761 \end{pspicture}
2762
2763 \begin{pspicture}(-0.5,-2)(5,2.5)
2764 \psaxes{->}(0,0)(0,-2)(3,2.5)
2765 \psVolume[fillstyle=solid,fillcolor=green!40](0,4){8}{x sqrt}
2766 \psline{->}(4,0)(5,0)
2767 \end{pspicture}
2768 %
2769 \begin{pspicture}(-0.5,-2)(5,2.5)
2770 \psaxes{->}(0,0)(0,-2)(3,2.5)
2771 \psVolume[fillstyle=solid,fillcolor=yellow!40](0,4){16}{x sqrt}
2772 \psline{->}(4,0)(5,0)
2773 \end{pspicture}
2774 %
2775 \begin{pspicture}(-0.5,-2)(5,2.5)
2776 \psaxes{->}(0,0)(0,-2)(3,2.5)
2777 \psVolume[fillstyle=solid,fillcolor=cyan!40](0,4){32}{x sqrt}
2778 \psline{->}(4,0)(5,0)
2779 \end{pspicture}
2780 \end{lstlisting}
2781
2782 \psset{xunit=2}
2783 \makebox[\linewidth]{%
2784 \begin{pspicture}(-0.5,-4)(3,4)
2785 \psaxes{->}(0,0)(0,-4)(3,4)
2786 \psVolume[fillstyle=solid,fillcolor=cyan!40](0,1){4}{x}
2787 \psVolume[fillstyle=solid,fillcolor=yellow!40](1,2){4}{x dup mul}
2788 \psline(2,0)(3,0)
2789 \end{pspicture}
2790 %
2791 \begin{pspicture}(-0.5,-4)(3,4)
2792 \psaxes{->}(0,0)(0,-4)(3,4)
2793 \psVolume[fillstyle=solid,fillcolor=cyan!40](0,1){20}{x}
2794 \psVolume[fillstyle=solid,fillcolor=yellow!40](1,2){20}{x dup mul}
2795 \psline(2,0)(3,0)
2796 \end{pspicture}
2797 }
2798 \begin{lstlisting}
2799 \psset{xunit=2}
2800 \begin{pspicture}(-0.5,-4)(3,4)
2801 \psaxes{->}(0,0)(0,-4)(3,4)
2802 \psVolume[fillstyle=solid,fillcolor=cyan!40](0,1){4}{x}
2803 \psVolume[fillstyle=solid,fillcolor=yellow!40](1,2){4}{x dup mul}
2804 \psline(2,0)(3,0)
2805 \end{pspicture}
2806 %
2807 \begin{pspicture}(-0.5,-4)(3,4)
2808 \psaxes{->}(0,0)(0,-4)(3,4)
2809 \psVolume[fillstyle=solid,fillcolor=cyan!40](0,1){20}{x}
2810 \psVolume[fillstyle=solid,fillcolor=yellow!40](1,2){20}{x dup mul}
2811 \psline(2,0)(3,0)
2812 \end{pspicture}
2813 \end{lstlisting}
2814
2815
2816 \clearpage
2817 \section{Examples}
2818 \subsection{Filling an area under a distribution curve}
2819 \begin{LTXexample}[preset=\centering]
2820 \psset{xunit=0.5cm,yunit=20cm,arrowscale=1.5}
2821 \begin{pspicture}(-1,-0.1)(21,0.2)
2822 \psChiIIDist[linewidth=1pt,nue=5]{0.01}{19.5}
2823 \psaxes[labels=none,ticks=none]{->}(20,0.2)
2824 \pscustom[fillstyle=solid,fillcolor=red!30]{%
2825 \psChiIIDist[linewidth=1pt,nue=5]{8}{19.5}%
2826 \psline(20,0)(8,0)}
2827 \end{pspicture}
2828 \end{LTXexample}
2829
2830
2831 \subsection{An animation of a distribution}
2832
2833 \psset{xunit=0.9cm,yunit=9cm}
2834 \newcommand*\studentT[1]{%
2835 \begin{pspicture}(-6,-0.1)(6,0.5)
2836 \psaxes[Dy=0.1]{->}(0,0)(-5,0)(5.5,0.45)[$x$,0][$y$,90]
2837 \pscustom[fillstyle=solid,fillcolor=blue!40,opacity=0.4,linecolor=red,linestyle=none]{%
2838 \psline(0,0)(-5,0)
2839 \psTDist[nue=#1]{-5}{5}
2840 \psline(5,0)(0,0)
2841 }
2842 \psTDist[nue=#1,linecolor=red,linewidth=1pt]{-5}{5}
2843 \rput(3,0.3){$\nu = #1$}
2844 \end{pspicture}}
2845
2846 \begin{center}
2847 \begin{animateinline}[poster=first,controls,palindrome]{10}
2848 \multiframe{50}{rA=0.02+0.02}{\studentT{\rA}}
2849 \end{animateinline}
2850 \captionof{figure}{Student's $t$-distribution.}
2851 \end{center}
2852
2853
2854 \begin{lstlisting}
2855 \psset{xunit=0.9cm,yunit=9cm}
2856 \newcommand*\studentT[1]{%
2857 \begin{pspicture}(-6,-0.1)(6,0.5)
2858 \psaxes[Dy=0.1]{->}(0,0)(-5,0)(5.5,0.45)[$x$,0][$y$,90]
2859 \pscustom[fillstyle=solid,fillcolor=blue!40,opacity=0.4,linecolor=red,linestyle=none]{%
2860 \psline(0,0)(-5,0)
2861 \psTDist[nue=#1]{-5}{5}
2862 \psline(5,0)(0,0)
2863 }
2864 \psTDist[nue=#1,linecolor=red,linewidth=1pt]{-5}{5}
2865 \rput(3,0.3){$\nu = #1$}
2866 \end{pspicture}}
2867
2868 \begin{center}
2869 \begin{animateinline}[poster=first,controls,palindrome]{10}
2870 \multiframe{50}{rA=0.02+0.02}{\studentT{\rA}}
2871 \end{animateinline}
2872 \captionof{figure}{Student's $t$-distribution.}
2873 \end{center}
2874 \end{lstlisting}
2875
2876
2877 \clearpage
2878 \section{List of all optional arguments for \texttt{pst-func}}
2879 \xkvview{family=pst-func,columns={key,type,default}}
2880
2881 \bgroup
2882 \RaggedRight
2883 \nocite{*}
2884 %\bibliographystyle{plain}
2885 \printbibliography{pst-func-doc}
2886 \egroup
2887
2888 \printindex
2889
2890 \end{document}