[pstricks] Drawing S- and Z-Curves
Michael Sharpe
msharpe at ucsd.edu
Sun Apr 26 23:45:10 CEST 2009
On Apr 26, 2009, at 11:24 AM, Rich Shepard wrote:
> On Sun, 26 Apr 2009, Herbert Voss wrote:
>
>> you can also use the Gauss macro from pst-func
>
> Herbert,
>
> The problem with the Gauss curve (and what I've found for logistic
> curves)
> is that they do not reach y=1.0 at a defined x value, with ends at
> (x0,y=0)
> (x1,y=0). I'm no longer enough of a mathetician to know what
> equation I
> need.
>
> As an example of what I am trying to do are the attached .eps
> files. I
> created those using Xfig but they are sloppy compared with what I
> should be able
> to do with PSTricks.
>
> While these images are illustrative, within our model (built with
> python
> and C), the output will provide real (x,y) pairs that we need to fit
> to a
> bell or logistic curve.
>
> Suggestions and pointers are always appreciated.
>
Rich,
Here is an example file with the gauss function normalized to maximum
value 1, and a version of the logistic functions. The lines near the
end show the usage. In the logistic curves mu sets the center point,
and lscale, which must be fairly small, sets the scale parameter. Note
that these are specified in PostScript, not algebraic. format. In the
gaussian case, you can choose to set either sigma, or var. Whichever
you set last will determine the variance (and standard deviation.)
Michael
\documentclass[dvips]{article}
%\usepackage{amsmath}
\usepackage{pstricks-add}
\pagestyle{empty}
\makeatletter
\pst at addfams{pst-morefunc}
\define at key[psset]{pst-morefunc}{sigma}{\def\psk at sigma{#1 }\def
\psk at var{#1 #1 mul }}
\define at key[psset]{pst-morefunc}{var}{\def\psk at var{#1 }\def
\psk at sigma{#1 sqrt }}
\define at key[psset]{pst-morefunc}{mu}{\def\psk at mu{#1 }}
\define at key[psset]{pst-morefunc}{lscale}{\def\psk at lscale{#1 }}
\def\gaussfn{ Euler x \psk at mu sub dup mul 2 div \psk at var div neg exp }
\def\Scurve{1 1 Euler x \psk at mu sub \psk at lscale div neg exp add div }
\def\Zcurve{Euler x \psk at mu sub \psk at lscale div neg exp dup 1 add div }
\makeatother
\begin{document}
\psset{yunit=5cm}\begin{pspicture}[showgrid=true](-.5,-.5)(6.5,1.2)
\psplot[mu=1,lscale=.2]{0}{3}{\Zcurve}
\psplot[mu=3,lscale=.2]{0}{5}{\Scurve}
\psplot[mu=2,var=2]{0}{5}{\gaussfn}
\end{pspicture}
\end{document}
More information about the PSTricks
mailing list