texlive[44944] Master/texmf-dist: pst-func (3aug17)

commits+karl at tug.org commits+karl at tug.org
Thu Aug 3 23:09:51 CEST 2017


Revision: 44944
          http://tug.org/svn/texlive?view=revision&revision=44944
Author:   karl
Date:     2017-08-03 23:09:51 +0200 (Thu, 03 Aug 2017)
Log Message:
-----------
pst-func (3aug17)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/generic/pst-func/Changes
    trunk/Master/texmf-dist/doc/generic/pst-func/pst-func-doc.pdf
    trunk/Master/texmf-dist/doc/generic/pst-func/pst-func-doc.tex
    trunk/Master/texmf-dist/tex/generic/pst-func/pst-func.tex

Modified: trunk/Master/texmf-dist/doc/generic/pst-func/Changes
===================================================================
--- trunk/Master/texmf-dist/doc/generic/pst-func/Changes	2017-08-03 21:09:37 UTC (rev 44943)
+++ trunk/Master/texmf-dist/doc/generic/pst-func/Changes	2017-08-03 21:09:51 UTC (rev 44944)
@@ -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)

Modified: trunk/Master/texmf-dist/doc/generic/pst-func/pst-func-doc.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/generic/pst-func/pst-func-doc.tex
===================================================================
--- trunk/Master/texmf-dist/doc/generic/pst-func/pst-func-doc.tex	2017-08-03 21:09:37 UTC (rev 44943)
+++ trunk/Master/texmf-dist/doc/generic/pst-func/pst-func-doc.tex	2017-08-03 21:09:51 UTC (rev 44944)
@@ -1334,34 +1334,40 @@
     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 @@
 \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 @@
 \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 @@
 \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 @@
 \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 @@
 
 
 
