1

I need to have four different noicy curves drawn in tikz. The four lines need to be different (they must have different amplitude and noise.)

They need to start from a their own baseline and again end at this baseline.

enter image description here

my code is as follows

\documentclass{memoir}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\begin{figure}[h]
\centering
\begin{tikzpicture}
\newcommand\XA{1}
\newcommand\YA{10}
\newcommand\LengthProbe{5}
\newcommand\widthProbe{0.5}
\newcommand\contactPoint{0.10}
\newcommand\neuronX{3}
\newcommand\neuronY{8.5}

\path[use as bounding box,draw,black] (0,0) rectangle (12,12);

\node [circle,draw] at (\neuronX,\neuronY) (N1) {}; 
\node [circle,draw,below right = 0.2cm and 0.2cm of N1] () {};
\node [circle,draw,below right = 0.15cm and -0.2cm of N1] () {};
\node [circle,draw,below left = 0.6cm and -0.2cm of N1] () {};
\node [circle,draw,above right = 0.05cm and 0.2cm of N1] () {};
\node [circle,draw,below right = 0.8cm and 0.3cm of N1] () {};
\node [circle,draw,below left = 0.6cm and -0.2cm of N1] (N3) {};
\node [circle,draw,below right = 1.2cm and 0.2cm of N1] (N4) {};
\node [circle,draw,below left = 1.4cm and 0.0cm of N1] (N4) {};

\node[yshift = 10.5cm,xshift = 3.5cm] () {Before Optimization};

\coordinate (A1) at (2.5,10);
\coordinate (B1) at (2,5);
\draw (A1) to [bend left=10] (B1);

\coordinate (A2) at (4 , 10);
\coordinate (B2) at (4.5 , 5);
\draw (A2) to [bend right=10] (B2);

\draw (\XA,\YA) -- (\XA,\YA-\LengthProbe) -- (\XA+\widthProbe,\YA-\LengthProbe -\widthProbe) --(\XA+\widthProbe,\YA) -- (\XA,\YA); %linear probes

\foreach \ix in {0.2,0.8,...,4.6}
\draw (\XA+0.1,\YA-\ix) rectangle (\XA+\contactPoint+0.1,\YA-\ix-\contactPoint);

\foreach \ix in {0.3,0.9,...,5.0}
\draw (\XA+0.3,\YA-\ix-0.2) rectangle (\XA+\contactPoint+0.3,\YA-\ix-\contactPoint-0.2);

\end{tikzpicture}

\end{figure}

 \end{document}
1

An alternative in Metapost, wrapped up in luamplib, so compile this with lualatex.

enter image description here

\RequirePackage{luatex85}
\documentclass[border=5mm]{standalone}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}

vardef exp(expr x) = mexp(256x) enddef; % wrap MP's version of exp

vardef normal_pdf(expr x) = 
    exp(-1/2x*x)/2.50662827463  % \sqrt(2\pi) \simeq 2.50663 
enddef;

vardef noisy_normal_pdf(expr w, h, noisiness, frequency) = 
    ( (-4, normal_pdf(-4) + (noisiness/128) * normaldeviate) 
    for x=frequency-4 step frequency until 4:
       -- (x, normal_pdf(x) + (noisiness/128) * normaldeviate) 
   endfor ) xscaled 0.125 w yscaled 2.50663 h
enddef;  % scaled so that the curve has width w and height h

beginfig(1);
    for r = 0 upto 4:
        draw noisy_normal_pdf(5cm, 1cm, 2r, 1/32) shifted (0,r * cm);
    endfor
endfig;
\end{mplibcode}
\end{document}
1

This is my first attempt on creating what you asked for. Right now I cant control the frequency, but you should be able to achieve something like you wanted.

enter image description here

Some code was taken from this question: Tikz/pgf decoration that adds noise only to y coordinate

\documentclass[a4paper]{article}

\usepackage{tikz}
\usetikzlibrary{decorations}
\usetikzlibrary{decorations.pathmorphing}
\begin{document}

\pgfdeclaredecoration{jiggly}{step}
{
  \state{step}[width=+\pgfdecorationsegmentlength]
  { \pgfmathsetmacro{\delta}{rand*\pgfdecorationsegmentamplitude}
    \pgfmathsetmacro{\deltax}{\delta*cos(90+\pgfdecoratedangle}
    \pgfmathsetmacro{\deltay}{\delta*sin(90+\pgfdecoratedangle}
    \pgfpathlineto{\pgfpoint{\pgfdecorationsegmentlength-\deltax}{\deltay}}
  }
  \state{final}
  {
    \pgfpathlineto{\pgfpointdecoratedpathlast}
  }
}

\begin{tikzpicture}[decoration={jiggly, amplitude=0.1cm}]


\draw[decoration={jiggly, amplitude=0.2cm},smooth] [decorate] 
(0,0) --++(2,1)--++(2,0)-- ++(2,-1);

\draw[decoration={jiggly, amplitude=0.3cm},smooth] [decorate] 
(0,2) --++(2,1)--++(2,0)-- ++(2,-1);

\draw[decoration={jiggly, amplitude=0.5cm},smooth] [decorate] 
(0,4) --++(2,1)--++(2,0)-- ++(2,-1);

\draw[decoration={jiggly, amplitude=0.7cm},smooth] [decorate]
(0,6) --++(2,1)--++(2,0)-- ++(2,-1);

\end{tikzpicture}

\end{document}

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.