2

Since you cant set the size of math notation I was wondering if we can scale the image to be larger so that math appears smaller?

Also I`d like to be able to change the x-axis and y-axis of the subplot to be similar to to the sample image?

Finally, this might be difficult but its possible to add some sample curves/paths in light gray for the distributions that roughly match the mean and variance with some random curvature similar to the example below?

Rotated Normal Distribution

sample realizations

1 Answers1

4

To increase the size of the plot, you just may adjust width and height. The second part of the question I don't understand. Indicating mean and variance is straightforward.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\pgfmathsetmacro{\offset}{0.05}
\begin{tikzpicture}[font=\sffamily,
declare function={gauss(\x,\y,\z)=\offset+1/(\y*sqrt(2*pi))*exp(-((\x-\z)^2)/(2*\y^2));}]

\begin{axis}[samples=101,smooth,hide axis,width=20cm,height=11cm]
\addplot [domain=-3:3] ({gauss(x,0.8,0)},x);
\addplot [domain=-3:3] ({1+gauss(x,1.2,0)},1+x);
\addplot [domain=-3:3] ({2+gauss(x,0.6,0)},x);
\foreach [count=\Y starting from 0] \vari/\DeltaX in {0.8/0,1.2/1,0.6/0} 
{\typeout{\vari/\DeltaX}
\edef\temp{\noexpand\draw[gray] ({\Y+\offset},{\vari+\DeltaX}) -- ({\Y+gauss(\vari,\vari,0)},{\vari+\DeltaX})
({\Y+\offset},{-\vari+\DeltaX}) -- ({\Y+gauss(\vari,\vari,0)},{-\vari+\DeltaX})
 (\Y+\offset,\DeltaX) -- ({\Y+gauss(0,\vari,0)},\DeltaX)
;}
\temp}

\draw[-latex] (0,-3) --  (0,3) coordinate[pos=0.4](x1) coordinate[pos=0.5] (y1)
node[below right,rotate=-90]{$x(t_i)$};
\draw[-latex] (0,-3) -- (0.5,-3) node[below left,rotate=-90]{$f\bigl(x(t_i)\bigr)$};
\draw (1,-2) -- (1,4) coordinate[pos=0.6](x2) coordinate[pos=0.5] (y2);
\draw (2,-3) -- (2,3) coordinate[pos=0.6](x3) coordinate[pos=0.5] (y3);
\addplot[-latex] coordinates{(-0.5,-4) (3,-4)};
\path (0,-4) coordinate (z1) (1,-4) coordinate (z2) (2,-4) coordinate (z3);
\coordinate (t) at (3,-4.1);
\coordinate (xi) at (-0.6,4);
\addplot[-latex] coordinates{(-0.5,-4) (3,-4)};
\addplot[-latex] coordinates{(-0.5,-4) (-0.5,4)};
\end{axis}
\foreach \X in {1,2,3}
{\fill (x\X) circle (2pt);
\draw ([xshift=-1mm]y\X) -- ([xshift=1mm]y\X);
\draw ([yshift=1mm]z\X) -- ([yshift=-1mm]z\X) node[below] {$\X$};}
\node[anchor=north east] at (t) {time};
\node[anchor=north east] at (xi) {$x(t)$};
\draw[blue,thick,shorten >=2mm,shorten <=2mm] (x1) -- (x2);
\draw[blue,thick,shorten >=2mm,shorten <=2mm] (x2) -- (x3);
\end{tikzpicture}
\end{document}

enter image description here

Alternative you may just decrease the size of the font.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\pgfmathsetmacro{\offset}{0.05}
\begin{tikzpicture}[font=\sffamily\small,
declare function={gauss(\x,\y,\z)=\offset+1/(\y*sqrt(2*pi))*exp(-((\x-\z)^2)/(2*\y^2));}]

\begin{axis}[samples=101,smooth,hide axis,width=15cm,height=8cm]
\addplot [domain=-3:3] ({gauss(x,0.8,0)},x);
\addplot [domain=-3:3] ({1+gauss(x,1.2,0)},1+x);
\addplot [domain=-3:3] ({2+gauss(x,0.6,0)},x);
\foreach [count=\Y starting from 0] \vari/\DeltaX in {0.8/0,1.2/1,0.6/0} 
{\edef\temp{\noexpand\draw[gray] ({\Y+\offset},{\vari+\DeltaX}) -- ({\Y+gauss(\vari,\vari,0)},{\vari+\DeltaX})
({\Y+\offset},{-\vari+\DeltaX}) -- ({\Y+gauss(\vari,\vari,0)},{-\vari+\DeltaX})
 (\Y+\offset,\DeltaX) -- ({\Y+gauss(0,\vari,0)},\DeltaX)
;}
\temp}
\begin{scope}[thick]
\draw[-latex] (0,-3) --  (0,3) coordinate[pos=0.4](x1) coordinate[pos=0.5] (y1)
node[below right,rotate=-90]{$x(t_i)$};
\draw[-latex] (0,-3) -- (0.5,-3) node[below left,rotate=-90]{$f\bigl(x(t_i)\bigr)$};
\draw[-latex] (1,-2) -- (1,4) coordinate[pos=0.6](x2) coordinate[pos=0.5] (y2);
\draw[dashed] (0,-3) -- (0,-3.5);
\draw[-latex] (2,-3) -- (2,3) coordinate[pos=0.6](x3) coordinate[pos=0.5] (y3);
\draw[dashed] (1,-2) -- (1,-3.5);
\path (0,-4) coordinate (z1) (1,-4) coordinate (z2) (2,-4) coordinate (z3);
\draw[dashed] (2,-3) -- (2,-3.5);
\coordinate (t) at (3,-4.1);
\coordinate (xi) at (-0.6,4);
\addplot[-latex] coordinates{(-0.5,-3.5) (3,-3.5)};
\addplot[-latex] coordinates{(-0.5,-3.5) (-0.5,3.5)};
\end{scope}
\pgfplotsinvokeforeach{1,...,20}{
\draw[very thin] plot[smooth] coordinates 
{(0,{sign(2*rand-1)*(exp(-rand/0.8)-1)}) 
(1,{1+sign(2*rand-1)*(exp(-rand/1.6)-1)})
(2,{sign(2*rand-1)*(exp(-rand/1.2)-1)})};}
\end{axis}
\foreach \X in {1,2,3}
{\fill (x\X) circle (2pt);
\draw ([xshift=-1mm]y\X) -- ([xshift=1mm]y\X);
\draw ([yshift=1mm]z\X) -- ([yshift=-1mm]z\X) node[below] {$\X$};}
\node[anchor=north east] at (t) {time};
\node[anchor=north east] at (xi) {$x(t)$};
\draw[blue,thick,shorten >=2mm,shorten <=2mm] (x1) -- (x2);
\draw[blue,thick,shorten >=2mm,shorten <=2mm] (x2) -- (x3);
\end{tikzpicture}
\end{document}

enter image description here

  • those lines to indicate mean/variance are nice thank you marmot youre awesome ! – user171006 Oct 13 '18 at 04:13
  • what i meant is would it be possible to add curves like in the diagram above that vary around the mean? – user171006 Oct 13 '18 at 04:14
  • 1
    @user171006 I still don't understand, the curves are there. Do you want additional Gaussians? –  Oct 13 '18 at 04:16
  • ok curves might be the wrong word in this context. i mean sample realizations so those grey lines in the above diagram. also is it possible to detach the y-axis of the subplot and make it bold and move it in a little so it intersects the x-axis like in the diagram above? – user171006 Oct 13 '18 at 04:18
  • 1
    @user171006 I added something. I guess one would first have to do some math to improve it. –  Oct 13 '18 at 04:42
  • awesome i`ll play around with what youve posted but its a great start ! thanks for all your help i really appreciate it. – user171006 Oct 13 '18 at 04:55