[pstricks] adding noise to a signal

Herbert Voss Herbert.Voss at alumni.TU-Berlin.DE
Thu Oct 7 14:25:08 CEST 2004


jmpapy wrote:

> does anybody knows how to generate a realization of a normally 
> distributed random variable b(n) and to add it to an existing 
> discrete-time signal s(n) drawn using pstricks ?

something like this??

Herbert

\documentclass[a4paper,10pt]{article}
\usepackage{pstricks,pstricks-add}
\begin{document}

\pstVerb{
   rrand srand % initializes the random generator
}
\begin{pspicture}(-5,-0.2)(5,5)
\psline{-}(-5,0)(5,0)
\psplot[linecolor=red,plotpoints=50,showpoints=true,linestyle=none]{-1}{3}{%
   4.7 39.48 x 1 neg add 2 exp mul 1 2 exp add div
   rand          % a random integer 0...2^31 - 1
   2147483647    % 2^31 - 1
   div add       % now rand is between 0...1
}
\end{pspicture}

\vspace{1cm}
\begin{pspicture}(-5,-0.2)(5,5)
\psline{-}(-5,0)(5,0)
\psplot[linecolor=red,plotpoints=50,showpoints=true,linestyle=none]{-1}{3}{%
   4.7 39.48 x 1 neg add 2 exp mul 1 2 exp add div
   rand 2147483647 div add %
}
\end{pspicture}

\end{document}



-- 
http://TeXnik.de/
http://PSTricks.de/
ftp://ftp.dante.de/tex-archive/info/math/voss/Voss-Mathmode.pdf
http://www.dante.de/faq/de-tex-faq/
http://www.tex.ac.uk/cgi-bin/texfaq2html?introduction=yes




More information about the PSTricks mailing list