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 | |
parent | 8fcb0c5c689043e5e4ab34ffe816bab9cf95e382 (diff) |
pst-func (3aug17)
git-svn-id: svn://tug.org/texlive/trunk@44944 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/doc/generic/pst-func/Changes | 1 | ||||
-rw-r--r-- | Master/texmf-dist/doc/generic/pst-func/pst-func-doc.pdf | bin | 3783927 -> 3879798 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/generic/pst-func/pst-func-doc.tex | 80 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/pst-func/pst-func.tex | 409 |
4 files changed, 354 insertions, 136 deletions
diff --git a/Master/texmf-dist/doc/generic/pst-func/Changes b/Master/texmf-dist/doc/generic/pst-func/Changes index 0f8ff6bfb23..e8f600adba0 100644 --- a/Master/texmf-dist/doc/generic/pst-func/Changes +++ b/Master/texmf-dist/doc/generic/pst-func/Changes @@ -1,4 +1,5 @@ ..... pst-func.tex +0.87 2017-08-03 - modified algorithm for the distributions 0.86 2017-06-21 - allow alternating colors for bars 0.85 2017-04-18 - allow framing of function values (ts) 0.84 2017-03-11 - some more modifications to the binomial distributions (ts) diff --git a/Master/texmf-dist/doc/generic/pst-func/pst-func-doc.pdf b/Master/texmf-dist/doc/generic/pst-func/pst-func-doc.pdf Binary files differindex 8e06fc2fc7d..7057bb9fb7b 100644 --- a/Master/texmf-dist/doc/generic/pst-func/pst-func-doc.pdf +++ b/Master/texmf-dist/doc/generic/pst-func/pst-func-doc.pdf diff --git a/Master/texmf-dist/doc/generic/pst-func/pst-func-doc.tex b/Master/texmf-dist/doc/generic/pst-func/pst-func-doc.tex index 66f4b4a9888..39c151fd184 100644 --- a/Master/texmf-dist/doc/generic/pst-func/pst-func-doc.tex +++ b/Master/texmf-dist/doc/generic/pst-func/pst-func-doc.tex @@ -1334,34 +1334,40 @@ The syntax is: the sequence $m\ldots n$ is plotted \end{itemize} -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 \Lkeyword{markZeros} to draw rectangles instead +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. +The valid options for the macros are \Lkeyword{markZeros} to draw rectangles instead 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 for the macro \Lcs{psPrintValue} are valid, too.~ \cite{pst-tools} Important is the keyword \Lkeyword{valuewidth} -which is preset to 10. If your value has more characters when converting into a string, it will +which is preset to 15. If your value has more characters when converting into a string, it will not be printed or cause an GhostScript error. -Special options are +Special options are \begin{itemize} \item \Lkeyword{barwidth}, which is a factor (no dimension) and set by default to 1. This option is not valid for the macro \Lcs{psBinomialN}! +\item \Lkeyword{alternateColors} is a new fillstyle, so the colors alternates between \Lkeyword{fillcolorA} and \Lkeyword{fillcolorB}, only valid for \Lcs{psBinomial}. +\item \Lkeyword{fillcolorA} alternate color one. +\item \Lkeyword{fillcolorB} alternate color two. \item \Lkeyword{labelangle} is the rotation of the printed values, default is 90\textdegree \item \Lkeyword{xlabelsep} is the x-separation of the printed values, default is 0 (no dimension) \item \Lkeyword{labelsep} is the y-separation of the printed values, default is 0.2 (no dimension) \item \Lkeyword{LabelColor} is the color of the printed values, default is black +\item \Lkeyword{PrintVLimit} is the value limit for the printed values, default is $1e-64$, smaller values are not printed. +\item \Lkeyword{Switch2Log} is the value for $N$ where the new calculation is used, default is $80$. \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 \item \Lkeyword{VLines} this option is only valid for the macros \Lcs{psBinomialF} and \Lcs{psBinomialFS}, default is false. Draws the vertical lines dashed. \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 \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 \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 -\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 +\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 \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 \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 \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 +\item \Lkeyword{LeftClipX} gives the left end of the clipping area for \Lcs{psBinomialC}, default is $-1$. +\item \Lkeyword{RightClipX} gives the distance to $N$ for the right end of the clipping area for \Lcs{psBinomialC}, default is $1$. \end{itemize} + \psset[pst-func]{barwidth=1} \begin{LTXexample}[pos=t,preset=\centering] \psset{xunit=1cm,yunit=5cm}% @@ -1378,7 +1384,7 @@ labelangle=80,LabelColor=blue]{6}{0.4} \begin{pspicture}(-1,-0.05)(8,0.6)% \psaxes[Dy=0.2,dy=0.2\psyunit]{->}(0,0)(-1,0)(8,0.5) \uput[-90](8,0){$k$} \uput[90](0,0.5){$P(X=k)$} -\psBinomialC[fillstyle=solid,opacity=0.5,fillcolor=cyan,plotstyle=curve]{7}{0.6} +\psBinomialC[fillstyle=solid,opacity=0.5,fillcolor=cyan]{7}{0.6} \psBinomial[linecolor=red,markZeros,printValue,fillstyle=solid, fillcolor=blue,barwidth=0.2,xlabelsep=-0.05]{7}{0.6} \end{pspicture} @@ -1392,7 +1398,7 @@ labelangle=80,LabelColor=blue]{6}{0.4} \psBinomial[linecolor=black!30]{0,7}{0.6} \psBinomial[linecolor=blue,markZeros,printValue,fillstyle=solid, fillcolor=blue,barwidth=0.4]{2,5,7}{0.6} -\psBinomialC[,showpoints=true,plotstyle=curve]{7}{0.6} +\psBinomialC[showpoints=true]{7}{0.6} \end{pspicture} \end{LTXexample} @@ -1416,7 +1422,7 @@ labelangle=80,LabelColor=blue]{6}{0.4} \psaxes[labelFontSize=\scriptstyle,xticksize=0 1.07,yticksize=0 16,tickcolor=gray!50, Dy=0.1,dy=0.1,Dx=1,dx=1,Ox=0]{->}(0,0)(-0.9,0)(16,1.1) \uput[-90](15.8,0){$z$}\uput[0](0,1.1){$P_{0,15}^{100}(Z=z)$} -\psBinomialC[linecolor=cyan,fillstyle=solid,fillcolor=cyan!50,opacity=0.4,plotstyle=curve]{40}{0.15}% +\psBinomialC[linecolor=cyan,fillstyle=solid,fillcolor=cyan!50,opacity=0.4]{40}{0.15}% \psBinomial[markZeros,linecolor=BrickRed,fillstyle=solid,fillcolor=BrickRed,barwidth=0.75,opacity=0.6]{1,16,40}{0.15}% \psBinomialFS[markZeros,linecolor=Green,fillstyle=solid,fillcolor=orange,barwidth=0.3,opacity=0.6]{0,16,40}{0.15}% \psBinomialF[linecolor=gray,fillstyle=solid,fillcolor=yellow,barwidth=0.4,opacity=0.5]{3,16,40}{0.15} @@ -1438,6 +1444,57 @@ radiusout=3.5,radiusinL=0,radiusinR=2,LineEnding=true,leftEnd=1,rightEnd=3]{0,10 \end{pspicture*} \end{LTXexample} +\begin{LTXexample}[pos=t,preset=\centering] +\begin{pspicture}[showgrid=false](-.75,-1.8)(13.2,4.7)% +{\psset{xunit=1cm,yunit=12cm}% +\psset{plotpoints=500,arrowscale=1.3,arrowinset=0.05,arrowlength=1.9,comma} +\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) +\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)$} +\rput(-0.05,0){% +\psBinomialC[linecolor=Green,fillstyle=solid,fillcolor=gray,opacity=0.25,plotstyle=curve,linestyle=dashed]{10}{0.8}} +\rput(0.05,0){% +\psBinomialC[linecolor=cyan,fillstyle=solid,fillcolor=cyan,opacity=0.25,plotstyle=curve,linestyle=dashed]{10}{0.7}% +\psBinomial[markZeros,linecolor=cyan,fillstyle=solid,fillcolor=cyan,barwidth=0.2,opacity=0.85]{0,8,10}{0.7}%,printValue +\psBinomial[markZeros,linecolor=magenta,fillstyle=solid,fillcolor=magenta,barwidth=0.2,opacity=0.85]{9,10,10}{0.7} +} +\rput(-0.05,0){% +\psBinomialC[linecolor=Green,fillstyle=solid,fillcolor=gray,opacity=0.25,plotstyle=curve,linestyle=dashed]{10}{0.8} +\psBinomial[markZeros,linecolor=DeepSkyBlue4,fillstyle=solid,fillcolor=DeepSkyBlue4,barwidth=0.2,opacity=0.85]{0,8,10}{0.8}%,printValue +\psBinomial[markZeros,linecolor=BrickRed,fillstyle=solid,fillcolor=BrickRed,barwidth=0.2,opacity=0.85]{9,10,10}{0.8} +} +\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) +\rput(5,0.33){\psframebox[fillstyle=solid,fillcolor=orange!30,linestyle=none]{$n=10$}} +} +\end{pspicture} +\end{LTXexample} + +\begin{LTXexample}[pos=t,preset=\centering] +\begin{pspicture}[showgrid=false](-.75,-1.8)(13.2,4.7)% +{\psset{xunit=1cm,yunit=12cm}% +\psset{plotpoints=500,arrowscale=1.3,arrowinset=0.05,arrowlength=1.9,comma} +\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) +\uput[-90](11.9,0){$z$} \uput[0](0,0.32){$P_{0,7}^{10}(Z=z)$} +\psBinomialC[linecolor=cyan,fillstyle=solid,fillcolor=cyan,opacity=0.25,plotstyle=curve,linestyle=dashed,LeftClipX=4,RightClipX=-3]{10}{0.7}% +\psBinomial[markZeros,linecolor=cyan,fillstyle=solid,fillcolor=cyan,barwidth=0.2,opacity=0.85]{0,8,10}{0.7}%,printValue +\psBinomial[markZeros,linecolor=magenta,fillstyle=solid,fillcolor=magenta,barwidth=0.2,opacity=0.85]{9,10,10}{0.7} +\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) +\rput(5,0.33){\psframebox[fillstyle=solid,fillcolor=orange!30,linestyle=none]{$n=10$}} +} +\end{pspicture} +\end{LTXexample} + +\begin{LTXexample}[pos=t,preset=\centering] +{\psset{xunit=0.07cm,yunit=10cm}% +\begin{pspicture}[showgrid=false](-6,-0.1)(220,1.1)% +\psset{plotpoints=500,arrowscale=1.3,arrowinset=0.05,arrowlength=1.9,comma} +\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) +\uput[-90](219,0){$k$} \uput[0](0,1.05){$P(X=k)=B(300;\frac{1}{3};k)$} +\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 +\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} +\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} +\end{pspicture}} +\end{LTXexample} + The default binomial distribution has the mean of $\mu=E(X)=N\cdot p$ and a variant of $\sigma^2=\mu\cdot(1-p)$. The normalized distribution has a mean of $0$. Instead of $P(X=k)$ @@ -1521,6 +1578,9 @@ valid for \Lcs{psBinomialN}. The option \Lkeyword{showpoints} is valid if \Lkeyv + + + \clearpage \subsection{Poisson distribution} Given a Poisson process\footnote{\url{http://mathworld.wolfram.com/PoissonProcess.html}}, 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{% |