+
+
+
 \clearpage
 \subsection{Poisson distribution}
 Given a Poisson process\footnote{\url{http://mathworld.wolfram.com/PoissonProcess.html}}, 

Modified: trunk/Master/texmf-dist/tex/generic/pst-func/pst-func.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/pst-func/pst-func.tex	2017-08-03 21:09:37 UTC (rev 44943)
+++ trunk/Master/texmf-dist/tex/generic/pst-func/pst-func.tex	2017-08-03 21:09:51 UTC (rev 44944)
@@ -31,8 +31,8 @@
 % interface to the `xkeyval' package
 \pst at 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 at key[psset]{pst-func}{PrintVLimit}[1e-6]{\def\psFunc at PrintVLimit{#1 }}
+\define at key[psset]{pst-func}{Switch2Log}[80]{\def\psFunc at Switch2Log{#1 }}
 \define at boolkey[psset]{pst-func}[Pst@]{printValue}[true]{}
 \define at boolkey[psset]{pst-func}[Pst@]{LineEnding}[true]{}
 \define at boolkey[psset]{pst-func}[Pst@]{VLines}[true]{}
@@ -537,15 +539,12 @@
 \define at key[psset]{pst-func}{LineEndColorR}[red]{\pst at getcolor{#1}\psk at LineEndColorR}
 \define at key[psset]{pst-func}{fillcolorA}[blue!40]{\pst at getcolor{#1}\psk at fillcolorA}
 \define at key[psset]{pst-func}{fillcolorB}[red!40]{\pst at getcolor{#1}\psk at fillcolorB}
-
+\define at key[psset]{pst-func}{vlinestyle}[solid]{\def\psvlinestyle{#1}}
 \def\psfs at alternateColors{}
 \def\pst at alternateColors{alternateColors}
-
-\define at 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 at object{psBinomial}}
 \def\psBinomial at i#1#2{\psBinomial at ii#1,,,\@nil{#2}}%
 \def\psBinomial at ii#1,#2,#3,#4\@nil#5{%
@@ -559,13 +558,15 @@
   \fi}
 %
 \def\psBinomial at iii#1#2#3#4{%
+ \addbefore at par{valuewidth=15}%
   \begin at OpenObj
-  \addto at pscode{
+  \addto at pscode{%
     /toggle false def
     \ifx\psk at fillstylename\pst at alternateColors
        /ColA { \pst at usecolor\psk at fillcolorA } def
        /ColB { \pst at usecolor\psk at fillcolorB } def
     \fi
+    /ValueSwitch2Log \psFunc at Switch2Log\space def
     /scx { \pst at number\psxunit mul } def
     /scy { \pst at number\psyunit mul } def
     /m #1 def
@@ -575,34 +576,68 @@
     /dx \psFunc at 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 at fillstylename\pst at 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 at fillstylename\pst at alternateColors
+        newpath
         kOld scx 0 moveto
       \fi
       kOld scx Y scy L k dx add scx Y scy L
       \ifPst at markZeros k dx add scx 0 L kOld 1 add scx 0 L \fi
-      \ifx\psk at fillstylename\pst at alternateColors 
+      \ifx\psk at fillstylename\pst at alternateColors
         closepath
-        gsave toggle {ColA}{ColB} ifelse fill grestore
+        gsave toggle {ColA}{ColB} ifelse \tx at setTransparency fill grestore
         /toggle toggle not def
       \fi
       \ifPst at printValue
         gsave \psk at PSfont findfont \psk at fontscale scalefont setfont \pst at usecolor\psk at LabelColor %
-        Y \psk at valuewidth string cvs
+        Y \psFunc at PrintVLimit le { () } { Y \psk at valuewidth\space string cvs } ifelse
         \ifPst at comma dot2comma \fi
         k scx \psk at fontscale 2 div add \psFunc at xlabelsep scx add
         Y scy \pst at number\pslabelsep add moveto
@@ -617,6 +652,7 @@
   \end at OpenObj
 }%
 %
+%
 \def\psBinomialN{\pst at object{psBinomialN}}%
 \def\psBinomialN at i#1#2{%
   \leavevmode
@@ -687,8 +723,10 @@
     \else\psBinomialF at iii{#1}{#2}{#3}{#5}\fi
   \fi}%
 \def\psBinomialF at iii#1#2#3#4{%
+ \addbefore at par{valuewidth=15}%
   \begin at OpenObj
-  \addto at pscode{
+  \addto at pscode{%
+    /ValueSwitch2Log \psFunc at Switch2Log\space def
     /scx { \pst at number\psxunit mul } def
     /scy { \pst at 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 at 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 at radiusout 0 360 arc kOld scx F scy \psFunc at radiusinL 360 0 arcn closepath \pst at usecolor\psk at LineEndColorL fill
@@ -754,7 +832,7 @@
      \fi\fi\fi
       \ifPst at printValue
         gsave \psk at PSfont findfont \psk at fontscale scalefont setfont \pst at usecolor\psk at LabelColor %
-        F \psk at valuewidth string cvs
+        Y \psFunc at PrintVLimit le { () } { F \psk at valuewidth\space string cvs } ifelse
         \ifPst at comma dot2comma \fi
         k scx \psk at fontscale 2 div add \psFunc at xlabelsep scx add
         F scy \pst at number\pslabelsep add moveto
@@ -778,8 +856,10 @@
     \else\psBinomialFS at iii{#1}{#2}{#3}{#5}\fi
   \fi}%
 \def\psBinomialFS at iii#1#2#3#4{%
+ \addbefore at par{valuewidth=15}%
   \begin at OpenObj
-  \addto at pscode{
+  \addto at pscode{%
+    /ValueSwitch2Log \psFunc at Switch2Log\space def
     /scx { \pst at number\psxunit mul } def
     /scy { \pst at number\psyunit mul } def
     /m #1 def
@@ -791,37 +871,75 @@
     \ifPst at 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 at 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 at LineEnding
       k 0 eq
-      { }
-      { kOld scx FS scy newpath \psFunc at radiusout 0 360 arc kOld scx FS scy \psFunc at radiusinL 360 0 arcn closepath \pst at usecolor\psk at LineEndColorL fill } ifelse \fi
+        { \psFunc at leftEnd neg scx 1 scy moveto \psFunc at radiusout neg 1 scy L gsave \pst at usecolor\pslinecolor stroke grestore } if
+      k m eq {kOld scx \psFunc at radiusout add FS Y add scy moveto  kOld scx FS Y add scy  newpath \psFunc at radiusout 0 360 arc kOld scx FS Y add scy \psFunc at radiusinR 360 0 arcn closepath
+      gsave \pst at usecolor\psk at LineEndColorR fill grestore } if
+        kOld scx FS scy newpath \psFunc at radiusout 0 360 arc kOld scx FS scy \psFunc at radiusinL 360 0 arcn closepath \pst at usecolor\psk at LineEndColorL fill % } ifelse
+       \fi
       kOld \ifPst at LineEnding\psFunc at radiusout\pst at number\psxunit div add \fi
-      k 0 eq
-      { \psFunc at leftEnd sub }
-      { } ifelse
+%      k 0 eq
+%      { \psFunc at leftEnd sub }
+%      { } ifelse
       scx FS scy moveto
       k 1 add
       \ifPst at LineEnding\psFunc at radiusout\pst at number\psxunit div sub \fi
@@ -846,10 +964,10 @@
      \fi\fi\fi
       \ifPst at printValue
         gsave \psk at PSfont findfont \psk at fontscale scalefont setfont \pst at usecolor\psk at LabelColor %
-        FS \psk at valuewidth string cvs
-        \ifPst at comma dot2comma \fi
-        k scx \psk at fontscale 2 div add \psFunc at xlabelsep scx add
-        FS scy \pst at number\pslabelsep add moveto
+        Y \psFunc at PrintVLimit le { () } { FS \psk at valuewidth\space string cvs } ifelse
+         \ifPst at comma dot2comma \fi
+        k 0.1 add scx \psk at fontscale 2 div add \psFunc at xlabelsep scx add
+        FS  scy \pst at number\pslabelsep add moveto
         \psFunc at langle rotate show grestore
       \fi
       /kOld kOld 1 add def
@@ -858,67 +976,106 @@
   \end at OpenObj
 }%
 %
+%
+\define at key[psset]{pst-func}{LeftClipX}[-1]{\def\psFunc at LeftClipX{#1 }}
+\define at key[psset]{pst-func}{RightClipX}[-1]{\def\psFunc at RightClipX{#1 }}
+\psset[pst-func]{LeftClipX=-1,RightClipX=1}
 \def\psBinomialC{\pst at object{psBinomialC}}
 \def\psBinomialC at i#1#2{%
   \leavevmode
   \pst at killglue
   \begingroup
-  \use at par
+    \use at par
+  \begin{psclip}%
+{\psframe[linestyle=none,fillstyle=none](\psFunc at LeftClipX,-0.1)(!#1 \psFunc at RightClipX\space add 1)}%
+%  \use at par
   \init at pscode
-  \def\cplotstyle{curve}%
-  \ifx\psplotstyle\cplotstyle \@nameuse{beginplot@\psplotstyle}\fi
-  \addto at pscode{%
-    \ifx\psplotstyle\cplotstyle /Curve true def \else /Curve false def \fi
+  \beginplot at cspline
+%    \addto at pscode{/D {} def mark}%
+   \addto at pscode{%
     /scx { \pst at number\psxunit mul } def
     /scy { \pst at 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 at markZeros x scx 0 L \fi %
-        } ifelse
-      \ifPst at printValue
-        gsave \psk at PSfont findfont \psk at fontscale scalefont setfont \pst at usecolor\psk at LabelColor %
-        y \psk at valuewidth string cvs %/Output exch def
-        \ifPst at comma dot2comma \fi      % do we have to change dot to comma
-        x dx sub scx \psk at fontscale 2 div add \psFunc at xlabelsep scx add
-        y scy \pst at number\pslabelsep add moveto
-        \psFunc at 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 at fillstyle
-  \pst at 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 at cspline
 \use at pscode
+\end{psclip}%
 \endgroup
 \ignorespaces}%
 %
-%
 \def\psPoisson{\pst at object{psPoisson}}% with contributions from Gerry Coombes
 \def\psPoisson at i#1#2{\psPoisson at ii#1,,\@nil{#2}}%
 \def\psPoisson at ii#1,#2,#3\@nil#4{%



More information about the tex-live-commits mailing list