diff options
author | Karl Berry <karl@freefriends.org> | 2017-08-03 21:09:51 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-08-03 21:09:51 +0000 |
commit | 93a965bb76ab3c748f5c198d09bd03b4aa87f932 (patch) | |
tree | 5a8c7c58012c6e608257bdf409e0f3eea68b049c /Master/texmf-dist/tex/generic/pst-func | |
parent | 8fcb0c5c689043e5e4ab34ffe816bab9cf95e382 (diff) |
pst-func (3aug17)
git-svn-id: svn://tug.org/texlive/trunk@44944 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/pst-func')
-rw-r--r-- | Master/texmf-dist/tex/generic/pst-func/pst-func.tex | 409 |
1 files changed, 283 insertions, 126 deletions
diff --git a/Master/texmf-dist/tex/generic/pst-func/pst-func.tex b/Master/texmf-dist/tex/generic/pst-func/pst-func.tex index b40b4dca356..c636a2b4b26 100644 --- a/Master/texmf-dist/tex/generic/pst-func/pst-func.tex +++ b/Master/texmf-dist/tex/generic/pst-func/pst-func.tex @@ -31,8 +31,8 @@ % interface to the `xkeyval' package \pst@addfams{pst-func} % -\def\fileversion{0.86} -\def\filedate{2017/06/21} +\def\fileversion{0.87} +\def\filedate{2017/08/03} \message{`PST-func' v\fileversion, \filedate\space (hv)} % \pstheader{pst-func.pro} @@ -521,6 +521,8 @@ \psIntegral[#1]{#2}{#3}(#4,#5){pop pop x #6\space x t neg add #7\space mul}% }% % +\define@key[psset]{pst-func}{PrintVLimit}[1e-6]{\def\psFunc@PrintVLimit{#1 }} +\define@key[psset]{pst-func}{Switch2Log}[80]{\def\psFunc@Switch2Log{#1 }} \define@boolkey[psset]{pst-func}[Pst@]{printValue}[true]{} \define@boolkey[psset]{pst-func}[Pst@]{LineEnding}[true]{} \define@boolkey[psset]{pst-func}[Pst@]{VLines}[true]{} @@ -537,14 +539,11 @@ \define@key[psset]{pst-func}{LineEndColorR}[red]{\pst@getcolor{#1}\psk@LineEndColorR} \define@key[psset]{pst-func}{fillcolorA}[blue!40]{\pst@getcolor{#1}\psk@fillcolorA} \define@key[psset]{pst-func}{fillcolorB}[red!40]{\pst@getcolor{#1}\psk@fillcolorB} - +\define@key[psset]{pst-func}{vlinestyle}[solid]{\def\psvlinestyle{#1}} \def\psfs@alternateColors{} \def\pst@alternateColors{alternateColors} - -\define@key[psset]{pst-func}{vlinestyle}[solid]{\def\psvlinestyle{#1}} -\psset[pst-func]{printValue=false,barwidth=1,labelangle=90,xlabelsep=0,LabelColor=black,LineEndColorL=green,LineEndColorR=red, - radiusout=2,radiusinL=0,radiusinR=1.5,LineEnding=true,leftEnd=1,rightEnd=2,VLines=false, - fillcolorA=blue!40,fillcolorB=red!40} +% +\psset[pst-func]{printValue=false,barwidth=1,labelangle=90,xlabelsep=0,LabelColor=black,LineEndColorL=green,LineEndColorR=red,radiusout=2, radiusinL=0,radiusinR=1.5,LineEnding=true,leftEnd=1,rightEnd=2,VLines=false,fillcolorA=blue!40,fillcolorB=red!40,PrintVLimit=1e-64,Switch2Log=80} % \def\psBinomial{\pst@object{psBinomial}} \def\psBinomial@i#1#2{\psBinomial@ii#1,,,\@nil{#2}}% @@ -559,13 +558,15 @@ \fi} % \def\psBinomial@iii#1#2#3#4{% + \addbefore@par{valuewidth=15}% \begin@OpenObj - \addto@pscode{ + \addto@pscode{% /toggle false def \ifx\psk@fillstylename\pst@alternateColors /ColA { \pst@usecolor\psk@fillcolorA } def /ColB { \pst@usecolor\psk@fillcolorB } def \fi + /ValueSwitch2Log \psFunc@Switch2Log\space def /scx { \pst@number\psxunit mul } def /scy { \pst@number\psyunit mul } def /m #1 def @@ -575,34 +576,68 @@ /dx \psFunc@barwidth 2 div def /q 1 p sub def /kOld dx neg m add def - kOld scx 0 moveto % starting point - 0 1 m 1 sub { - /k exch def % save loop variable - k 0 eq - { /Y q N exp def } - { /Y Y N k sub 1 add mul k div p mul q div def } - ifelse - } for - m 1 n { % n-m+1 times - /k exch def % save loop variable - k 0 eq - { /Y q N exp def } - { /Y Y N k sub 1 add mul k div p mul q div def } - ifelse % recursive definition - \ifx\psk@fillstylename\pst@alternateColors - newpath + kOld scx 0 moveto % starting point# +%%---------------------------------------------------------------------------------------------------------------------------------------------------------------- +%%-------------------- Code, der bei gro{\ss}em N \"{u}ber den Logarithmus arbeitet von Manuel Luque --------------------------------------------- + /SumLog {% log(1) + log(2) + ... + log(n) = log(n!) + 1 dict begin % Erwartet die Eingabe eines Wertes, n\"{a}mlich bis zu welchem Wert addiert werden soll ---> n + /nV exch def % der \"{u}bergebene Wert wird in nV abgespeichert + /iV 1 def % Startwert ist iV=1 + 0 nV { iV log add /iV iV 1 add def } repeat % 0 + log(1) + log(2) + ... + log(n) Die Null ist dazu n\"{o}tig um die erste Addition machen zu k\"{o}nnen + end + } def + /binomial_comb{ % log(N!) - log(k!) - log((n-k)!) = log[N!/(k!*(n-k)!)] + 2 dict begin + /nV exch def + /NV exch def + NV SumLog nV SumLog sub + NV nV sub SumLog sub + end + } def + /PnN { + 3 dict begin + /pV exch def + /nV exch def + /NV exch def + 10 + NV nV binomial_comb + nV pV log mul + NV nV sub 1 pV sub log mul add add + exp + } def +%%------------------------------------------------------------------------------------------------ +%%------------------------------------------------------------------------------------------------ + N ValueSwitch2Log gt { } {% + 0 1 m 1 sub {% + /k exch def % save loop variable + k 0 eq + { /Y q N exp def } + { /Y Y N k sub 1 add mul k div p mul q div def } + ifelse + } for + } ifelse + m 1 n {% % n-m+1 times + /k exch def % save loop variable + N ValueSwitch2Log gt { N k p PnN /Y exch def } + { k 0 eq + { /Y q N exp def } + { /Y Y N k sub 1 add mul k div p mul q div def } + ifelse + } ifelse % recursive definition + \ifx\psk@fillstylename\pst@alternateColors + newpath kOld scx 0 moveto \fi kOld scx Y scy L k dx add scx Y scy L \ifPst@markZeros k dx add scx 0 L kOld 1 add scx 0 L \fi - \ifx\psk@fillstylename\pst@alternateColors + \ifx\psk@fillstylename\pst@alternateColors closepath - gsave toggle {ColA}{ColB} ifelse fill grestore + gsave toggle {ColA}{ColB} ifelse \tx@setTransparency fill grestore /toggle toggle not def \fi \ifPst@printValue gsave \psk@PSfont findfont \psk@fontscale scalefont setfont \pst@usecolor\psk@LabelColor % - Y \psk@valuewidth string cvs + Y \psFunc@PrintVLimit le { () } { Y \psk@valuewidth\space string cvs } ifelse \ifPst@comma dot2comma \fi k scx \psk@fontscale 2 div add \psFunc@xlabelsep scx add Y scy \pst@number\pslabelsep add moveto @@ -617,6 +652,7 @@ \end@OpenObj }% % +% \def\psBinomialN{\pst@object{psBinomialN}}% \def\psBinomialN@i#1#2{% \leavevmode @@ -687,8 +723,10 @@ \else\psBinomialF@iii{#1}{#2}{#3}{#5}\fi \fi}% \def\psBinomialF@iii#1#2#3#4{% + \addbefore@par{valuewidth=15}% \begin@OpenObj - \addto@pscode{ + \addto@pscode{% + /ValueSwitch2Log \psFunc@Switch2Log\space def /scx { \pst@number\psxunit mul } def /scy { \pst@number\psyunit mul } def /m #1 def @@ -709,23 +747,63 @@ kOld scx 0 L stroke \fi } { } ifelse } ifelse kOld scx 0 moveto % starting point - 0 1 m 1 sub { - /k exch def % save loop variable - k 0 eq - { /Y q N exp def - /F Y def} - { /Y Y N k sub 1 add mul k div p mul q div def - /F F Y add def } - ifelse - } for - m 1 n { % n-m+1 times - /k exch def % save loop variable - k 0 eq - { /Y q N exp def - /F Y def } - { /Y Y N k sub 1 add mul k div p mul q div def - /F F Y add def } - ifelse % recursive definition +%%---------------------------------------------------------------------------------------------------------------------------------------------------------------- +%%-------------------- Code, der bei gro{\ss}em N \"{u}ber den Logarithmus arbeitet von Manuel Luque --------------------------------------------- + /SumLog {% log(1) + log(2) + ... + log(n) = log(n!) + 1 dict begin % Erwartet die Eingabe eines Wertes, n\"{a}mlich bis zu welchem Wert addiert werden soll ---> n + /nV exch def % der \"{u}bergebene Wert wird in nV abgespeichert + /iV 1 def % Startwert ist iV=1 + 0 nV { iV log add /iV iV 1 add def } repeat % 0 + log(1) + log(2) + ... + log(n) Die Null ist dazu n\"{o}tig um die erste Addition machen zu k\"{o}nnen + end + } def + /binomial_comb{ % log(N!) - log(k!) - log((n-k)!) = log[N!/(k!*(n-k)!)] + 2 dict begin + /nV exch def + /NV exch def + NV SumLog nV SumLog sub + NV nV sub SumLog sub + end + } def + /PnN { + 3 dict begin + /pV exch def + /nV exch def + /NV exch def + 10 + NV nV binomial_comb + nV pV log mul + NV nV sub 1 pV sub log mul add add + exp + } def +%%------------------------------------------------------------------------------------------------ +%%------------------------------------------------------------------------------------------------ + 0 1 m 1 sub { + /k exch def % save loop variable + N ValueSwitch2Log gt { k 0 eq + { N k p PnN /Y exch def /F Y def } + { N k p PnN /Y exch def /F F Y add def } + ifelse } + { k 0 eq + { /Y q N exp def + /F Y def } + { /Y Y N k sub 1 add mul k div p mul q div def + /F F Y add def + } ifelse + } ifelse + } for + m 1 n { % n-m+1 times + /k exch def % save loop variable + N ValueSwitch2Log gt { k 0 eq + { N k p PnN /Y exch def /F Y def } + { N k p PnN /Y exch def /F F Y add def } ifelse } + { k 0 eq + { /Y q N exp def + /F Y def } + { /Y Y N k sub 1 add mul k div p mul q div def + /F F Y add def + } ifelse + } ifelse % recursive definition + F 1 gt { /F 1 def } if \ifPst@markZeros kOld scx F scy L k dx add scx F scy L k dx add scx 0 L kOld 1 add scx 0 L \else kOld scx F scy newpath \psFunc@radiusout 0 360 arc kOld scx F scy \psFunc@radiusinL 360 0 arcn closepath \pst@usecolor\psk@LineEndColorL fill @@ -754,7 +832,7 @@ \fi\fi\fi \ifPst@printValue gsave \psk@PSfont findfont \psk@fontscale scalefont setfont \pst@usecolor\psk@LabelColor % - F \psk@valuewidth string cvs + Y \psFunc@PrintVLimit le { () } { F \psk@valuewidth\space string cvs } ifelse \ifPst@comma dot2comma \fi k scx \psk@fontscale 2 div add \psFunc@xlabelsep scx add F scy \pst@number\pslabelsep add moveto @@ -778,8 +856,10 @@ \else\psBinomialFS@iii{#1}{#2}{#3}{#5}\fi \fi}% \def\psBinomialFS@iii#1#2#3#4{% + \addbefore@par{valuewidth=15}% \begin@OpenObj - \addto@pscode{ + \addto@pscode{% + /ValueSwitch2Log \psFunc@Switch2Log\space def /scx { \pst@number\psxunit mul } def /scy { \pst@number\psyunit mul } def /m #1 def @@ -791,37 +871,75 @@ \ifPst@markZeros /kOld dx neg m add def \else /kOld m def \fi kOld scx 0 moveto % starting point - 0 1 m 1 sub { - /k exch def % save loop variable - k 0 eq - { /Y q N exp def - /F Y def - /FS 1 F sub def} - { /Y Y N k sub 1 add mul k div p mul q div def - /F F Y add def - /FS 1 F sub def} - ifelse - } for - m 1 n { % n-m+1 times - /k exch def % save loop variable - k 0 eq - { /Y q N exp def - /F Y def - /FS 1 F sub def} - { /Y Y N k sub 1 add mul k div p mul q div def - /F F Y add def - /FS 1 F sub def} - ifelse % recursive definition +%%---------------------------------------------------------------------------------------------------------------------------------------------------------------- +%%-------------------- Code, der bei gro{\ss}em N \"{u}ber den Logarithmus arbeitet von Manuel Luque --------------------------------------------- + /SumLog {% log(1) + log(2) + ... + log(n) = log(n!) + 1 dict begin % Erwartet die Eingabe eines Wertes, n\"{a}mlich bis zu welchem Wert addiert werden soll ---> n + /nV exch def % der \"{u}bergebene Wert wird in nV abgespeichert + /iV 1 def % Startwert ist iV=1 + 0 nV { iV log add /iV iV 1 add def } repeat % 0 + log(1) + log(2) + ... + log(n) Die Null ist dazu n\"{o}tig um die erste Addition machen zu k\"{o}nnen + end + } def + /binomial_comb{ % log(N!) - log(k!) - log((n-k)!) = log[N!/(k!*(n-k)!)] + 2 dict begin + /nV exch def + /NV exch def + NV SumLog nV SumLog sub + NV nV sub SumLog sub + end + } def + /PnN { + 3 dict begin + /pV exch def + /nV exch def + /NV exch def + 10 + NV nV binomial_comb + nV pV log mul + NV nV sub 1 pV sub log mul add add + exp + } def +%%------------------------------------------------------------------------------------------------ +%%------------------------------------------------------------------------------------------------ + 0 1 m 1 sub { + /k exch def % save loop variable + N ValueSwitch2Log gt { k 0 eq + { N k p PnN /Y exch def /F Y def /FS 1 F sub def } + { N k p PnN /Y exch def /F F Y add def /FS 1 F sub def } + ifelse } + { k 0 eq + { /Y q N exp def + /F Y def /FS 1 F sub def } + { /Y Y N k sub 1 add mul k div p mul q div def + /F F Y add def /FS 1 F sub def } + ifelse } ifelse + } for + m 1 n { % n-m+1 times + /k exch def % save loop variable + N ValueSwitch2Log gt { k 0 eq + { N k p PnN /Y exch def /F Y def /FS 1 F sub def } + { N k p PnN /Y exch def /F F Y add def /FS 1 F sub def } ifelse } + { k 0 eq + { /Y q N exp def + /F Y def /FS 1 F sub def } + { /Y Y N k sub 1 add mul k div p mul q div def + /F F Y add def /FS 1 F sub def } + ifelse + } ifelse % recursive definition + FS 0 lt { /FS 0 def } if \ifPst@markZeros kOld scx FS scy L k dx add scx FS scy L k dx add scx 0 L kOld 1 add scx 0 L \else \ifPst@LineEnding k 0 eq - { } - { kOld scx FS scy newpath \psFunc@radiusout 0 360 arc kOld scx FS scy \psFunc@radiusinL 360 0 arcn closepath \pst@usecolor\psk@LineEndColorL fill } ifelse \fi + { \psFunc@leftEnd neg scx 1 scy moveto \psFunc@radiusout neg 1 scy L gsave \pst@usecolor\pslinecolor stroke grestore } if + k m eq {kOld scx \psFunc@radiusout add FS Y add scy moveto kOld scx FS Y add scy newpath \psFunc@radiusout 0 360 arc kOld scx FS Y add scy \psFunc@radiusinR 360 0 arcn closepath + gsave \pst@usecolor\psk@LineEndColorR fill grestore } if + kOld scx FS scy newpath \psFunc@radiusout 0 360 arc kOld scx FS scy \psFunc@radiusinL 360 0 arcn closepath \pst@usecolor\psk@LineEndColorL fill % } ifelse + \fi kOld \ifPst@LineEnding\psFunc@radiusout\pst@number\psxunit div add \fi - k 0 eq - { \psFunc@leftEnd sub } - { } ifelse +% k 0 eq +% { \psFunc@leftEnd sub } +% { } ifelse scx FS scy moveto k 1 add \ifPst@LineEnding\psFunc@radiusout\pst@number\psxunit div sub \fi @@ -846,10 +964,10 @@ \fi\fi\fi \ifPst@printValue gsave \psk@PSfont findfont \psk@fontscale scalefont setfont \pst@usecolor\psk@LabelColor % - FS \psk@valuewidth string cvs - \ifPst@comma dot2comma \fi - k scx \psk@fontscale 2 div add \psFunc@xlabelsep scx add - FS scy \pst@number\pslabelsep add moveto + Y \psFunc@PrintVLimit le { () } { FS \psk@valuewidth\space string cvs } ifelse + \ifPst@comma dot2comma \fi + k 0.1 add scx \psk@fontscale 2 div add \psFunc@xlabelsep scx add + FS scy \pst@number\pslabelsep add moveto \psFunc@langle rotate show grestore \fi /kOld kOld 1 add def @@ -858,67 +976,106 @@ \end@OpenObj }% % +% +\define@key[psset]{pst-func}{LeftClipX}[-1]{\def\psFunc@LeftClipX{#1 }} +\define@key[psset]{pst-func}{RightClipX}[-1]{\def\psFunc@RightClipX{#1 }} +\psset[pst-func]{LeftClipX=-1,RightClipX=1} \def\psBinomialC{\pst@object{psBinomialC}} \def\psBinomialC@i#1#2{% \leavevmode \pst@killglue \begingroup - \use@par + \use@par + \begin{psclip}% +{\psframe[linestyle=none,fillstyle=none](\psFunc@LeftClipX,-0.1)(!#1 \psFunc@RightClipX\space add 1)}% +% \use@par \init@pscode - \def\cplotstyle{curve}% - \ifx\psplotstyle\cplotstyle \@nameuse{beginplot@\psplotstyle}\fi - \addto@pscode{% - \ifx\psplotstyle\cplotstyle /Curve true def \else /Curve false def \fi + \beginplot@cspline +% \addto@pscode{/D {} def mark}% + \addto@pscode{% /scx { \pst@number\psxunit mul } def /scy { \pst@number\psyunit mul } def /N #1 def - /p #2 def % Wahrscheinlichkeit - /q 1 p sub def % q = 1 - p - /E N p mul def % Erwartungswert - /sigma E q mul sqrt def % Varianz - /dx 1.0 sigma div 2 div def - /xOld dx neg E sub sigma div def - /xEnd xOld neg E add dx add scx def -% /xOld dx neg sigma div def -% /xEnd xOld neg dx add scx def - Curve - { /Coors [xOld dx sub scx 0] def }% saves the coordinates for curve - { xOld scx 0 moveto }% starting point - ifelse - 0 1 N { % N times - /k exch def % save loop variable - k 0 eq - { /Y q N exp def } - { /Y Y N k sub 1 add mul k div p mul q div def } - ifelse % recursive definition - /x k 1 div dx add def - /y Y 1 mul def % normalize - Curve - { x dx sub scx y scy Coors aload length 2 add array astore /Coors exch def} - { xOld scx y scy L x scx y scy L - \ifPst@markZeros x scx 0 L \fi % - } ifelse - \ifPst@printValue - gsave \psk@PSfont findfont \psk@fontscale scalefont setfont \pst@usecolor\psk@LabelColor % - y \psk@valuewidth string cvs %/Output exch def - \ifPst@comma dot2comma \fi % do we have to change dot to comma - x dx sub scx \psk@fontscale 2 div add \psFunc@xlabelsep scx add - y scy \pst@number\pslabelsep add moveto - \psFunc@langle rotate show grestore - \fi - /xOld x def - } for - Curve { [ xEnd 0 Coors aload pop } if% showpoints on top of the stack - }% -\ifx\psplotstyle\cplotstyle\@nameuse{endplot@\psplotstyle}\else - \psk@fillstyle - \pst@stroke -\fi + /p #2 def % Wahrscheinlichkeit + /q 1 p sub def % q = 1 - p + /E N p mul def % Erwartungswert + /sigma E q mul sqrt def % Varianz + /dx 1.0 2 div def + /xOld dx neg 3 sub def + /xEnd 0 def + /Coors [xOld dx sub scx 0] def % speichern der Koordinaten f\"{u}r den Spline +%%---------------------------------------------------------------------------------------------------------------------------------------------------------------- +%%-------------------- Code, der \"{u}ber den Logarithmus arbeitet von Manuel Luque --------------------------------------------- + /SumLog {% log(1) + log(2) + ... + log(n) = log(n!) + 1 dict begin % Erwartet die Eingabe eines Wertes, n\"{a}mlich bis zu welchem Wert addiert werden soll ---> n + /nV exch def % der \"{u}bergebene Wert wird in nV abgespeichert + /iV 1 def % Startwert ist iV=1 + 0 nV { iV log add /iV iV 1 add def } repeat % 0 + log(1) + log(2) + ... + log(n) Die Null ist dazu n\"{o}tig um die erste Addition machen zu k\"{o}nnen + end + } def + /binomial_comb{ % log(N!) - log(k!) - log((n-k)!) = log[N!/(k!*(n-k)!)] + 2 dict begin + /nV exch def + /NV exch def + NV SumLog nV SumLog sub + NV nV sub SumLog sub + end + } def + /PnN { + 3 dict begin + /pV exch def + /nV exch def + /NV exch def + 10 + NV nV binomial_comb + nV pV log mul + NV nV sub 1 pV sub log mul add add + exp + } def +%%------------------------------------------------------------------------------------------------ +%%------------------------------------------------------------------------------------------------ +%------------------------------- 3 Punkte um die Kurve links auf Null zu bringen mit dem weiter oben gew\"{a}hlten Startwert sind es also 4 ------------ + /x -2 dx add def + /y 0 def + x dx sub scx y scy Coors aload length 2 add array astore /Coors exch def + /x -0.65 dx add def + /y N 0 p PnN 10 -1.3 exp mul def + x dx sub scx y scy Coors aload length 2 add array astore /Coors exch def + /x -0.375 dx add def + /y N 0 p PnN 3 div def + x dx sub scx y scy Coors aload length 2 add array astore /Coors exch def +%---------------------------- Ende der 3 Punkte und Beginn eigentlicher Code ---------------- + 0 1 N {% % Schleife geht von 0 bis N in 1-er Schritten + /k exch def % save loop variable + N k p PnN /Y exch def + /x k dx add def + /y Y def + x dx sub scx y scy Coors aload length 2 add array astore /Coors exch def + /xOld x def + } for +%--------------------------- Ende des eigentlichen Codes und Beginn von --- +%------------------------------- 4 Punkte um die Kurve rechts auf Null zu bringen ----------- + /x N 0.375 add dx add def + /y Y 3 div def + x dx sub scx y scy Coors aload length 2 add array astore /Coors exch def + /x N 0.65 add dx add def + /y Y 10 -1.3 exp mul def + x dx sub scx y scy Coors aload length 2 add array astore /Coors exch def + /x N 2 add dx add def + /y 0 def + x dx sub scx y scy Coors aload length 2 add array astore /Coors exch def + /x N 3 add dx add def + /y 0 def + x dx sub scx y scy Coors aload length 2 add array astore /Coors exch def +%---------------------------- Ende der 4 Punkte und Laden der Koordinaten des arrays ; L\"{o}schen (pop) von showpoints??---------------------- + [ xEnd 1 add 0 Coors aload pop % showpoints on top of the stack + }% +\endplot@cspline \use@pscode +\end{psclip}% \endgroup \ignorespaces}% % -% \def\psPoisson{\pst@object{psPoisson}}% with contributions from Gerry Coombes \def\psPoisson@i#1#2{\psPoisson@ii#1,,\@nil{#2}}% \def\psPoisson@ii#1,#2,#3\@nil#4{% |