From f587320cb4c3114a76584fc12b89cdba7c1db07c Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 3 Apr 2023 21:32:32 +0000 Subject: pst-func (3apr23) git-svn-id: svn://tug.org/texlive/trunk@66750 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/generic/pst-func/Changes | 5 + Master/texmf-dist/doc/generic/pst-func/README.md | 4 +- .../doc/generic/pst-func/pst-func-doc.bib | 8 ++ .../doc/generic/pst-func/pst-func-doc.pdf | Bin 4050523 -> 4065407 bytes .../doc/generic/pst-func/pst-func-doc.tex | 107 ++++++++++++++++++--- Master/texmf-dist/dvips/pst-func/pst-func.pro | 55 +++++++---- .../texmf-dist/tex/generic/pst-func/pst-func.tex | 73 +++++++++++--- Master/texmf-dist/tex/latex/pst-func/pst-func.sty | 6 +- 8 files changed, 211 insertions(+), 47 deletions(-) diff --git a/Master/texmf-dist/doc/generic/pst-func/Changes b/Master/texmf-dist/doc/generic/pst-func/Changes index 9ecb5349bbc..4c691ca0946 100644 --- a/Master/texmf-dist/doc/generic/pst-func/Changes +++ b/Master/texmf-dist/doc/generic/pst-func/Changes @@ -1,4 +1,7 @@ ..... pst-func.tex +1.01 2023-04-02 - added \psNonCentralTDist (noncentral Student's distribution) +1.00 2022-09-11 - fix \psBessel: use toDeg instead of k + - set algebraic=false 0.99 2021-11-03 - fix for psLorenz (missing sort routine) 0.98 2021-10-30 - fix for Gini coefficiant 0.97 2021-10-29 - fix and extension for \psLorenz curve @@ -119,6 +122,8 @@ ..... pst-func.pro +0.19 2023-04-02 - added /ConfHyperFunc { % Confluent Hypergeometric Function of the First Kind + needed by \psNonCentralTDist 0.18 2021-10-30 - added arraysum and arrayprod 0.17 2018-12-13 - allow algebraic mode for Simpson 0.16 2018-11-15 - new algorithm for Si/si/Ci/ci diff --git a/Master/texmf-dist/doc/generic/pst-func/README.md b/Master/texmf-dist/doc/generic/pst-func/README.md index 2552fc43849..9fb82bf0953 100644 --- a/Master/texmf-dist/doc/generic/pst-func/README.md +++ b/Master/texmf-dist/doc/generic/pst-func/README.md @@ -19,6 +19,7 @@ - psGammaDist - psChiIIDist - psTDist for Student's t-distribution +- psNonCentralTDist for noncentral Student's t-distribution - psBetaDist for Beta distribution - psWeibull for Weibull distribution - psLame (Lamé Curve - a superellipse) @@ -43,7 +44,8 @@ CTAN server, http://mirror.ctan.org PSTricks is PostScript Tricks, the documentation cannot be run with pdftex, use lualatex or the sequence latex->dvips->ps2pdf or -pdflatex with package auto-pst-pdf or xelatex. +pdflatex with package auto-pst-pdf or xelatex or lualatex (preferred). + hvoss@tug.org diff --git a/Master/texmf-dist/doc/generic/pst-func/pst-func-doc.bib b/Master/texmf-dist/doc/generic/pst-func/pst-func-doc.bib index e749f71bfb1..89f7eaad317 100644 --- a/Master/texmf-dist/doc/generic/pst-func/pst-func-doc.bib +++ b/Master/texmf-dist/doc/generic/pst-func/pst-func-doc.bib @@ -166,3 +166,11 @@ year = {2012}, url = {/graphics/pstricks/contrib/pst-tools} } + +@online{weisstein, + author = {Weisstein, Eric W.}, + title = {Noncentral Student's t-Distribution}, + subtitle = {From MathWorld--A Wolfram Web Resource}, + url = {https://mathworld.wolfram.com/NoncentralStudentst-Distribution.html}, + note = {Probability and Statistics; Statistical Distributions; Continuous Distributions } + } 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 index b791d5e480e..62249b7e51f 100644 Binary files a/Master/texmf-dist/doc/generic/pst-func/pst-func-doc.pdf and b/Master/texmf-dist/doc/generic/pst-func/pst-func-doc.pdf differ 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 8e87d3a6d38..b3f0c2ecae0 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 @@ -1,6 +1,6 @@ \RequirePackage{pdfmanagement-testphase} \DeclareDocumentMetadata{} -%% $Id: pst-func-doc.tex 306 2021-10-29 14:48:08Z herbert $ +%% $Id: pst-func-doc.tex 691 2023-04-03 10:51:04Z herbert $ \documentclass[fontsize=11pt,english,BCOR=10mm,DIV=12,bibliography=totoc,parskip=false,headings=small, headinclude=false,footinclude=false,oneside]{pst-doc} \usepackage{pst-func} @@ -1158,7 +1158,7 @@ f(t) = constI \cdot J_n + constII where \Lkeyword{constI} and \Lkeyword{constII} must be real PostScript expressions, e.g. \begin{lstlisting}[style=syntax] -\psset{constI=2.3,constII=t k sin 1.2 mul 0.37 add} +\psset{constI=2.3,constII=t toDegrees sin 1.2 mul 0.37 add} \end{lstlisting} The Bessel function is plotted with the parametricplot macro, this is the @@ -1174,13 +1174,11 @@ In particular, note that the default for time consuming at this setting, it can be decreased in the usual way, at the cost of some reduction in graphics resolution. -\begin{LTXexample} -{ +\begin{LTXexample}[pos=t] \psset{xunit=0.25,yunit=5} \begin{pspicture}(-13,-.85)(13,1.25) \rput(13,0.8){% - $\displaystyle J_n(x)=\frac{1}{\pi}\int_0^\pi\cos(x\sin t-nt)\dt$% -} + $\displaystyle J_n(x)=\frac{1}{\pi}\int_0^\pi\cos(x\sin t-nt)\dt$} \psaxes[Dy=0.2,Dx=4]{->}(0,0)(-30,-.8)(30,1.2) \psset{linewidth=1pt} \psBessel[linecolor=red]{0}{-28}{28}% @@ -1188,23 +1186,21 @@ way, at the cost of some reduction in graphics resolution. \psBessel[linecolor=green]{2}{-28}{28}% \psBessel[linecolor=magenta]{3}{-28}{28}% \end{pspicture} -} \end{LTXexample} -\begin{LTXexample} -{ + +\begin{LTXexample}[pos=t] \psset{xunit=0.25,yunit=2.5} \begin{pspicture}(-13,-1.5)(13,3) \rput(13,0.8){% - $\displaystyle f(t) = 2.3 \cdot J_0 + 1.2\cdot \sin t + 0.37$% -} + $\displaystyle f(t) = 2.3 \cdot J_0 + 1.2\cdot \sin t + 0.37$} \psaxes[Dy=0.8,dy=2cm,Dx=4]{->}(0,0)(-30,-1.5)(30,3) \psset{linewidth=1pt} -\psBessel[linecolor=red,constI=2.3,constII={t k sin 1.2 mul 0.37 add}]{0}{-28}{28}% +\psBessel[linecolor=red,constI=2.3,constII={t toDegrees sin 1.2 mul 0.37 add}]{0}{-28}{28}% \end{pspicture} -} \end{LTXexample} + %\clearpage \subsection{Modfied Bessel function of first order} The modified Bessel function of first order is defined as @@ -1216,6 +1212,7 @@ I_\nu(x) &= \left(\frac12 x\right)^\nu % \noindent The syntax of the macro is + \begin{BDef} \Lcs{psModBessel}\OptArgs\Largb{xStart}\Largb{xEnd} \end{BDef} @@ -1223,6 +1220,11 @@ I_\nu(x) &= \left(\frac12 x\right)^\nu The only valid optional argument for the function is \Lkeyword{nue}, which is preset to 0, it shows $I_0$. + + + + + \begin{LTXexample} \begin{pspicture}(0,-0.5)(5,5) \psaxes[ticksize=-5pt 0]{->}(5,5) @@ -1909,6 +1911,70 @@ and the following syntax %The $t_\nu$-distribution has mode 0. +\subsection{Student's noncentral $t$-distribution} + + +A generalization of Student's t-distribution known as the noncentral Student's t-distribution is given by + +\[ + P(x)=\frac{\nu^{\nu/2}\nu!}{2^{\nu}e^{\lambda^2/2}(\nu+x^2)^{\nu/2}\Gamma(\frac12\nu)} + \left\{ + \frac{\sqrt{2}\lambda x\, {}_1F_1\left(\frac12 \nu+1;\, \frac32; \,\frac{\lambda^2x^2}{2(\nu+x^2)}\right)} + {(\nu+x^2)\Gamma[\frac12(\nu+1)]} + + \frac{{}_1F_1\left(\frac12(\nu+1);\, \frac12; \, \frac{\lambda^2x^2}{2(\nu+x^2)}\right)}{\sqrt{\nu+x^2}\Gamma(\frac12\nu+1)}\right\} +\] + +where $\Gamma(z)$ is the gamma function and ${}_1F_1(a;b;z)$ is a confluent hypergeometric function of the first kind.~\parencite{weisstein} + + +\[ {}_1F_1(a;b;z) = 1+\frac ab z + \frac{a(a+1)}{b(b+1)} \frac{z^2}{2!}+ \cdots=\sum_{k=0}^\infty\frac{(a)_k}{(b)_k} \frac{z^k}{k!} \] + + +%mu = lambdasqrt(n/2)(Gamma(1/2(n-1)))/(Gamma(1/2n)) +%sigma^2 = ((lambda^2+1)n)/(n-2)-(lambda^2n[Gamma(1/2(n-1))]^2)/(2[Gamma(1/2n)]^2). + +The macro has the same syntax as the centered Student's distribution: + +\begin{BDef} +\Lcs{psNonCentralTDist}\OptArgs\Largb{x0}\Largb{x1} +\end{BDef} + + +There exists an additional optional parameter \Lkeyword{lambda}, which is preset to 0.5. + + +\begin{LTXexample}[pos=t,preset=\centering] +\psset{xunit=0.75cm,yunit=10cm} +\begin{pspicture}(-6,-0.1)(11,.5) + \psaxes[Dy=0.1]{->}(0,0)(-4.5,0)(10,0.5) + \psset{linewidth=1pt,plotpoints=100} + \psNonCentralTDist[linecolor=red,lambda=0,nue=1]{-5}{10}% same as \psTDist + \psNonCentralTDist[linecolor=green,lambda=0,nue=4]{-5}{10}% dito + \psNonCentralTDist[linecolor=red,lambda=2,nue=1]{-5}{10} + \psNonCentralTDist[linecolor=green,lambda=2,nue=4]{-5}{10} +\end{pspicture} +\end{LTXexample} + + + + + +\begin{LTXexample}[pos=t,preset=\centering] +\psset{xunit=1.25cm,yunit=10cm} +\begin{pspicture}(-6,-0.1)(6,.5) + \psaxes[Dy=0.1]{->}(0,0)(-4.5,0)(5.5,0.5) + \psset{linewidth=1pt,plotpoints=100} + \psTDist[linecolor=blue]{-4}{4} + \psNonCentralTDist[linecolor=red]{-4}{5} + \psNonCentralTDist[linecolor=green,nue=4,lambda=2]{-4}{5} +\end{pspicture} +\end{LTXexample} + + + + + + \clearpage \subsection{$F$-distribution} A continuous statistical distribution which arises in the testing of @@ -2173,6 +2239,21 @@ origin of the coordinate system. \endpsgraph \end{LTXexample} + +\begin{LTXexample}[pos=t,preset=\centering] +\psset{lly=-13mm,llx=-5mm} +\psgraph[Dx=0.2,Dy=0.2,axesstyle=frame](0,0)(1,1){6cm}{6cm} +\psline[linestyle=dashed](1,1) +\psLorenz[Gini,linecolor=red,linewidth=1.5pt]<.2 .2 .2 .2 .2>{.1 .1 .1 .35 .35 } +\psLorenz[Gini,linecolor=blue,linestyle=dashed,linewidth=1.5pt]{.1 .1 .1 .35 .35 } +\endpsgraph +\end{LTXexample} + + + + + + \clearpage \subsection{\nxLcs{psLame} -- Lam\'e Curve, a superellipse} A superellipse is a curve with Cartesian equation diff --git a/Master/texmf-dist/dvips/pst-func/pst-func.pro b/Master/texmf-dist/dvips/pst-func/pst-func.pro index f752442e87c..a0a58d9e921 100644 --- a/Master/texmf-dist/dvips/pst-func/pst-func.pro +++ b/Master/texmf-dist/dvips/pst-func/pst-func.pro @@ -1,4 +1,4 @@ -%% $Id: pst-func.pro 861 2018-12-13 20:40:06Z herbert $ +%% $Id: pst-func.pro 689 2023-04-03 06:46:27Z herbert $ %% %% This is file `pst-func.pro', %% @@ -16,7 +16,7 @@ %% `pst-func' is a PSTricks package to plot special math functions %% %% -%% version 0.17 / 2018-12-13 Herbert Voss +%% version 0.19 / 2023-04-02 Herbert Voss % /tx@FuncDict 100 dict def tx@FuncDict begin @@ -289,13 +289,13 @@ tx@FuncDict begin /s1 0 def /s2 0 def 1 1 M { - /k exch def - /xVal k 2 mul 1 sub h mul a add def + /simp_k exch def + /xVal simp_k 2 mul 1 sub h mul a add def /s1 s1 xVal useX { /x exch def } if SFunc add def } for 1 1 M 1 sub { - /k exch def - /xVal k 2 mul h mul a add def + /simp_k exch def + /xVal simp_k 2 mul h mul a add def /s2 s2 xVal useX { /x exch def } if SFunc add def } for /I a useX { /x exch def } if SFunc b useX { /x exch def } if SFunc add s1 4 mul add s2 2 mul add 3 div h mul def @@ -305,12 +305,12 @@ tx@FuncDict begin /LogGamma { 5 dict begin % z on stack /z ED /sum 0 def - /k 1 def + /logGamma_k 1 def { - z k div dup 1 add ln sub dup + z logGamma_k div dup 1 add ln sub dup abs eps8 lt { pop exit } if sum add /sum exch def - /k k 1 add def + /logGamma_k logGamma_k 1 add def } loop sum z ln sub CEuler z mul sub end @@ -321,10 +321,10 @@ tx@FuncDict begin /xtmp exch def /n exch def 0 0 1 n .5 mul floor { - /k exch def - xtmp xtmp mul 1 sub k exp - xtmp n 2 k mul sub exp mul - n 2 k mul MoverN mul + /cheb_k exch def + xtmp xtmp mul 1 sub cheb_k exp + xtmp n 2 cheb_k mul sub exp mul + n 2 cheb_k mul MoverN mul add } for end @@ -335,10 +335,10 @@ tx@FuncDict begin /xtmp exch def /n exch def 0 0 1 n .5 mul floor { - /k exch def - xtmp xtmp mul 1 sub k exp - xtmp n 2 k mul sub exp mul - n 1 add 2 k mul 1 add MoverN mul + /cheb_k exch def + xtmp xtmp mul 1 sub cheb_k exp + xtmp n 2 cheb_k mul sub exp mul + n 1 add 2 cheb_k mul 1 add MoverN mul add } for end @@ -368,6 +368,27 @@ tx@FuncDict begin } def %end{vasicek density} % +% https://mathworld.wolfram.com/ConfluentHypergeometricFunctionoftheFirstKind.html +/ConfHyperFunc { % Confluent Hypergeometric Funtion of the First Kind + % on stack must be a b z + 10 dict begin + /z ED /b ED /a ED + /sum 1 def + /k 0 def + /nom 1 def + /denom 1 def + { + nom a k add mul z mul /nom ED + denom b k add mul k 1 add mul /denom ED + nom denom div /diff ED + sum diff add /sum ED + diff 1e-5 lt { exit } { k 1 add /k ED } ifelse + k 1000 ge { (Error ConfHyperFunc: k =1000) == exit } if + } loop + sum + end +} def +% end % /arraySum { % on stack the array 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 1e982ddb2be..7960baf61b2 100644 --- a/Master/texmf-dist/tex/generic/pst-func/pst-func.tex +++ b/Master/texmf-dist/tex/generic/pst-func/pst-func.tex @@ -1,4 +1,4 @@ -%% $Id: pst-func.tex 308 2021-10-30 14:11:45Z herbert $ +%% $Id: pst-func.tex 689 2023-04-03 06:46:27Z herbert $ %% %% This is file `pst-func.tex', %% @@ -31,8 +31,8 @@ % interface to the `xkeyval' package \pst@addfams{pst-func} % -\def\fileversion{0.99} -\def\filedate{2021/11/03} +\def\fileversion{1.01} +\def\filedate{2023/04/02} \message{`PST-func' v\fileversion, \filedate\space (hv)} % \pstheader{pst-func.pro} @@ -233,14 +233,14 @@ \def\psBessel{\@ifnextchar[{\psBessel@i}{\psBessel@i[]}} \def\psBessel@i[#1]#2#3#4{{%%% #2 = n \pst@killglue - \psset{plotpoints=500}% - \psset{#1}% + \psset{plotpoints=500,constI=1,constII=0}% + \psset{#1,algebraic=false}% + \pstVerb{ /toDegrees { 57.29577951 mul } def } \parametricplot{#3}{#4}{% /J1 0 def - /k { 57.29577951 mul } def - /xBessel t k def + /xBessel t toDegrees def 0 0.1 180 { - /tB exch k def + /tB exch toDegrees def /J1 J1 0.1 xBessel tB sin mul tB #2\space mul sub cos mul add def } for @@ -706,7 +706,9 @@ grestore \def\psPrintValue{\pst@object{psPrintValue}} \def\psPrintValue@i#1{\expandafter\psPrintValue@ii#1,,\@nil} \def\psPrintValue@ii#1,#2,#3\@nil{% #1,#2 only for algebraic code + \addbefore@par{algebraic=false}% \begin@SpecialObj + \use@par \addto@pscode{ gsave \psk@PSfont\space findfont \psk@fontscale scalefont setfont \ifPst@algebraic @@ -1465,14 +1467,18 @@ grestore \def\psBetaDist@i#1#2{% \ifdim#1pt<\z@ \psframebox*{\color{red}!!!\#1 must be greater than 0!!!} \else + \begingroup \addbefore@par{plotpoints=200,alpha=1,beta=1}% - \begin@OpenObj - \psplot[algebraic=false]{#1}{#2}{ + \addto@par{algebraic=false}% +% \begin@OpenObj + \use@par + \psplot{#1}{#2}{ \psk@beta \psk@alpha add GAMMA \psk@beta GAMMA \psk@alpha GAMMA mul div 1 x sub \psk@beta 1.0 sub exp mul x \psk@alpha 1.0 sub exp mul } - \end@OpenObj% +% \end@OpenObj% + \endgroup \fi% \ignorespaces% } @@ -1508,6 +1514,44 @@ grestore \endgroup% \ignorespaces% } + +\define@key[psset]{pst-func}{lambda}[1]{\def\psk@lambda{#1 }} +\psset[pst-func]{lambda=0.5} + +\def\psNonCentralTDist{\pst@object{psNonCentralTDist}} +\def\psNonCentralTDist@i#1#2{% + \leavevmode + \pst@killglue + \begingroup + \addbefore@par{plotpoints=500}% + \use@par + \ifdim\psk@nue pt<\z@ \psframebox*{\color{red}!!!nue must be greater than 0!!!} + \else + \psplot[algebraic=false]{#1}{#2}{% P(x) = a ( b/c + d/e ) + \psk@nue dup 2 div exp \psk@nue factorial mul % nominator of a + 2 \psk@nue exp Euler \psk@lambda dup mul 2 div exp mul + \psk@nue x dup mul add \psk@nue 2 div exp mul + \psk@nue 2 div GAMMA mul % denominator of a + div % a + 2 sqrt \psk@lambda mul x mul + \psk@nue 2 div 1 add + 1.5 + \psk@lambda dup mul x dup mul mul 2 div \psk@nue x dup mul add div + tx@FuncDict begin ConfHyperFunc end % Confluent Hypergeometric Funtion of the First Kind + mul % b + \psk@nue x dup mul add \psk@nue 1 add 2 div GAMMA mul % c + div % b/c + \psk@nue 1 add 2 div 0.5 \psk@lambda dup mul x dup mul mul 2 div \psk@nue x dup mul add div + tx@FuncDict begin ConfHyperFunc end % d + \psk@nue x dup mul add sqrt \psk@nue 2 div 1 add GAMMA mul % e + div % d/e + add % b/c + d/e + mul % (b/c + d/e) * a + }% + \fi + \endgroup + \ignorespaces +} % \def\psFDist{\pst@object{psFDist}} \def\psFDist@i#1#2{% @@ -1656,6 +1700,7 @@ grestore \fi 0 0 % the start point 0 1 nVal 1 sub { dup XvalRelCum exch get exch YvalRelCum exch get } for +% pstack \if@star 1 0 0 0 \fi % add values for the closed curve end }% filling the area under the curve. @@ -1676,14 +1721,16 @@ grestore \leavevmode \pst@killglue \begingroup - \addbefore@par{plotpoints=200,startAngle=0,endAngle=360}% + \addbefore@par{plotpoints=200,startAngle=0,endAngle=360,algebraic=false}% \use@par \parametricplot{\psk@startAngle}{\psk@endAngle}{% t cos dup mul 1 #1\space div exp \pst@radiusA \pst@number\psxunit div mul t 90 gt { t 270 lt { neg } if } if t sin dup mul 1 #1\space div exp \pst@radiusB \pst@number\psyunit div mul t 180 gt { neg } if } - \endgroup\ignorespaces} + \endgroup + \ignorespaces +} % \def\psWeierstrass{\pst@object{psWeierstrass}} \def\psWeierstrass@i(#1,#2){\@ifnextchar[{\psWeierstrass@ii(#1,#2)}{\psWeierstrass@iii(#1,#2)}} diff --git a/Master/texmf-dist/tex/latex/pst-func/pst-func.sty b/Master/texmf-dist/tex/latex/pst-func/pst-func.sty index ff1038570dd..c97e1968b1b 100644 --- a/Master/texmf-dist/tex/latex/pst-func/pst-func.sty +++ b/Master/texmf-dist/tex/latex/pst-func/pst-func.sty @@ -1,5 +1,5 @@ \RequirePackage{pstricks} -\ProvidesPackage{pst-func}[2018/12/13 package wrapper for pst-func.tex (hv)] +\ProvidesPackage{pst-func}[2021/10/30 package wrapper for pst-func.tex (hv)] \RequirePackage{pst-plot} \RequirePackage{pst-math} \RequirePackage{pst-tools} @@ -10,7 +10,7 @@ \ProvidesFile{pst-func.tex} [\filedate\space v\fileversion\space `PST-func' (hv)] \IfFileExists{pst-func.pro}{% - \ProvidesFile{pst-func.pro}[2018/12/13 v. 0.17, PostScript prologue file (hv)] + \ProvidesFile{pst-func.pro}[2023/04/02 v. 0.19, PostScript prologue file (hv)] \@addtofilelist{pst-func.pro}}{}% \endinput -%% $Id: pst-func.sty 306 2021-10-29 14:48:08Z herbert $ +%% $Id: pst-func.sty 693 2023-04-03 10:56:01Z herbert $ -- cgit v1.2.3