5

I want to know if it's possible to fill an area interval (i.e from -0.2 to 0.2) under a gaussian curve, more exactly just an interval under this curve, using PSTricks.

enter image description here

I'm using pst-func, pst-plot, pst-math, pstricks-add packages also. Based on pst-func package

\psset{yunit=4cm,xunit=3}
\begin{pspicture}(-2,-0.2)(2,1.4)
\psgrid[griddots=10,gridlabels=0pt, subgriddiv=0]
\psaxes[Dy=0.25]{->}(0,0)(-2,0)(2,1.25)
\uput[-90](6,0){x}\uput[0](0,1){y}
  \rput[lb](1,0.75){\textcolor{red}{$\sigma =0.5$}}
  \rput[lb](1,0.5){\textcolor{blue}{$\sigma =1$}}
  \rput[lb](-2,0.5){$f(x)=\dfrac{1}{\sigma\sqrt{2\pi}}\,e^{-\dfrac{(x-\mu)^2}{2\sigma{}^2}}$}
  \psGauss[linecolor=red, linewidth=2pt, fillcolor=red!40,fillstyle=solid,opacity=0.5]{-2.95}{2.95}%
  \psGaussI[linewidth=1pt]{-2}{2}%
%  \psGauss[linecolor=cyan, mue=0.5, linewidth=2pt]{-1.75}{1.75}%
%  \psGauss[sigma=1, linecolor=blue, linewidth=2pt]{-1.75}{1.75}
\end{pspicture}

Edited:

I tryed this code:

\psset{yunit=4cm,xunit=3}
\begin{pspicture}(-2,-0.2)(2,1.4)
  \psgrid[griddots=10,gridlabels=0pt, subgriddiv=0]
  \psaxes[Dy=0.25]{->}(0,0)(-2,0)(2,1.25)
  \uput[-90](6,0){x}\uput[0](0,1){y}
  \rput[lb](1,0.75){\textcolor{red}{$\sigma =0.5$}}
  \rput[lb](1,0.5){\textcolor{blue}{$\sigma =1$}}
  \rput[lb](-2,0.5){$f(x)=\dfrac{1}{\sigma\sqrt{2\pi}}\,e^{-\dfrac{(x-\mu)^2}{2\sigma{}^2}}$}
  \psGauss[linecolor=red, linewidth=2pt]{-2.95}{2.95}%
  \psGaussI[linewidth=1pt]{-2}{2}%
   \pscustom[fillstyle=solid,fillcolor=red!30]{%
    \psGauss[linewidth=1pt,nue=5]{0.5}{1}%
    \psline(1,0)(0.5,0)}
\end{pspicture}

And I would like to know if it's possible to close the loop line (psline), that start over the curve and lay down on axis "x". From 0.5 to 1 over the curve, then 1 to (1,0) and to (0.5,0). Seem's that is missing a part from (0.5,0) to (0.5,curve). There is a way to fill this line ?

Thanks again!!

  • 3
    is there any problem to read the documentation: "14.1 Filling an area under a distribution curve" – user2478 Feb 20 '13 at 20:26
  • 2
    wow, didn't see it. thank you very much – André Feb 20 '13 at 20:32
5

The topic is covered in section 14.1 "Filling an area under a distribution curve" of the manual.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.