PST Func
PST Func
pst-func
1.00
0.25
x
−2 −1 0 1
Package author(s):
Herbert Voß
Contents 2
Contents
1 \psBezier# 5
2 Polynomials 7
2.1 Chebyshev polynomials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2 \psPolynomial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.3 \psBernstein . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.4 Calculating the zeros of a function or the the intermediate point of two
function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3 \psFourier 21
4 \psBessel 24
8 Distributions 32
8.1 Normal distribution (Gauss) . . . . . . . . . . . . . . . . . . . . . . . . . . 33
8.2 Binomial distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
8.3 Poisson distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
8.4 Gamma distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
8.5 χ2 -distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
8.6 Student’s t-distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
8.7 F -distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
8.8 Beta distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
8.9 Cauchy distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
8.10 Weibull distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
8.11 Vasicek distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
15 Examples 66
15.1 Filling an area under a distribution curve . . . . . . . . . . . . . . . . . . . 66
15.2 An animation of a distribution . . . . . . . . . . . . . . . . . . . . . . . . . 66
Contents 3
References 69
Contents 4
Thanks to
Rafal Bartczuk, Jean-Côme Charpentier, Martin Chicoine, Gerry Coombes,
Denis Girou, John Frampton, Leon Free, Attila Gati, Horst Gierhardt, Christophe
Jorssen, Lars Kotthoff, Buddy Ledger, Manuel Luque, Patrice Mégret, Svend
Mortensen, Matthias Rüss, Thomas Söll, Jose-Emilio Vila-Forcen, Timothy
Van Zandt, Michael Zedler, and last but not least http://mathworld.wolfram.
com.
1 \psBezier# 5
1 \psBezier#
This macro can plot a Bézier spline from order 1 up to 9 which needs (order+1) pairs of
given coordinates.
Given a set of n + 1 control points P0 , P1 , . . . , Pn , the corresponding Bézier curve (or
Bernstein-Bézier curve) is given by
n
X
C(t) = Pi Bi,n (t) (1)
i=0
n
where Bi,n (t) is a Bernstein polynomial Bi,n (t) = i ti (1 − t)n−i , and t ∈ [0, 1]. The Bézier
curve starts through the first and last given point and lies within the convex hull of all
control points. The curve is tangent to P1 −P0 and Pn −Pn−1 at the endpoint. Undesirable
properties of Bézier curves are their numerical instability for large numbers of control
points, and the fact that moving a single control point changes the global shape of the
curve. The former is sometimes avoided by smoothly patching together low-order Bézier
curves.
The macro \psBezier (note the upper case B) expects the number of the order and
n = order + 1 pairs of coordinates:
\psBezier# [Options] (x0 , y0 )(x1 , y1 )(xn , yn )
The number of steps between the first and last control points is given by the keyword
plotpoints and preset to 200. It can be changed in the usual way.
1 \psset{showpoints=true,linewidth=1.5pt}
2 \begin{pspicture}(-2,-2)(2,2)% order 1 -- linear
3 \psBezier1{<->}(-2,0)(-2,2)
4 \end{pspicture}\qquad
5 %
6 \begin{pspicture}(-2,-2)(2,2)% order 2 -- quadratric
7 \psBezier2{<->}(-2,0)(-2,2)(0,2)
8 \end{pspicture}\qquad
9 %
10 \begin{pspicture}(-2,-2)(2,2)% order 3 -- cubic
11 \psBezier3{<->}(-2,0)(-2,2)(0,2)(2,2)
12 \end{pspicture}\qquad
13
14 \vspace{1cm}
15 \begin{pspicture}(-2,-2)(2,2)% order 4 -- quartic
16 \psBezier4{<->}(-2,0)(-2,2)(0,2)(2,2)(2,0)
17 \end{pspicture}\qquad
18 %
19 \begin{pspicture}(-2,-2)(2,2)% order 5 -- quintic
20 \psBezier5{<->}(-2,0)(-2,2)(0,2)(2,2)(2,0)(2,-2)
21 \end{pspicture}\qquad
22 %
23 \begin{pspicture}(-2,-2)(2,2)% order 6
24 \psBezier6{<->}(-2,0)(-2,2)(0,2)(2,2)(2,0)(2,-2)(0,-2)
25 \end{pspicture}\qquad
26
27 \vspace{1cm}
1 \psBezier# 6
28 \begin{pspicture}(-2,-2)(2,2)% order 7
29 \psBezier7{<->}(-2,0)(-2,2)(0,2)(2,2)(2,0)(2,-2)(0,-2)(-2,-2)
30 \end{pspicture}\qquad
31 %
32 \begin{pspicture}(-2,-2)(2,2)% order 8
33 \psBezier8{<->}(-2,0)(-2,2)(0,2)(2,2)(2,0)(2,-2)(0,-2)(-2,-2)(-2,0)
34 \end{pspicture}\qquad
35 %
36 \begin{pspicture}(-2,-2)(2,2)% order 9
37 \psBezier9{<->}(-2,0)(-2,2)(0,2)(2,2)(2,0)(2,-2)(0,-2)(-2,-2)(-2,0)(0,0)
38 \end{pspicture}
b b b
b b b b b b b b b
b b
b b b b b b b b b
b b b b
b b b b b b b b
2 Polynomials 7
2 Polynomials
The polynomials of the first (ChebyshevT) kind are defined through the identity
Tn (cos θ) = cos(nθ)
They can be obtained from the generating functions
1 − t2
g1 (t, x) = (2)
1 − 2xt + t2
∞
X
= T0 (x) + 2 Tn (x)tn (3)
n=1
and
1 − xt
g2 (t, x) = (4)
1 − 2xt + t2
∞
X
= Tn (x)tn (5)
n=0
1
g(t, x) = (6)
1 − 2xt + t2
∞
X
= Un (x)tn (7)
n=0
pst-func defines the TEX-macros \ChebyshevT for the first kind and \ChebyshevU for
the second kind of Chebyshev polynomials. These TEX-macros cannot be used outside
of PostScript, they are only wrappers for tx@FuncDict begin ChebyshevT end and the
same for \ChebyshevU.
2.1 Chebyshev polynomials 8
Im{s21 }
Re{s21 }
1 \psset{arrowscale=1.5,unit=3cm}
2 \begin{pspicture}(-1.5,-1.5)(1.5,1.5)
3 \psaxes[ticks=none,labels=none]{->}(0,0)(-1.25,-1.25)(1.25,1.25)%
4 [Re$\{s_{21}\}$,0][Im$\{s_{21}\}$,90]
5 \pscircle(0,0){1}
6 \parametricplot[linecolor=blue,plotpoints=10000]{0}{1.5}{
7 /N 9 def
8 /x 2 N mul t \ChebyshevT def
9 /y 2 N mul 1 sub t \ChebyshevU def
10 x x 2 exp y 2 exp add div
11 y x 2 exp y 2 exp add div
12 }
13 \end{pspicture}
2.1 Chebyshev polynomials 9
−1.2 −1.0 −0.8 −0.6 −0.4 −0.2 0.2 0.4 0.6 0.8 1.0 1.2
−1
1 \psset{xunit=4cm,yunit=3cm,plotpoints=1000}
2 \begin{pspicture}(-1.2,-2)(2,1.5)
3 \psaxes[Dx=0.2]{->}(0,0)(-1.25,-1.2)(1.25,1.2)
4 \psset{linewidth=1.5pt}
5 \psplot[linestyle=dashed]{-1}{1}{1 x \ChebyshevT}
6 \psplot[linecolor=black]{-1}{1}{2 x \ChebyshevT}
7 \psplot[linecolor=black]{-1}{1}{3 x \ChebyshevT}
8 \psplot[linecolor=blue]{-1}{1}{4 x \ChebyshevT }
9 \psplot[linecolor=red]{-1}{1}{5 x \ChebyshevT }
10 \end{pspicture}
2.1 Chebyshev polynomials 10
−1.0 −0.8 −0.6 −0.4 −0.2 0.2 0.4 0.6 0.8 1.0
−1
1 \psset{xunit=4cm,yunit=3cm,plotpoints=1000}
2 \begin{pspicture *}(-1.5,-1.5)(1.5,1.5)
3 \psaxes[Dx=0.2]{->}(0,0)(-1.15,-1.1)(1.15,1.1)
4 \psaxes[Dx=0.2]{->}(0,0)(-1.25,-1.2)(1.25,1.2)
5 \psset{linewidth=1.5pt}
6 \psplot[linecolor=black]{-1}{1}{2 x \ChebyshevU}
7 \psplot[linecolor=black]{-1}{1}{3 x \ChebyshevU}
8 \psplot[linecolor=blue]{-1}{1}{4 x \ChebyshevU}
9 \psplot[linecolor=red]{-1}{1}{5 x \ChebyshevU}
10 \end{pspicture *}
−1.2 −1.0 −0.8 −0.6 −0.4 −0.2 0.2 0.4 0.6 0.8 1.0 1.2
−1
1 \psset{xunit=4cm,yunit=3cm,plotpoints=1000}
2.2 \psPolynomial 11
2 \begin{pspicture}(-1.25,-1.2)(1.25,1.2)
3 \psaxes[Dx=0.2]{->}(0,0)(-1.25,-1.2)(1.25,1.2)
4 \psset{linewidth=1.5pt}
5 \psplot[linecolor=black]{-1}{1}{x ACOS 2 mul RadtoDeg cos}
6 \psplot[linecolor=black]{-1}{1}{x ACOS 3 mul RadtoDeg cos}
7 \psplot[linecolor=blue]{-1}{1}{x ACOS 4 mul RadtoDeg cos}
8 \psplot[linecolor=red]{-1}{1}{x ACOS 5 mul RadtoDeg cos}
9 \end{pspicture}
2.2 \psPolynomial
so pst-func needs only the coefficients of the polynomial to calculate the function. The
syntax is
With the option xShift one can do a horizontal shift to the graph of the function. With
another than the predefined value the macro replaces x by x − xShift; xShift=1 moves
the graph of the polynomial function one unit to the right.
8
g(x)
4
h(x) f (x)
−3 −2 −1 1 2 3 4
−2
−4
1 \psset{yunit=0.5cm,xunit=1cm}
2 \begin{pspicture *}(-3,-5)(5,10)
3 \psaxes[Dy=2]{->}(0,0)(-3,-5)(5,10)
4 \psset{linewidth=1.5pt}
5 \psPolynomial[coeff=6 3 -1,linecolor=red]{-3}{5}
6 \psPolynomial[coeff=2 -1 -1 .5 -.1 .025,linecolor=blue]{-2}{4}
2.2 \psPolynomial 12
The plot is easily clipped using the star version of the pspicture environment, so that
points whose coordinates are outside of the desired range are not plotted. The plotted
polynomials are:
f (x) = 6 + 3x − x2 (11)
2 3 4 5
g(x) = 2 − x − x + 0.5x − 0.1x + 0.025x (12)
h(x) = −2 + x − x2 + 0.5x3 + 0.1x4 + 0.025x5 + 0.2x6 (13)
∗ 2 3
h (x) = −2 + (x − 1) − (x − 1) + 0.5(x − 1) +
+ 0.1(x − 1)4 + 0.025(x − 1)5 + 0.2(x − 1)6 (14)
The above parameters are only valid for the \psPolynomial macro, except x0, which
can also be used for the Gauss function. All options can be set in the usual way with
\psset.
2.2 \psPolynomial 13
h′′ (x) 6
4
h(x)
2
h′ (x)
−3 −2 −1 1 2
−2
−4
1 \psset{yunit=0.5cm,xunit=2cm}
2 \begin{pspicture *}(-3,-5)(3,10)
3 \psaxes[Dy=2]{->}(0,0)(-3,-5)(3,10)
4 \psset{linewidth=1.5pt}
5 \psPolynomial[coeff=-2 1 -1 .5 .1 .025 .2 ,linecolor=magenta]{-2}{4}
6 \psPolynomial[coeff=-2 1 -1 .5 .1 .025 .2 ,linecolor=red,%
7 linestyle=dashed,Derivation=1]{-2}{4}
8 \psPolynomial[coeff=-2 1 -1 .5 .1 .025 .2 ,linecolor=blue,%
9 linestyle=dotted,Derivation=2]{-2}{4}
10 \rput[lb](2,4){\textcolor{magenta}{$h(x)$}}
11 \rput[lb](1,1){\textcolor{red}{$h^{\prime}(x)$}}
12 \rput[lb](-1,6){\textcolor{blue}{$h^{\prime\prime}(x)$}}
13 \end{pspicture *}
2.2 \psPolynomial 14
8
f ′′ (x) = 6x
6
f ′′′ (x) = 6
4
f (x) = x3
−3 −2 −1 1 2
−2
−4
1 \psset{yunit=0.5cm,xunit=2cm}
2 \begin{pspicture *}(-3,-5)(3,10)
3 \psaxes[Dy=2]{->}(0,0)(-3,-5)(3,10)
4 \psset{linewidth=1.5pt}
5 \psPolynomial[coeff=0 0 0 1,linecolor=blue]{-2}{4}
6 \psPolynomial[coeff=0 0 0 1,linecolor=red,%
7 linestyle=dashed,Derivation=2]{-2}{4}
8 \psPolynomial[coeff=0 0 0 1,linecolor=cyan,%
9 linestyle=dotted,Derivation=3]{-2}{4}
10 \rput[lb](1.8,4){\textcolor{blue}{$f(x)=x^3$}}
11 \rput[lb](0.2,8){\textcolor{red}{$f^{\prime\prime}(x)=6x$}}
12 \rput[lb](-2,5){\textcolor{cyan}{$f^{\prime\prime\prime}(x)=6$}}
13 \end{pspicture *}
2.2 \psPolynomial 15
b b b b b b b b
−5 −4 −3 −2 −1 1 2 3 4
−1
−2
−3
−4
−5
1 \begin{pspicture *}(-5,-5)(5,5)
2 \psaxes{->}(0,0)(-5,-5)(5,5)%
3 \psset{dotscale=2}
4 \psPolynomial[markZeros,linecolor=red,linewidth=2pt,coeff=-1 1 -1 0 0.15]{-4}{3}%
5 \psPolynomial[markZeros,linecolor=blue,linewidth=1pt,linestyle=dashed,%
6 coeff=-1 1 -1 0 0.15,Derivation=1,zeroLineTo=0]{-4}{3}%
7 \psPolynomial[markZeros,linecolor=magenta,linewidth=1pt,linestyle=dotted,%
8 coeff=-1 1 -1 0 0.15,Derivation=2,zeroLineTo=0]{-4}{3}%
9 \psPolynomial[markZeros,linecolor=magenta,linewidth=1pt,linestyle=dotted,%
10 coeff=-1 1 -1 0 0.15,Derivation=2,zeroLineTo=1]{-4}{3}%
11 \end{pspicture *}
2.2 \psPolynomial 16
× × × × × × × ×
−5 −4 −3 −2 −1 1 2 3 4
−1
−2
−3
−4
−5
1 \psset{xunit=1.5}
2 \begin{pspicture *}(-5,-5)(5,5)
3 \psaxes{->}(0,0)(-5,-5)(5,5)%
4 \psset{dotscale=2,dotstyle=x,zeroLineStyle=dotted,zeroLineWidth=1pt}
5 \psPolynomial[markZeros,linecolor=red,linewidth=2pt,coeff=-1 1 -1 0 0.15]{-4}{3}%
6 \psPolynomial[markZeros,linecolor=blue,linewidth=1pt,linestyle=dashed,%
7 coeff=-1 1 -1 0 0.15,Derivation=1,zeroLineTo=0]{-4}{3}%
8 \psPolynomial[markZeros,linecolor=magenta,linewidth=1pt,linestyle=dotted,%
9 coeff=-1 1 -1 0 0.15,Derivation=2,zeroLineTo=0]{-4}{3}%
10 \psPolynomial[markZeros,linecolor=magenta,linewidth=1pt,linestyle=dotted,%
11 coeff=-1 1 -1 0 0.15,Derivation=2,zeroLineTo=1]{-4}{3}%
12 \end{pspicture *}
2.3 \psBernstein 17
2.3 \psBernstein
normalization
n
X
Bi,n (t) = 1
i=0
occurring at t = ni . The envelope fn (x) of the Bernstein polynomials Bi,n (x) for i =
0, 1, . . . , n is given by
1
fn (x) = p
πn · x(1 − x)
illustrated below for n = 20.
\psBernstein [Options] (tStart,tEnd )(i,n )
The (tStart, tEnd) are optional and preset by (0,1). The only new optional argument
is the boolean key envelope, which plots the envelope curve instead of the Bernstein
polynomial.
B0,0
1 \psset{xunit=4.5cm,yunit=3cm}
2 \begin{pspicture}(1,1.1)
3 \psaxes{->}(0,0)(1,1)[$t$,0][$B_{0,0}$,90]
4 \psBernstein[linecolor=red,linewidth=1pt](0,0)
5 \end{pspicture}
t
Bi,1
1 \psset{xunit=4.5cm,yunit=3cm}
2 \begin{pspicture}(1,1.1)
3 \psaxes{->}(0,0)(1,1)[$t$,0][$B_{i,1}$,90]
4 \psBernstein[linecolor=blue,linewidth=1pt](0,1)
5 \psBernstein[linecolor=blue,linewidth=1pt](1,1)
6 \end{pspicture}
t
2.3 \psBernstein 18
Bi,2
1 \psset{xunit=4.5cm,yunit=3cm}
2 \begin{pspicture}(1,1.1)
3 \psaxes{->}(0,0)(1,1)[$t$,0][$B_{i,2}$,90]
4 \multido{\i=0+1}{3}{\psBernstein[linecolor=red,
5 linewidth=1pt](\i,2)}
6 \end{pspicture}
t
Bi,3
1 \psset{xunit=4.5cm,yunit=3cm}
2 \begin{pspicture}(1,1.1)
3 \psaxes{->}(0,0)(1,1)[$t$,0][$B_{i,3}$,90]
4 \multido{\i=0+1}{4}{\psBernstein[linecolor=magenta,
5 linewidth=1pt](\i,3)}
6 \end{pspicture}
t
Bi,4
1 \psset{xunit=4.5cm,yunit=3cm}
2 \begin{pspicture}(1,1.1)
3 \psaxes{->}(0,0)(1,1)[$t$,0][$B_{i,4}$,90]
4 \multido{\i=0+1}{5}{\psBernstein[linecolor=cyan,
5 linewidth=1pt](\i,4)}
6 \end{pspicture}
t
Bi,20 1 \psset{xunit=4.5cm,yunit=3cm}
2 \begin{pspicture}(-0.1,-0.05)(1.1,1.1)
3 \multido{\i=0+1}{20}{\psBernstein[linecolor=green,
4 linewidth=1pt](\i,20)}
5 \psBernstein[envelope,linecolor=black](0.02,0.98)
(0,20)
6 \psaxes{->}(0,0)(1,1)[$t$,0][$B_{i,20}$,180]
7 \end{pspicture}
t
Benv
1 \psset{xunit=4.5cm,yunit=3cm}
2 \begin{pspicture *}(-0.2,-0.05)(1.1,1.1)
3 \psaxes{->}(0,0)(1,1)[$t$,0][$B_{env}$,180]
4 \multido{\i=2+1}{20}{\psBernstein[envelope,
5 linewidth=1pt](0.01,0.99)(0,\i)}
6 \end{pspicture *}
t
2.4 Calculating the zeros of a function or the the intermediate point of two function 19
2.4 Calculating the zeros of a function or the the intermediate point of two
function
If the second function is not given the macro calculates and displays the zeros of the
first function. If the second function is defined too, then the macro calculates the inter-
mediate point of the two functions. The intervall is defined as [x0 , x1 ]. Possible optional
arguments are
Mµ=1(0.0|2)
m b =1 b
2
√
f (x) = 2 · x · cos (ln x) · sin x
1
t hier
1
ung is
b b b b b
0
1 2 3 4 5 6 7 8 9
−1
−2
1 \definecolor{BeigeTS}{rgb}{0.98,0.95,0.87}
2 \definecolor{CornBlauTS}{rgb}{0.39,0.59,0.93}
3 \definecolor{SandBraun}{rgb}{0.96,0.64,0.38}
4 \psset{yunit=1.25cm,arrowinset=0.02,arrowlength=2,linewidth=0.5pt,saveNodeCoors,
NodeCoorPrefix=n}
5 \def\funkf{2*sqrt(x)*cos(ln(x))*sin(x)}
6 \begin{pspicture}[plotpoints=500,algebraic,fontscale=5,markZeros,PrintCoord,
7 PointName=N,dotscale=0.7](-0.5,-3)(10,2.5)
8 \psStep[fillstyle=solid,fillcolor=BeigeTS,opacity=0.7,linewidth=0.3pt,
2.4 Calculating the zeros of a function or the the intermediate point of two function 20
9 linecolor=SandBraun!50](0.001,9.5){40}{\funkf}
10 \psStep[StepType=Riemann,fillstyle=solid,opacity=0.3,fillcolor=CornBlauTS,
11 linecolor=CornBlauTS,linewidth=0.3pt](0.001,9.5){40}{\funkf}
12 \psaxes[labelFontSize=\scriptstyle,ticksize=-0.1 0]{->}(0,0)(0,-2.75)(10,2.5)
13 \psplot[linecolor=BeigeTS!60,linewidth=0.8pt]{0.001}{9.75}{\funkf}
14 \psplotTangent[linecolor=blue,Derive={Derive(1,\funkf)}]{1.29}{1.5}{\funkf}
15 \uput[90](6,1.2){$f(x)=2\cdot\sqrt{x}\cdot\cos{(\ln{x})}\cdot\sin{x}$}
16 {\psset{dotscale=1.5,linecolor=blue!50!black!90,ydecimals=0}
17 \psZero[xShift=-0.2,yShift=0.15,postString=1,Newton](0.5,1){\funkf}{N1}
18 \psZero[xShift=-0.05,yShift=0.15,postString=2](2,4){\funkf}{N2}
19 \psZero[xShift=-0.45,yShift=0.15,postString=3](4,6){\funkf}{N3}
20 \psZero[xShift=-0.45,yShift=0.15,postString=4](6,7){\funkf}{N4}
21 \psZero[xShift=-0.45,yShift=0.15,postString=5](9,11){\funkf}{N5}
22 \psZero[xShift=-1.15,yShift=0,PointName=M,
23 postString={m=1}](0.5,2){Derive(1,\funkf)-1+\funkf}[\funkf]{M}%
24 }
25 \pcline{->}(0.5,-1)(M)
26 \nbput[nrot=:U,labelsep=0.01]{%
27 \scriptsize Steigung ist hier
28 \psPrintValueNew[PSfont=Palatino-Roman,decimals=0,round,fontscale=7]{nMx,{Derive
(1,\funkf)}}}
29 \psdot[linecolor=green,strokeopacity=0.8](*{nMx} {\funkf})
30 \uput[90](*{nMx} {\funkf}){$m=$
31 \psPrintValueNew[PSfont=Palatino-Roman,decimals=0,round,fontscale=8]{nMx,{Derive(1,\
funkf)}}}
32 \end{pspicture}
3 \psFourier 21
3 \psFourier
The macro \psFourier plots Fourier sums. The syntax is similiar to \psPolynomial,
except that there are two kinds of coefficients:
−5 −4 −3 −2 −1 1 2 3 4
−1
−2
1 \begin{pspicture}(-5,-3)(5,5.5)
2 \psaxes{->}(0,0)(-5,-2)(5,4.5)
3 \psset{plotpoints=500,linewidth=1pt}
4 \psFourier[cosCoeff=2, linecolor=green]{-4.5}{4.5}
5 \psFourier[cosCoeff=0 0 2, linecolor=magenta]{-4.5}{4.5}
6 \psFourier[cosCoeff=2 0 2, linecolor=red]{-4.5}{4.5}
7 \end{pspicture}
3 \psFourier 22
−5 −4 −3 −2 −1 1 2 3 4
−1
−2
−3
−4
−5
−6
1 \psset{yunit=0.75}
2 \begin{pspicture}(-5,-6)(5,7)
3 \psaxes{->}(0,0)(-5,-6)(5,7)
4 \psset{plotpoints=500}
5 \psFourier[linecolor=red,linewidth=1pt]{-4.5}{4.5}
6 \psFourier[sinCoeff= -1 1 -1 1 -1 1 -1 1,%
7 linecolor=blue,linewidth=1.5pt]{-4.5}{4.5}
8 \end{pspicture}
3 \psFourier 23
−5 −4 −3 −2 −1 1 2 3 4
−1
−2
−3
−4
−5
1 \begin{pspicture}(-5,-5)(5,5.5)
2 \psaxes{->}(0,0)(-5,-5)(5,5)
3 \psset{plotpoints=500,linewidth=1.5pt}
4 \psFourier[sinCoeff=-.5 1 1 1 1 ,cosCoeff=-.5 1 1 1 1 1,%
5 linecolor=blue]{-4.5}{4.5}
6 \end{pspicture}
4 \psBessel 24
4 \psBessel
There are two special parameters for the Bessel function, and also the settings of many
pst-plot or pstricks parameters affect the plot. These two “constants” have the fol-
lowing meaning:
f (t) = constI · Jn + constII
where constI and constII must be real PostScript expressions, e.g.
\psset{constI=2.3,constII=t k sin 1.2 mul 0.37 add}
The Bessel function is plotted with the parametricplot macro, this is the reason why
the variable is named t. The internal procedure k converts the value t from radian into
degrees. The above setting is the same as
In particular, note that the default for plotpoints is 500. If the plotting computations
are too time consuming at this setting, it can be decreased in the usual way, at the cost
of some reduction in graphics resolution.
4 \psBessel 25
1.0
Z π
1
0.8 Jn (x) = cos(x sin t − nt) dt
π 0
0.6
0.4
0.2
−0.2
−0.4
−0.6
−0.8
1 {
2 \psset{xunit=0.25,yunit=5}
3 \begin{pspicture}(-13,-.85)(13,1.25)
4 \rput(13,0.8){%
5 $\displaystyle J_n(x)=\frac{1}{\pi}\int_0^\pi\cos(x\sin t-nt)\dt$%
6 }
7 \psaxes[Dy=0.2,Dx=4]{->}(0,0)(-30,-.8)(30,1.2)
8 \psset{linewidth=1pt}
9 \psBessel[linecolor=red]{0}{-28}{28}%
10 \psBessel[linecolor=blue]{1}{-28}{28}%
11 \psBessel[linecolor=green]{2}{-28}{28}%
12 \psBessel[linecolor=magenta]{3}{-28}{28}%
13 \end{pspicture}
14 }
4 \psBessel 26
2.4
1.6
−0.8
1 {
2 \psset{xunit=0.25,yunit=2.5}
3 \begin{pspicture}(-13,-1.5)(13,3)
4 \rput(13,0.8){%
5 $\displaystyle f(t) = 2.3 \cdot J_0 + 1.2\cdot \sin t + 0.37$%
6 }
7 \psaxes[Dy=0.8,dy=2cm,Dx=4]{->}(0,0)(-30,-1.5)(30,3)
8 \psset{linewidth=1pt}
9 \psBessel[linecolor=red,constI=2.3,constII={t k sin 1.2 mul 0.37 add}]{0}{-28}{28}%
10 \end{pspicture}
11 }
5 Modfied Bessel function of first order 27
The only valid optional argument for the function is nue, which is preset to 0, it shows
I0 .
0
0 1 2 3 4
1 \begin{pspicture}(0,-0.5)(5,5)
2 \psaxes[ticksize=-5pt 0]{->}(5,5)
3 \psModBessel[yMaxValue=5,nue=0,linecolor=red]{0}{5}
4 \psModBessel[yMaxValue=5,nue=1,linecolor=green]{0}{5}
5 \psModBessel[yMaxValue=5,nue=2,linecolor=blue]{0}{5}
6 \psModBessel[yMaxValue=5,nue=3,linecolor=cyan]{0}{5}
7 \end{pspicture}
6 \psSi, \pssi and \psCi 28
Rx sin(t)
Si(x) = t dt
0
1
sin(t)
f (x) = t
−1
R∞ sin(t) π
si(x) = − t dt = Si(x) − 2
x
−2
−3
−4
1 \psset{xunit=0.5}
2 \begin{pspicture}(-15,-4.5)(15,2)
3 \psaxes[dx=1cm,Dx=2]{->}(0,0)(-15.1,-4)(15,2)
4 \psplot[plotpoints=1000]{-14.5}{14.5}{ x RadtoDeg sin x div }
5 \psSi[plotpoints=1500,linecolor=red,linewidth=1pt]{-14.5}{14.5}
6 \pssi[plotpoints=1500,linecolor=blue,linewidth=1pt]{-14.5}{14.5}
7 \rput(-5,1.5){\color{red}$Si(x)=\int\limits _{0}^x \frac{\sin(t)}{t}\dt$}
8 \rput(8,-1.5){\color{blue}$si(x)=-\int\limits _{x}^{\infty} \frac{\sin(t)}{t}\dt=Si(x)
-\frac{\pi}{2}$}
9 \rput(8,.5){$f(x)= \frac{\sin(t)}{t}$}
10 \end{pspicture}
6 \psSi, \pssi and \psCi 29
2
R∞ cos(t)
Ci(x) = − t dt ci(x) = −Ci(x) + ln(x) + γ
x
1
−1
−2
−3
−4
1 \psset{xunit=0.5}
2 \begin{pspicture *}(-15,-4.2)(15,4.2)
3 \psaxes[dx=1cm,Dx=2]{->}(0,0)(-15.1,-4)(15,4)
4 \psplot[plotpoints=1000]{-14.5}{14.5}{ x RadtoDeg cos x Div }
5 \psCi[plotpoints=500,linecolor=red,linewidth=1pt]{-11.5}{11.5}
6 \psci[plotpoints=500,linecolor=blue,linewidth=1pt]{-11.5}{11.5}
7 \rput(-8,1.5){\color{red}$Ci(x)=-\int\limits _{x}^{\infty} \frac{\cos(t)}{t}\dt$}
8 \rput(8,1.5){\color{blue}$ci(x)=-Ci(x)+\ln(x)+\gamma$}
9 \end{pspicture *}
7 \psIntegral, \psCumIntegral, and \psConv 30
These new macros1 allows to plot the result of an integral using the Simpson numerical
integration rule. The first one is the result of the integral of a function with two vari-
ables, and the integral is performed over one of them. The second one is the cumulative
integral of a function (similar to \psGaussI but valid for all functions). The third one is
the result of a convolution. They are defined as:
Zb
\psIntegral (x) = f (x, t)dt (23)
a
Zx
\psCumIntegral (x) = f (t)dt (24)
xStart
Zb
\psConv(x) = f (t)g(x − t)dt (25)
a
In the first one, the integral is performed from a to b and the function f depends on
two parameters. In the second one, the function f depends on only one parameter,
and the integral is performed from the minimum value specified for x (xStart) and the
current value of x in the plot. The third one uses the \psIntegral macro to perform an
approximation to the convolution, where the integration is performed from a to b.
The syntax of these macros is:
In the first macro, the function should be created such that it accepts two values:
<x t function> should be a value. For the second and the third functions, they only
need to accept one parameter: <x function> should be a value.
There are no new parameters for these functions. The two most important ones are
plotpoints, which controls the number of points of the plot (number of divisions on
x for the plot) and Simpson, which controls the precision of the integration (a larger
number means a smallest step). The precision and the smoothness of the plot depend
strongly on these two parameters.
−8 −6 −4 −2 0 2 4 6 8
1 %\usepackage{pst-math}
2 \psset{xunit=0.5cm,yunit=2cm}
3 \begin{pspicture}[linewidth=1pt](-10,-.5)(10,1.5)
4 \psaxes[dx=1cm,Dx=2]{->}(0,0)(-10,0)(10,1.5)
5 \psCumIntegral[plotpoints=200,Simpson=10]{-10}{10}{0 1 GAUSS}
6 \psIntegral[plotpoints=200,Simpson=100,linecolor=green]{.1}{10}(-3,3){0 exch GAUSS}
7 \psIntegral[plotpoints=200,Simpson=10,linecolor=red,
8 fillcolor=red!40,fillstyle=solid,opacity=0.5]{-10}{10}(-4,6){1 GAUSS}
9 \end{pspicture}
0.5
−5 −4 −3 −2 −1 0 1 2 3 4
1 \psset{xunit=1cm,yunit=4cm}
2 \begin{pspicture}[linewidth=1pt](-5,-.2)(5,0.75)
3 \psaxes[dx=1cm,Dx=1,Dy=0.5]{->}(0,0)(-5,0)(5,0.75)
4 \psplot[linecolor=blue,plotpoints=200]{-5}{5}{x abs 2 le {0.25}{0} ifelse}
5 \psplot[linecolor=green,plotpoints=200]{-5}{5}{x abs 1 le {.5}{0} ifelse}
6 \psConv[plotpoints=100,Simpson=1000,linecolor=red]{-5}{5}(-10,10)%
7 {abs 2 le {0.25}{0} ifelse}{abs 1 le {.5} {0} ifelse}
8 \end{pspicture}
In the second example, a convolution is performed using two rectangle functions. The
result (in red) is a trapezoid function.
8 Distributions 32
8 Distributions
All distributions which use the Γ- or ln Γ-function need the pst-math package, it defines
the PostScript functions GAMMA and GAMMALN. pst-func reads by default the PostScript
file pst-math.pro. It is part of any TEX distribution and should also be on your system,
otherwise install or update it from CTAN. It must be the latest version.
4
1 \begin{pspicture *}(-0.5,-0.5)(6.2,5.2)
2 \psaxes{->}(0,0)(6,5)
3 3 \psset{plotpoints=100,linewidth=1pt}
4 \psplot[linecolor=red]{0.01}{4}{ x GAMMA }
2 5 \psplot[linecolor=blue]{0.01}{5}{ x GAMMALN
}
6 \end{pspicture *}
1
0
0 1 2 3 4 5
8.1 Normal distribution (Gauss) 33
(x − µ)2
1 −
f (x) = √ e 2σ 2 (26)
σ 2π
The syntax of the macros is
where the only new parameter are sigma=<value>+ and mue=<value>+ for the hori-
zontal shift, which can also be set in the usual way with \psset. It is significant only for
the \psGauss and \psGaussI macro. The default is sigma=0.5 and mue=0. The integral
is caclulated wuth the Simson algorithm and has one special option, called Simpson,
which defines the number of intervals per step and is predefined with 5.
1.00 y
0.25
−2 −1 0 1
1 \psset{yunit=4cm,xunit=3}
2 \begin{pspicture}(-2,-0.2)(2,1.4)
3 % \psgrid[griddots=10,gridlabels=0pt, subgriddiv=0]
4 \psaxes[Dy=0.25]{->}(0,0)(-2,0)(2,1.25)
5 \uput[-90](6,0){x}\uput[0](0,1){y}
6 \rput[lb](1,0.75){\textcolor{red}{$\sigma =0.5$}}
7 \rput[lb](1,0.5){\textcolor{blue}{$\sigma =1$}}
8 \rput[lb](-2,0.5){$f(x)=\dfrac{1}{\sigma\sqrt{2\pi}}\,e^{-\dfrac{(x-\mu)^2}{2\sigma{}^2}}$}
9 \psGauss[linecolor=red, linewidth=2pt]{-1.75}{1.75}%
10 \psGaussI[linewidth=1pt]{-2}{2}%
11 \psGauss[linecolor=cyan, mue=0.5, linewidth=2pt]{-1.75}{1.75}%
12 \psGauss[sigma=1, linecolor=blue, linewidth=2pt]{-1.75}{1.75}
13 \end{pspicture}
8.2 Binomial distribution 34
These two macros plot binomial distribution, \psBinomialN the normalized one. It is
always done in the x-Intervall [0; 1]. Rescaling to another one can be done by setting the
xunit option to any other value.
The binomial distribution gives the discrete probability distribution Pp (n|N ) of obtain-
ing exactly 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
N n N −n
Pp (n|N ) = p q (27)
n
N!
= pn (1 − p)N −n , (28)
n!(N − n)!
There is a restriction in using the value for N. It depends to the probability, but in
general one should expect problems with N > 100. PostScript cannot handle such
small values and there will be no graph printed. This happens on PostScript side, so
TEX doesn’t report any problem in the log file. The valid options for the macros are
markZeros to draw rectangles instead of a continous line and printValue for printing
the y -values on top of the lines, rotated by 90°. For this option all other options from
section 1 for the macro \psPrintValue are valid, too. [11] Important is the keyword
valuewidth which is preset to 10. If your value has more characters when converting
into a string, it will not be printed or cause an GhostScript error.
The only special option is barwidth, which is a factor (no dimension) and set by default
to 1. This option is only valid for the macro \psBinomial and not for the normalized one!
8.2 Binomial distribution 35
P (X = k)
0.31104
0.27648
0.186624
0.4
0.13824
0.046656
0.036864
0.004096
0.2
−1 0 1 2 3 4 5 6 k
1 \psset{xunit=1cm,yunit=5cm}%
2 \begin{pspicture}(-1,-0.15)(7,0.55)%
3 \psaxes[Dy=0.2,dy=0.2\psyunit]{->}(0,0)(-1,0)(7,0.5)
4 \uput[-90](7,0){$k$} \uput[90](0,0.5){$P(X=k)$}
5 \psBinomial[markZeros,printValue,fillstyle=vlines]{6}{0.4}
6 \end{pspicture}
P (X = k)
0.290304
0.4
0.261274
0.193536
0.130637
0.0774144
0.2
0.0279936
0.0172032
0.0016384
−1 0 1 2 3 4 5 6 7 k
1 \psset{xunit=1cm,yunit=10cm}%
2 \begin{pspicture}(-1,-0.05)(8,0.6)%
3 \psaxes[Dy=0.2,dy=0.2\psyunit]{->}(0,0)(-1,0)(8,0.5)
4 \uput[-90](8,0){$k$} \uput[90](0,0.5){$P(X=k)$}
5 \psBinomial[linecolor=red,markZeros,printValue,fillstyle=solid,
6 fillcolor=blue,barwidth=0.2]{7}{0.6}
7 \end{pspicture}
8.2 Binomial distribution 36
P (X = k)
0.290304
0.4
0.261274
0.193536
0.0774144
0.2
−1 0 1 2 3 4 5 6 7 k
1 \psset{xunit=1cm,yunit=10cm}%
2 \begin{pspicture}(-1,-0.05)(8,0.6)%
3 \psaxes[Dy=0.2,dy=0.2\psyunit]{->}(0,0)(-1,0)(8,0.5)
4 \uput[-90](8,0){$k$} \uput[90](0,0.5){$P(X=k)$}
5 \psBinomial[linecolor=black!30]{0,7}{0.6}
6 \psBinomial[linecolor=blue,markZeros,printValue,fillstyle=solid,
7 fillcolor=blue,barwidth=0.4]{2,5,7}{0.6}
8 \end{pspicture}
P (X = k)
.4
.2
0
0 5 10 15 20 25 30 35 40 45 50 55 k
1 \psset{xunit=0.25cm,yunit=10cm}
2 \begin{pspicture *}(-1,-0.05)(61,0.52)
3 \psaxes[Dx=5,dx=5\psxunit,Dy=0.2,dy=0.2\psyunit]{->}(60,0.5)
4 \uput[-90](60,0){$k$} \uput[0](0,0.5){$P(X=k)$}
5 \psBinomial[markZeros,linecolor=red]{4}{.5}
6 \psset{linewidth=1pt}
7 \psBinomial[linecolor=green]{5}{.5} \psBinomial[linecolor=blue]{10}{.5}
8 \psBinomial[linecolor=red]{20}{.5} \psBinomial[linecolor=magenta]{50}{.5}
9 \psBinomial[linecolor=cyan]{0,55,75}{.5}
10 \end{pspicture *}
The default binomial distribution has the mean of µ = E(X) = N · p and a variant of
σ2 = µ · (1 − p). The normalized distribution has a mean of 0. Instead of P (X = k) we use
X − E(X)
P (Z = z) with Z = and P ← P · σ . The macros use the recursive definition
σ(X)
8.2 Binomial distribution 37
N −k+1 p
P (k) = P (k − 1) · · (29)
k 1−p
P (Z = z)
0.4
0.2
−3 −2 −1 0 1 2 3
z
1 \psset{xunit=1cm,yunit=5cm}%
2 \begin{pspicture}(-3,-0.15)(4,0.55)%
3 \psaxes[Dy=0.2,dy=0.2\psyunit]{->}(0,0)(-3,0)(4,0.5)
4 \uput[-90](4,0){$z$} \uput[0](0,0.5){$P(Z=z)$}
5 \psBinomialN[markZeros,fillstyle=vlines]{6}{0.4}
6 \end{pspicture}
P (Z = z)
0.4
0.2
−8 −7 −6 −5 −4 −3 −2 −1 0 1 2 3 4 5 6 7
z
1 \psset{yunit=10}
2 \begin{pspicture *}(-8,-0.07)(8.1,0.55)
3 \psaxes[Dy=0.2,dy=0.2\psyunit]{->}(0,0)(-8,0)(8,0.5)
4 \uput[-90](8,0){$z$} \uput[0](0,0.5){$P(Z=z)$}
5 \psBinomialN{125}{.5}
6 \psBinomialN[markZeros,linewidth=1pt,linecolor=red]{4}{.5}
7 \end{pspicture *}
8.2 Binomial distribution 38
P (Z = z)
0.4
0.2
−8 −7 −6 −5 −4 −3 −2 −1 0 1 2 3 4 5 6 7
z
1 \psset{yunit=10}
2 \begin{pspicture *}(-8,-0.07)(8.1,0.52)
3 \psaxes[Dy=0.2,dy=0.2\psyunit]{->}(0,0)(-8,0)(8,0.5)
4 \uput[-90](8,0){$z$} \uput[0](0,0.5){$P(Z=z)$}
5 \psBinomialN[markZeros,linecolor=red]{4}{.5}
6 \psset{linewidth=1pt}
7 \psBinomialN[linecolor=green]{5}{.5}\psBinomialN[linecolor=blue]{10}{.5}
8 \psBinomialN[linecolor=red]{20}{.5} \psBinomialN[linecolor=gray]{50}{.5}
9 \end{pspicture *}
For the normalized distribution the plotstyle can be set to curve (plotstyle=curve ),
then the binomial distribution looks like a normal distribution. This option is only valid
for \psBinomialN. The option showpoints is valid if curve was chosen.
P (Z = z)
0.4 b
b b
b b
b b
0.2
b b
b b
b b
b b
b b
b b b b b b b b b b b b b b b b b b b b b b
−4 −3 −2 −1 0 1 2 3
z
1 \psset{xunit=1cm,yunit=10cm}%
2 \begin{pspicture *}(-4,-0.06)(4.1,0.57)%
3 \psaxes[Dy=0.2,dy=0.2\psyunit]{->}(0,0)(-4,0)(4,0.5)%
4 \uput[-90](4,0){$z$} \uput[90](0,0.5){$P(Z=z)$}%
5 \psBinomialN[linecolor=red,fillstyle=vlines,showpoints=true,markZeros]{36}{0.5}%
6 \psBinomialN[linecolor=blue,showpoints=true,plotstyle=curve]{36}{0.5}%
7 \end{pspicture *}
8.2 Binomial distribution 39
P (Z = z)
0.4 b
0.2 b
b
b b
b
b
b b b b
−4 −3 −2 −1 0 1 2 3
z
1 \psset{xunit=1cm,yunit=10cm}%
2 \begin{pspicture *}(-4,-0.06)(4.2,0.57)%
3 \psaxes[Dy=0.2,dy=0.2\psyunit]{->}(0,0)(-4,0)(4,0.5)%
4 \uput[-90](4,0){$z$} \uput[90](0,0.5){$P(Z=z)$}%
5 \psBinomialN[linecolor=red]{10}{0.6}%
6 \psBinomialN[linecolor=blue,showpoints=true,plotstyle=curve]{10}{0.6}%
7 \end{pspicture *}
8.3 Poisson distribution 40
N!
Pp (n|N ) = · pn (1 − p)N −n (30)
n!(N − n)!
λ=N ·p (31)
instead of the sample size N for fixed p, equation (2) then becomes (30);
N! λ n 1 − λ N −n
P λ (n|N ) = (32)
n n!(N − n)! N N
λk −λ
Pλ (X = k) = e
k!
. Letting the sample size become large (N → ∞), the distribution then approaches (with
p = nλ ):
k
n! λ λ n−k
lim P (X = k) = lim 1− (33)
n→∞ n→∞ (n − k)! k! n n
(n − k)! · (n − k + 1) · · · (n − 2)(n − 1)n
= lim · (34)
n→∞ (n − k)! nk
k
λ λ n λ −k
1− 1− (35)
k! n n
k
λ n n−1 n−2 n−k+1
= · lim · · · ... · · (36)
k! n→∞ n n n n
| {z }
→1
n −k
λ λ
1− 1− (37)
n n
| {z } | {z }
→e−λ →1
= λk e k!
−λ
(38)
which is known as the Poisson distribution and has the follwing syntax:
2 http://mathworld.wolfram.com/PoissonProcess.html
8.3 Poisson distribution 41
0.160623
0.160623
P (X = k)
0.137677
0.133853
0.103258
0.0892351
0.0688385
0.0446175
0.0413031
0.1
0.0148725
0.00519899
0.022529
0.00247875
0.0112645
−1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 k
1 \psset{xunit=1cm,yunit=20cm}%
2 \begin{pspicture}(-1,-0.05)(14,0.25)%
3 \uput[-90](14,0){$k$} \uput[90](0,0.2){$P(X=k)$}
4 \psPoisson[linecolor=red,markZeros,fillstyle=solid,
5 fillcolor=blue!10,printValue,valuewidth=20]{13}{6} % N lambda
6 \psaxes[Dy=0.1,dy=0.1\psyunit]{->}(0,0)(-1,0)(14,0.2)
7 \end{pspicture}
0.160623
0.160623
P (X = k)
0.137677
0.133853
0.103258
0.0892351
0.0688385
0.0446175
0.0413031
0.1
0.0148725
0.00247875
−1 0 1 2 3 4 5 6 7 8 9 10 k
1 \psset{xunit=1cm,yunit=20cm}%
2 \begin{pspicture}(-1,-0.05)(14,0.25)%
3 \uput[-90](14,0){$k$} \uput[90](0,0.2){$P(X=k)$}
4 \psPoisson[linecolor=blue,markZeros,fillstyle=solid,barwidth=0.4,
5 fillcolor=blue!10,printValue,valuewidth=20]{10}{6} % N lambda
6 \psaxes[Dy=0.1,dy=0.1\psyunit]{->}(0,0)(-1,0)(11,0.2)
7 \end{pspicture}
8.3 Poisson distribution 42
0.160623
0.160623
P (X = k)
0.137677
0.133853
0.103258
0.0892351
0.0688385
0.0446175
0.0413031
0.1
0.022529
−1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 k
1 \psset{xunit=1cm,yunit=20cm}%
2 \begin{pspicture}(-1,-0.05)(14,0.25)%
3 \uput[-90](14,0){$k$} \uput[90](0,0.2){$P(X=k)$}
4 \psPoisson[printValue,valuewidth=20]{2,11}{6} % M,N lambda
5 \psaxes[Dy=0.1,dy=0.1\psyunit]{->}(0,0)(-1,0)(14,0.2)
6 \end{pspicture}
8.4 Gamma distribution 43
β(βx)α−1 e−βx
f (x) = for x > 0 and α, β > 0
Γ(α)
0.5
0.4
0.3
0.2
0.1
0
0 1 2 3 4 5 6 7 8 9
1 \psset{xunit=1.2cm,yunit=10cm,plotpoints=200}
2 \begin{pspicture *}(-0.75,-0.05)(9.5,0.6)
3 \psGammaDist[linewidth=1pt,linecolor=red]{0.01}{9}
4 \psGammaDist[linewidth=1pt,linecolor=blue,alpha=0.3,beta=0.7]{0.01}{9}
5 \psaxes[Dy=0.1]{->}(0,0)(9.5,.6)
6 \end{pspicture *}
8.5 χ2 -distribution 44
8.5 χ2 -distribution
0.5
0.4
0.3
0.2
0.1
0
0 1 2 3 4 5 6 7 8 9
1 \psset{xunit=1.2cm,yunit=10cm,plotpoints=200}
2 \begin{pspicture *}(-0.75,-0.05)(9.5,.65)
3 \multido{\rnue=0.5+0.5,\iblue=0+10}{10}{%
4 \psChiIIDist[linewidth=1pt,linecolor=blue!\iblue,nue=\rnue]{0.01}{9}}
5 \psaxes[Dy=0.1]{->}(0,0)(9.5,.6)
6 \end{pspicture *}
8.6 Student’s t-distribution 45
A statistical distribution published by William Gosset in 1908 under his pseudonym “Stu-
dent”. The t-distribution with parameter ν has the density function
1 Γ[(ν + 1)/2] 1
f (x) = √ · · for −∞ < x < ∞ and ν > 0
νπ Γ(ν/2) [1 + (x /ν)](ν+1)/2
2
0.4
0.3
0.2
0.1
−4 −3 −2 −1 0 1 2 3 4 5
1 \psset{xunit=1.25cm,yunit=10cm}
2 \begin{pspicture}(-6,-0.1)(6,.5)
3 \psaxes[Dy=0.1]{->}(0,0)(-4.5,0)(5.5,0.5)
4 \psset{linewidth=1pt,plotpoints=100}
5 \psGauss[mue=0,sigma=1]{-4.5}{4.5}
6 \psTDist[linecolor=blue]{-4}{4}
7 \psTDist[linecolor=red,nue=4]{-4}{4}
8 \end{pspicture}
8.7 F -distribution 46
8.7 F -distribution
A continuous statistical distribution which arises in the testing of whether two observed
samples have the same variance.
The F -distribution with parameters µ and ν has the probability function
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0 1 2 3 4
1 \psset{xunit=2cm,yunit=10cm,plotpoints=100}
2 \begin{pspicture *}(-0.5,-0.07)(5.5,0.8)
3 \psline[linestyle=dashed](0.5,0)(0.5,0.75)
4 \psline[linestyle=dashed](! 2 7 div 0)(! 2 7 div 0.75)
5 \psset{linewidth=1pt}
6 \psFDist{0.1}{5}
7 \psFDist[linecolor=red,nue=3,mue=12]{0.01}{5}
8 \psFDist[linecolor=blue,nue=12,mue=3]{0.01}{5}
9 \psaxes[Dy=0.1]{->}(0,0)(5,0.75)
10 \end{pspicture *}
8.8 Beta distribution 47
1.8
1.6
1.4
1.2
1.0
0.8
0.6
0.4
0.2
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
1 \psset{xunit=10cm,yunit=5cm}
2 \begin{pspicture *}(-0.1,-0.1)(1.1,2.05)
3 \psset{linewidth=1pt}
4 \multido{\rbeta=0.25+0.25,\ired=0+5,\rblue=50.0+-2.5}{20}{%
5 \psBetaDist[beta=\rbeta,linecolor=red!\ired!blue!\rblue]{0.01}{0.99}}
6 \psaxes[Dy=0.2,Dx=0.1]{->}(0,0)(1,2.01)
7 \end{pspicture *}
8.9 Cauchy distribution 48
The Cauchy distribution, also called the Lorentz distribution, is a continuous distribution
describing resonance behavior. It also describes the distribution of horizontal distances
at which a line segment tilted at a random angle cuts the x-axis.
The general Cauchy distribution and its cumulative distribution can be written as
1 b
P (x) = (39)
π (x − m)2 + b2
1 1 x−m
D(x) = + arctan (40)
2 π b
where b is the half width at half maximum and m is the statistical median. The macro
has the syntax (with a default setting of m = 0 and b = 1):
\psCauchyI is the integral or the cumulative distribution and often named as D(x).
1.6
1.2
0.8
0.4
−3.0 −2.5 −2.0 −1.5 −1.0 −0.5 0 0.5 1.0 1.5 2.0 2.5
1 \psset{xunit=2,yunit=3cm}
2 \begin{pspicture *}(-3,-0.3)(3.1,2.1)
3 \psset{linewidth=1pt}
4 \multido{\rb=0.1+0.2,\rm=0.0+0.2}{4}{%
5 \psCauchy[b=\rb,m=\rm,linecolor=red]{-2.5}{2.5}
6 \psCauchyI[b=\rb,m=\rm,linecolor=blue]{-2.5}{2.5}}
7 \psaxes[Dy=0.4,dy=0.4,Dx=0.5,dx=0.5]{->}(0,0)(-3,0)(3,2)
8 \end{pspicture *}
8.10 Weibull distribution 49
α
x
−α α−1 −
P (x) = αβ x e β
(41)
α
x
−
D(x) = 1 − e β
(42)
or slightly different as
α α−1 − xβα
P (x) = x e (43)
β
α
− xβ
D(x) = 1 − e (44)
always for x ∈ [0; ∞), where α > 0 is the shape parameter and β > 0 is the scale
parameter of the distribution.
D(x) is the cumulative distribution function of the Weibull distribution. The values for
α and β are preset to 1, but can be changed in the usual way.
The Weibull distribution is related to a number of other probability distributions; in
particular, it interpolates between the exponential distribution (α = 1) and the Rayleigh
distribution (α = 2).
y y
2 2
1 1
0 0
0 1 2
x 0 1 2
x
1 \psset{unit=2}
2 \begin{pspicture *}(-0.5,-0.5)(2.6,2.6)
3 \psaxes{->}(0,0)(2.5,2.5)[$x$,-90][$y$,180]
4 \multido{\rAlpha=0.5+0.5}{5}{%
5 \psWeibull[alpha=\rAlpha]{0}{2.5}
6 \psWeibullI[alpha=\rAlpha,linestyle=dashed]{0}{2.4}}
7 \end{pspicture *}
8 %
9 \begin{pspicture *}(-0.5,-0.5)(2.6,2.6)
10 \psaxes{->}(0,0)(2.5,2.5)[$x$,-90][$y$,180]
8.10 Weibull distribution 50
11 \multido{\rAlpha=0.5+0.5,\rBeta=0.2+0.2}{5}{%
12 \psWeibull[alpha=\rAlpha,beta=\rBeta]{0}{2.5}
13 \psWeibullI[alpha=\rAlpha,beta=\rBeta,linestyle=dashed]{0}{2.4}}
14 \end{pspicture *}
The starting value for x should always be 0 or greater, if it is less than 0 then the
macro draws a line from (#1,0) to (0,0) and starts \psWeinbull with 0.
8.11 Vasicek distribution 51
For a homogenous portfolio of infinite granularity the portfolio loss distribution is given
by √
N −1 (P D) − 1 − R2 · N −1 (x)
P(L(P ) < x) = 1 − N
R
L(P ) denotes the portfolio loss in percent, pd is the uniform default probability, and R2
is the uniform asset correlation.
They are preset to pd = 0.22 and R2 = 0.11 and can be overwritten in the usual way.
The macro uses the PostScript function norminv from the package pst-math which is
loaded by default and also shown in the following example.
0
1
−1
−2
−3
1 \psset{xunit=5}
2 \begin{pspicture}(-0.1,-3)(1.1,4)
3 \psaxes{->}(0,0)(0,-3)(1.1,4)
4 \psVasicek[plotpoints=200,linecolor=blue]{0}{0.9999}
5 \psVasicek[plotpoints=200,linecolor=red,pd=0.2,R2=0.3]{0}{0.9999}
6 \psplot[plotpoints=200,algebraic,linestyle=dashed]{0}{0.9999}{norminv(x)}
7 \end{pspicture}
9 The Lorenz curve 52
0.8
0.6
0.4
0.2
0 x
0 0.2 0.4 0.6 0.8 1.0
1 \psset{lly=-6mm,llx=-5mm}
2 \psgraph[Dx=0.2,Dy=0.2,axesstyle=frame](0,0)(1,1){6cm}{6cm}
3 \psline[linestyle=dashed](1,1)
4 \psLorenz *[linecolor=blue!30,linewidth=1.5pt]{0.50 0.10 0.3 0.09 0.01 }
5 \psLorenz[linecolor=blue!30,plotstyle=bezier]{0.50 0.10 0.3 0.09 0.01 }
6 \psLorenz[linecolor=red,linewidth=1.5pt]{0.50 0.10 0.3 0.09 0.01 }
7 \endpsgraph
There exists an optional argument Gini for the output of the Gini coefficient. It is by
default set to false. With truethe value is caculated and printed below the origin of
the coordinate system.
9 The Lorenz curve 53
y
rs
1.0
0.8
rs
0.6
0.4
rs
0.2
rs
rs
0 rs
x
0 0.2 0.4 0.6 0.8 1.0
Gini: 0.378712
1 \psset{lly=-13mm,llx=-5mm}
2 \psgraph[Dx=0.2,Dy=0.2,axesstyle=frame](0,0)(1,1){6cm}{6cm}
3 \psline[linestyle=dashed](1,1)
4 \psLorenz[linewidth=1.5pt,Gini]{0.025 0.275 0.2 0.270 0.230}
5 \psLorenz[plotstyle=dots,dotstyle=square,dotscale=1.5]{0.025 0.275 0.2 0.270 0.230}
6 \endpsgraph
10 \psLame – Lamé Curve, a superellipse 54
Superellipses with a = b are also known as Lamé curves or Lamé ovals and the restric-
tion to r > 2 is sometimes also made. The following table summarizes a few special
cases. Piet Hein used 52 with a number of different ab ratios for various of his projects.
For example, he used ab = 65 for Sergels Torg (Sergel’s Square) in Stockholm, and ab = 23
for his table.
1 (squashed) diamond
2 ellipse
5
2 Piet Hein’s „superellipse“
\psLame [Options] {r }
3 Lamé worked on a wide variety of different topics. His work on differential geometry and contributions
to Fermat’s Last Theorem are important. He proved the theorem for n = 7 in 1839.
10 \psLame – Lamé Curve, a superellipse 55
−8 −6 −4 −2 2 4 6 8
−2
−4
−6
−8
1 \definecolorseries{col}{rgb}{last}{red}{blue}
2 \resetcolorseries[41]{col}
3 \psset{unit=.5}
4 \pspicture(-9,-9)(9,9)
5 \psaxes[Dx=2,Dy=2,tickstyle=bottom,ticksize=2pt]{->}(0,0)(-9,-9)(9,9)
6 \multido{\rA=0.2+0.1,\iA=0+1}{40}{%
7 \psLame[radiusA=8,radiusB=7,linecolor={col!![\iA]},linewidth=.5pt]{\rA}}
8 \endpspicture
11 \psThomae – the popcorn function 56
Thomae’s function, also known as the popcorn function, the raindrop function, the ruler
function or the Riemann function, is a modification of the Dirichlet function. This real-
valued function f (x) is defined as follows:
(
1 p
if x = q is a rational number q
f (x) =
0 if x is irrational
It is assumed here that gcd(p, q) = 1 and q > 0 so that the function is well-defined and
nonnegative. The syntax is:
(x0,x1) is the plotted interval, both values must be grater zero and x1 > x0 . The plotted
number of points is the third parameter.
1 b b
b b b b
b b b b b b
b b b b b b b b
b b b b b b b b b b
b b b b b b b b b b b b
b b b b b b b b b b b b b b
b b b b b b b b b b b b b b b b
b b b b b b b b b b b b b b b b b b
b b b b b
b b
b
b b
b b b b b b b b b
b b b b b b b bb b b b b b b b b b b b b b b b b b b b b
bb b
b
b b b bb b b b b b bb b b b b b b b bb
b
b
b b b b b
b b
b b b
b b
b bb
bb
bbb b bb bb b b b b b b b bb b b b b b b b
bb b b b b b b b bb b b b b b b b
b b b b bb
bb bb bbb b b b b b b b b b bb b b b b b b b b b b b b b b bb bbb bb b b b b b b b b b bb b bb bbb bb
bb b b bb bbbb bbb bbb b b b bbbb b b b b b bb b b b b b bb b b b b b b b bb b b b b b bb b b b b b bbb b b b b b b b b bb b b b b b b b b b bbb b b b b b b b b b b b b b b b bb b b b b b b bb b b bb b b b b b b b b b b bbbb b b b b b b b b b b bb b b bb b b b b b b bb b b b b b b b b b b b b b b b bbb b b b b b b b b bb b b b b b b b b bbb b b b b bb b b b b b bb b b b b b b b bb b b b b b bb b b b b b b bb b b b b b b b b b b b b b b b b b b b b b bb b bb b b b b b b b b b b b b b b b b b b b b bb b b b b bb b b b b b b b b bb b b b b b b b b b b b b b bbb b b b b b b b b b b bb b b b b b b b b b b b b b b b bbb b b b b b b b b b b b b b b bb b b b b b b b b b b bbb b b b b b b b b b b b b bb b b b b b b b b bb b b b b bb b b b b b b b b b b b b b b b b b b b b b b b b
b b b bb
b b bbbbb bbbbb b b b b b b bbbbbbbbbbbbb b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b bb b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b bb b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b bb
b b b b b b b b b b b b b bb b b b b b b bbb b b bb b b bbbbbbb bbbbbbbbb bbbbbbbb bbbbbbbb bbbbbb b b bbbbbbbb b b bbbbbbbbb b b b b bbbbbbbbbbb bbbbbbbbbbbbb b b bbbbbbbbbbbbbbb b b b b bbbbbbbbbbbbbbbbb b b bbbbbbbbbbbbbbbbbbbb b b b bbbbbbbbbbbbbbbbbbbbbbbb b bb bbbbbbbbbbbbbbbbbbbbbbbbbbbb bbb bb b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b bbb bb b bbb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
b b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb b bb b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb b b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb b b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb b bb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb bb b b b b bb bbb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bb bb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb b b bbb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bb b b b b b bb b b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb bb bb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bb b b b b bb bbb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb bb b b b b b b bbb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bb bb b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb bb b b bbb b b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
b bb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb bb b b b bbb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb bb bb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb b b bbb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b bb b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b bbb
bb b b bb b b b b bb b bb bb bb bbb b bb b bb b bb b bb b bbb b b bbb bbb bbb bbb bb bb b b bbb bbb b bb b bb b b bbb bbb bbb bbb bbb bbb bb bb b bb bbb bb b bb bb bbb b bb b bbb bb b bb b bb bbbb bb b bb bbb bb bbb bb b b b b bb b b bb b b bb b bb bbb bb b bbbbbbbbb b bb b b b b b bbbbbbbbb b bb b bb bbbbbbb bb bb bbbbbbb bb bb bb bbbbbbb b b b b b bbbbbbbb b b b bbbbbb bb bb bbbbbbb b bbbbbb bbbb b bbb bb bb bb bb bb bb b b bb b b b b b b b bb bbbbbbbbbbbbbbbb bb bb b b b b b b b bb b b bbbbbbbbbbbbbbbbbbbbb bb b b b bb bb bb b bbbbbbbbbbbbbbbbbbbbbb bb b bbbbbbbbbbbbbbbbbbbbbbbbbb bb b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb b b b b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb b b b b b b b b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb b b b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb bb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb b b b b b b b b b b b
0 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb b b b b b b b b b b b b b b b b b b b b b b b b b b b b b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb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bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb b b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb b b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb b b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb b b b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb b b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb b b b b b b b b b b b b b
b b b b bb bb b b bb b bb bb b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b
b b bb b b b b b b b b b b b b b b b b b b b bb b b b b b b b b b b b
b bb b b b b b b b b b b b b b b b b b b b b b b b b b b b b
b b bb b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b bb b
0 1 2
1 \psset{unit=4cm}
2 \begin{pspicture}(-0.1,-0.2)(2.5,1.15)
3 \psaxes{->}(0,0)(2.5,1.1)
4 \psThomae[dotsize=2.5pt,linecolor=red](0,2){300}
5 \end{pspicture}
12 \psWeierstrass – a pathological function 57
Without the optional argument the mandatory one is a, otherwise it is b and the optional
one a. Without setting the optional argument epsilon the value of 1.e-8 will be used.
0.4
0.3
0.2
0.1
0
0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6 1.8 2.0
−0.1
−0.2
−0.3
−0.4
1 \psset{yunit=10,xunit=5}
2 \begin{pspicture}(-0.1,-0.5)(2.1,0.5)
3 \psaxes[Dx=0.2,Dy=0.1,ticksize=-2pt 0,
4 labelFontSize=\scriptstyle]{->}(0,0)(0,-0.5)(2.1,0.5)
5 \psWeierstrass[linecolor=red](0,2){2}
6 \psWeierstrass[linecolor=green,epsilon=1.e-15](0,2){3}
7 \psWeierstrass[linecolor=blue,epsilon=1.e-5](0,2){4}
8 \end{pspicture}
The original Weierstraß function can be used with the optional argument:
∞
X
f (x) = an cos(bn πx)
n=0
12 \psWeierstrass – a pathological function 58
1.5
1.0
0.5
−0.5
−1.0
−1.5
−2.0
1 \psset{unit=2cm,linewidth=0.5pt,plotpoints=5000}
2 \begin{pspicture}(-2.1,-2.1)(2.1,2.1)
3 \psaxes[Dx=0.5,Dy=0.5,ticksize=-2pt 0,
4 labelFontSize=\scriptstyle]{->}(0,0)(-2,-2)(2,2)
5 \psWeierstrass[linecolor=red](-2,2)[0.5]{3}
6 \psWeierstrass[linecolor=blue!70](-2,2)[0.5]{10}
7 \end{pspicture}
13 \psplotImp – plotting implicit defined functions 59
For a given area, the macro calculates in a first step row by row for every pixel (1pt) the
function f (x, y) and checks for avchanging of the value from f (x, y) < 0 to f (x, y) > 0
or vice versa. If this happens, then the pixel must be part of the curve of the function
f (x, y) = 0. In a second step the same is done column by column. This may take some
time because an area of 400 × 300 pixel needs 120 thousand calculations of the function
value. The user still defines this area in his own coordinates, the translation into pixel
(pt) is done internally by the macro itself. The only special keyword is stepFactor which
is preset to 0.67 and controls the horizontal and vertical step width.
x2 + y 2 − 4 = 0
2
−3 −2 −1 1 2 3
−1
−2
−3
1 \begin{pspicture *}(-3,-3.2)(3.5,3.5)
2 \psaxes{->}(0,0)(-3,-3)(3.2,3)%
3 \psplotImp[linewidth=2pt,linecolor=red](-5,-2.1)(5,2.1){ x dup mul y dup mul add 4 sub
}
4 \uput[45](0,2){$x^2+y^2-4=0$}
5 \psplotImp[linewidth=2pt,linecolor=blue,algebraic](-5,-3)(4,2.4){ (x+1)^2+y^2-4 }
6 \end{pspicture *}
13 \psplotImp – plotting implicit defined functions 60
2
x2 + y 2 − 8(x2 − y 2 ) = 0
−3 −2 −1 1 2 3
−1
−2
1 \begin{pspicture *}(-3,-2.2)(3.5,2.5)
2 \psaxes{->}(0,0)(-3,-2)(3.2,2)%
3 \psplotImp[linewidth=2pt,linecolor=blue](-5,-2.2)(5,2.4){%
4 /xqu x dup mul def
5 /yqu y dup mul def
6 xqu yqu add dup mul 2 dup add 2 mul xqu yqu sub mul sub }
7 \uput*[0](-3,2){$\left(x^2+y^2\right)^2-8(x^2-y^2)=0$}
8 \psplotImp[linewidth=1pt,linecolor=red,algebraic](-5,-2.2)(5,2.4){% Lemniskate a =2
9 (x^2+y^2)^2-4*(x^2-y^2) }
10 \end{pspicture *}
x3 + y 3 − 4xy = 0
2
−3 −2 −1 1 2 3
−1
−2
−3
1 \begin{pspicture *}(-3,-3.2)(3.5,3.5)
2 \psaxes{->}(0,0)(-3,-3)(3.2,3)%
3 \psplotImp[linewidth=2pt,linecolor=green](-6,-6)(4,2.4){%
4 x 3 exp y 3 exp add 4 x y mul mul sub }
5 \uput*[45](-2.5,2){$\left(x^3+y^3\right)-4xy=0$}
6 \end{pspicture *}
13 \psplotImp – plotting implicit defined functions 61
−5 −4 −3 −2 −1 1 2 3 4 5
−1
−2
−3
1 \begin{pspicture *}(-5,-3.2)(5.5,4.5)
2 \psaxes{->}(0,0)(-5,-3)(5.2,4)%
3 \psplotImp[algebraic,linecolor=red](-6,-4)(5,4){ y*cos(x*y)-0.2 }
4 \psplotImp[algebraic,linecolor=blue](-6,-4)(5,4){ y*cos(x*y)-1.2 }
5 \end{pspicture *}
Using the polarplot option implies using the variables r and phi for describing the
function, y and x are not respected in this case. Using the algebraic option for polar
plots are also possible (see next example).
f (r, φ) = r − 2 = 0
2
−3 −2 −1 1 2 3
−1
−2
1 \begin{pspicture *}(-3,-2.5)(3.75,2.75)\psaxes{->}(0,0)(-3,-2.5)(3.2,2.5)%
2 \psplotImp[linewidth=2pt,linecolor=cyan,polarplot](-6,-3)(4,2.4){ r 2 sub }% circle r
=2
3 \uput*[45](0.25,2){$f(r,\phi)=r-2=0$}
4 \psplotImp[polarplot,algebraic](-6,-3)(4,2.4){ r-1 }% circle r=1
5 \end{pspicture *}
13 \psplotImp – plotting implicit defined functions 62
1
f (r, φ) = r 2 − r · sin2 φ = 0
2
−5 −4 −3 −2 −1 1 2 3 4 5
−1
−2
1 \begin{pspicture *}(-5,-2.2)(5.5,3.5)
2 \pscircle(0,0){1}%
3 \psaxes{->}(0,0)(-5,-2)(5.2,3)%
4 \multido{\rA=0.01+0.2}{5}{%
5 \psplotImp[linewidth=1pt,linecolor=blue,polarplot](-6,-6)(5,2.4){%
6 r dup mul 1.0 r div sub phi sin dup mul mul \rA\space sub }}%
7 \uput*[45](0,2){$f(r,\phi)=\left(r^2-\frac{1}{r}\right)\cdot\sin^2\phi=0$}
8 \end{pspicture *}
−4 −3 −2 −1 1 2 3 4
−1
−2
−3
1 \begin{pspicture *}(-4,-3.2)(4.5,4.5)
2 \psaxes{->}(0,0)(-4,-3)(4.2,4)%
3 \psplotImp[algebraic,polarplot,linecolor=red](-5,-4)(5,4){ r+cos(phi/r)-2 }
4 \end{pspicture *}
The data of an implicit plot can be written into an external file for further purposes.
Use the optional argument [pstricks-add]saveData to write the x|y values into the file
\jobname.data. The file name can be changed with the keyword [pstricks-add]filename.
When running a TEX file from within a GUI it may be possible that you get a writeaccess
error from GhostScript, because it prevents writing into a file when called from another
program. In this case run GhostScript on the PostScript-output from the command
13 \psplotImp – plotting implicit defined functions 63
line.
−1 1
x
−1
1 \begin{pspicture *}(-3,-3)(3,3)
2 \psaxes[linewidth=0.25pt,
3 xlabelPos=top,
4 labelFontSize=\scriptscriptstyle,
5 labelsep=2pt,
6 ticksize=0.05]{<->}(0,0)(-2,-1.75)(2,2)[x,0][y,90]
7 \psplotImp[linecolor=red,linewidth=1pt,stepFactor=0.2,saveData,
8 algebraic](-2.5,-1.75)(2.5,2.5){x^2+(5* y/4-sqrt(abs(x)))^2-2.5}
9 \end{pspicture *}
...
[
-1.53237 0.695058
-1.53237 1.29957
]
[
-1.52534 0.666941
-1.52534 1.32065
]
...
In one array all y values for the same x value are stored.
14 \psVolume – Rotating functions around the x-axis 64
This macro shows the behaviour of a rotated function around the x-axis.
\psVolume [Options] (xMin,xMax ){steps }{function f (x)}
1 1 1
0 0 0
1 2 1 2 1 2
−1 −1 −1
−2 −2 −2
2 2 2
1 1 1
0 0 0
1 2 1 2 1 2
−1 −1 −1
−2 −2 −2
1 \begin{pspicture}(-0.5,-2)(5,2.5)
2 \psaxes{->}(0,0)(0,-2)(3,2.5)
3 \psVolume[fillstyle=solid,fillcolor=magenta!30](0,4){1}{x sqrt}
4 \psline{->}(4,0)(5,0)
5 \end{pspicture}
6 %
7 \begin{pspicture}(-0.5,-2)(5,2.5)
8 \psaxes{->}(0,0)(0,-2)(3,2.5)
9 \psVolume[fillstyle=solid,fillcolor=red!40](0,4){2}{x sqrt}
10 \psline{->}(4,0)(5,0)
11 \end{pspicture}
12 %
13 \begin{pspicture}(-0.5,-2)(5,2.5)
14 \psaxes{->}(0,0)(0,-2)(3,2.5)
15 \psVolume[fillstyle=solid,fillcolor=blue!40](0,4){4}{x sqrt}
16 \psline{->}(4,0)(5,0)
17 \end{pspicture}
18
19 \begin{pspicture}(-0.5,-2)(5,2.5)
20 \psaxes{->}(0,0)(0,-2)(3,2.5)
21 \psVolume[fillstyle=solid,fillcolor=green!40](0,4){8}{x sqrt}
22 \psline{->}(4,0)(5,0)
23 \end{pspicture}
24 %
25 \begin{pspicture}(-0.5,-2)(5,2.5)
26 \psaxes{->}(0,0)(0,-2)(3,2.5)
14 \psVolume – Rotating functions around the x-axis 65
27 \psVolume[fillstyle=solid,fillcolor=yellow!40](0,4){16}{x sqrt}
28 \psline{->}(4,0)(5,0)
29 \end{pspicture}
30 %
31 \begin{pspicture}(-0.5,-2)(5,2.5)
32 \psaxes{->}(0,0)(0,-2)(3,2.5)
33 \psVolume[fillstyle=solid,fillcolor=cyan!40](0,4){32}{x sqrt}
34 \psline{->}(4,0)(5,0)
35 \end{pspicture}
3 3
2 2
1 1
0 0
1 2 1 2
−1 −1
−2 −2
−3 −3
−4 −4
1 \psset{xunit=2}
2 \begin{pspicture}(-0.5,-4)(3,4)
3 \psaxes{->}(0,0)(0,-4)(3,4)
4 \psVolume[fillstyle=solid,fillcolor=cyan!40](0,1){4}{x}
5 \psVolume[fillstyle=solid,fillcolor=yellow!40](1,2){4}{x dup mul}
6 \psline(2,0)(3,0)
7 \end{pspicture}
8 %
9 \begin{pspicture}(-0.5,-4)(3,4)
10 \psaxes{->}(0,0)(0,-4)(3,4)
11 \psVolume[fillstyle=solid,fillcolor=cyan!40](0,1){20}{x}
12 \psVolume[fillstyle=solid,fillcolor=yellow!40](1,2){20}{x dup mul}
13 \psline(2,0)(3,0)
14 \end{pspicture}
15 Examples 66
15 Examples
1 \psset{xunit=0.5cm,yunit=20cm,arrowscale=1.5}
2 \begin{pspicture}(-1,-0.1)(21,0.2)
3 \psChiIIDist[linewidth=1pt,nue=5]{0.01}{19.5}
4 \psaxes[labels=none,ticks=none]{->}(20,0.2)
5 \pscustom[fillstyle=solid,fillcolor=red!30]{%
6 \psChiIIDist[linewidth=1pt,nue=5]{8}{19.5}%
7 \psline(20,0)(8,0)}
8 \end{pspicture}
0.4
0.3 ν = 0.02
0.2
0.1
x
−5 −4 −3 −2 −1 0 1 2 3 4 5
1 \psset{xunit=0.9cm,yunit=9cm}
2 \newcommand *\studentT[1]{%
3 \begin{pspicture}(-6,-0.1)(6,0.5)
4 \psaxes[Dy=0.1]{->}(0,0)(-5,0)(5.5,0.45)[$x$,0][$y$,90]
5 \pscustom[fillstyle=solid,fillcolor=blue!40,opacity=0.4,linecolor=red,linestyle=none
]{%
6 \psline(0,0)(-5,0)
15.2 An animation of a distribution 67
7 \psTDist[nue=#1]{-5}{5}
8 \psline(5,0)(0,0)
9 }
10 \psTDist[nue=#1,linecolor=red,linewidth=1pt]{-5}{5}
11 \rput(3,0.3){$\nu = #1$}
12 \end{pspicture}}
13
14 \begin{center}
15 \begin{animateinline}[poster=first,controls,palindrome]{10}
16 \multiframe{50}{rA=0.02+0.02}{\studentT{\rA}}
17 \end{animateinline}
18 \captionof{figure}{Student’s $t$-distribution.}
19 \end{center}
16 List of all optional arguments for pst-func 68
References
[1] Denis Girou. Présentation de PSTricks. Cahier GUTenberg, 16:21–70, April 1994.
[2] Michel Goosens, Frank Mittelbach, Sebastian Rahtz, Denis Roegel, and Herbert
Voß. The LATEX Graphics Companion. Addison-Wesley Publishing Company,
Reading, Mass., 2007.
[3] Laura E. Jackson and Herbert Voß. Die Plot-Funktionen von pst-plot. Die
TEXnische Komödie, 2/02:27–34, June 2002.
[4] Nikolai G. Kollock. PostScript richtig eingesetzt: vom Konzept zum praktischen
Einsatz. IWT, Vaterstetten, 1989.
[5] Herbert Voß. Chaos und Fraktale selbst programmieren: von Mandelbrotmengen
über Farbmanipulationen zur perfekten Darstellung. Franzis Verlag, Poing, 1994.
[6] Herbert Voß. Die mathematischen Funktionen von PostScript. Die TEXnische
Komödie, 1/02, March 2002.
[7] Herbert Voß. PSTricks – Grafik für TEX und LATEX. DANTE – Lehmanns,
Heidelberg/Berlin, 6. edition, 2010.
[8] Herbert Voß. Typesetting mathematics with LATEX. UIT, Cambridge, 2010.
[9] Herbert Voß. PSTricks – Graphics for TEX and LATEX. UIT, Cambridge, 2011.
[13] Timothy van Zandt. PSTricks - PostScript macros for generic TEX. http://www.
tug.org/application/PSTricks, 1993.
[14] Timothy van Zandt. multido.tex - a loop macro, that supports fixed-point
addition. CTAN:/graphics/pstricks/generic/multido.tex, 1997.
[15] Timothy van Zandt. pst-plot: Plotting two dimensional functions and data.
CTAN:graphics/pstricks/generic/pst-plot.tex, 1999.
[16] Timothy van Zandt and Denis Girou. Inside PSTricks. TUGboat, 15:239–246,
September 1994.
Index
Symbols F
[, 62 File
– pst-math.pro, 32
A Fourier sums, 21
algebraic, 59, 61
G
B GAMMA, 32
b, 48 GAMMALN, 32
Bézier, 5 Gini, 52
Bézier curve, 5 Gini coefficient, 52
barwidth, 34
Bayesian analysis, 47 K
Bernstein-Bézier, 5 Keyvalue
black, 12 – black, 12
– curve, 38
C – dashed, 12
Cauchy distribution, 48 Keyword
Chebyshev polynomials, 7 – [, 62
ChebyshevT, 7 – algebraic, 59, 61
\ChebyshevT, 7 – b, 48
ChebyshevU, 7 – barwidth, 34
\ChebyshevU, 7 – coeff, 12
coeff, 12 – constI, 24
coefficients, 11 – constII, 24
constI, 24 – cosCoeff, 21
constII, 24 – decimals, 19
cosCoeff, 21 – Derivation, 12
curve, 38 – dZero, 12
– envelope, 17
D
– epsilon, 57
dashed, 12
– epsZero, 12
decimals, 19
– Gini, 52
density function, 45
– m, 48
Derivation, 12
– markZeros, 12, 19, 34
Dirichlet, 56
– mue, 33
dZero, 12
– Newton, 19
E – nue, 27
envelope, 17 – onlyNode, 19
Environment – onlyYVal, 19
– pspicture, 12, 59 – originV, 19
– pspicture*, 59 – plotpoints, 5, 24, 30
epsilon, 57 – plotstyle, 38
epsZero, 12 – PointName, 19
70
Index 71
– polarplot, 61 – \psFDist, 46
– PrintCoord, 19 – \psFourier, 21
– printValue, 34 – \psGammaDist, 43
– radiusA, 54 – \psGauss, 33
– radiusB, 54 – \psGaussI, 30, 33
– showpoints, 38 – \psIntegral, 30
– sigma, 33 – \psLame, 54
– Simpson, 30, 33 – \psLorenz*, 52
– sinCoeff, 21 – \psModBessel, 27
– stepFactor, 59 – \psplot, 64
– tEnd, 17 – \psplotImp, 59
– tStart, 17 – \psPoisson, 40
– valuewidth, 34 – \psPolynomial, 11, 12, 21
– xShift, 11, 12, 19 – \psPrintValue, 34
– xStart, 30 – \psset, 12, 33
– xunit, 34 – \psSi, 28
– ydecimals, 19 – \pssi, 28
– yShift, 19 – \psTDist, 45
– zeroLineColor, 12 – \psThomae, 56
– zeroLineStyle, 12 – \psVolume, 64
– zeroLineTo, 12 – \psWeierstrass, 57
– zeroLineWidth, 12 – \psWeinbull, 50
– \psZero, 19
L markZeros, 12, 19, 34
Lamé, 54 mue, 33
Lorentz distribution, 48
Lorenz curve, 52 N
Newton, 19
M nue, 27
m, 48
Macro O
– \ChebyshevT, 7 onlyNode, 19
– \ChebyshevU, 7 onlyYVal, 19
– \psBernstein, 17 originV, 19
– \psBessel, 24
– \psBetaDist, 47 P
– \psBezier, 5 Package
– \psBinomial, 34 – pst-func, 4, 7, 11, 32
– \psBinomialN, 34, 38 – pst-math, 4, 32, 51
– \psCauchy, 48 – pst-plot, 4, 24
– \psCauchyI, 48 – pst-xkey, 4
– \psChiIIDist, 44 – pstricks, 4, 24
– \psCi, 28 – pstricks-add, 4, 59
– \psConv, 30 parametric plot, 54
– \psCumIngegral, 30 Piet Hein, 54
– \psCumIntegral, 30 plotpoints, 5, 24, 30
Index 72
xStart, 30
xunit, 34
Y
ydecimals, 19
yShift, 19
Z
zeroLineColor, 12
zeroLineStyle, 12
zeroLineTo, 12
zeroLineWidth, 12