[pstricks] plotting a piecewise constant function (step function)

Herbert Voss Herbert.Voss at FU-Berlin.DE
Thu Oct 21 16:50:51 CEST 2010


Am 21.10.2010 12:56, schrieb Leon Free:

> Am I right saying that the \psGaussI integrates the Gauss function on a
> given interval ?

yes, see the documentation of pst-func

> What if I want to draw a function such as
> $f(x) = \sum_{i}^n g(x_{i-1}) I(x \in [x_{i-1} , x_i))$
> where $g$ can be any given function, $I(A) = 1$ if condition $A$ is
> verified and 0 otherwise, and the $x_i$'s are given real values ?
> (binomial cdf is just one such function taken as a starting point)

pst-plot knows the SUM operator for PostScript, see also
the docs

> As far as I understand the postscript code, it does reproduce almost
> word for a word the FP computations I initially made.
> Now what if I dont know what the function $g$ is and the $n+1$ values
> $g(x_0),\ldots,g(x_n)$ are stored in an external file ? (the goal being
> plotting $f$ as a step function with *- horizontal lines on each
> interval $[x_{i-1},x_i)$)

\psplot[...options...]{x0}{x1}[PS definitions]{ PS code }

With the algebraic option the PS code can be an algebraic equation.
There are a lot of alternatives to plot a function. There is also
the IfTE operator for if-then-else operations.

Herbert


More information about the PSTricks mailing list