JeT
This animation aims at showing the intuition on how these elements would be correlated.

The idea is to have a bunch of vectors whose color will simply change
- blue if  y>0
- gray if  y=0
- red if  y<0

You can then see the structure of correlation between them is changing whereas the distance between them remains the same.

I am stuck on a loop as you can see in my horrible (manual) code.


%convert -delay 20 -density 100x100 -dispose previous F:/NewOrga/_chap/chap30/_TikZ/TikZCorrelBasket.pdf -coalesce -layers optimize F:/NewOrga/_chap/chap30/_TikZ/TikZCorrelBasket.gif

MWE


\documentclass[tikz]{standalone}
%\usepackage{tikz}
\usetikzlibrary{arrows.meta}

%\usetikzlibrary{external}
%\tikzexternalize[prefix=TikZOut/]

\tikzset{
arr/.style = {draw=#1, -Latex},
dot/.style = {circle, fill, minimum size=#1,
inner sep=0pt, outer sep=0pt,
fill=red, node contents={}},
dot/.default = 6pt
}
\newcommand{\correl}[1]{

\begin{tikzpicture}

%\draw[help lines,blue!20] (0.5, -4) grid (4.5, 4);
\useasboundingbox (-0.5,-2) rectangle (4.5,2);

\node (n0) [dot];

\foreach \y [count=\i] in {#1} %<- #2 How to I loop on this in  ?
{
\ifnum\y<0
\draw[arr=red]  (n0) -- (3,(\y/10) node[right] {$\mathsf{{S}_{\i}}$};
\fi
\ifnum\y=0
\draw[arr=gray] (n0) -- (3,\y/10) node[right] {$\mathsf{{S}_{\i}}$};
\fi
\ifnum\y>0
\draw[arr=blue] (n0) -- (3,\y/10) node[right] {$\mathsf{{S}_{\i}}$};
\fi
}

\end{tikzpicture}
}

\begin{document}

%Pls don't laugh too loud before you read this uggly code. I tried still uggly

%  \foreach [evaluate={
%   \a  = \x ;
%   \b = \a - 4 ;
%   \c = \b - 4 ;
%   \d = \c - 4 ;
%   }] \x in {12}
%{

%and tried to play with evaluate=\i as \x using int(\i+6) but no result.

\correl{20,14,8,2}
\correl{19,13,7,1}
\correl{18,12,6,0}
\correl{17,11,5,-1}
\correl{16,10,4,-2}
\correl{15,9,3,-3}
\correl{14,8,2,-4}
\correl{13,7,1,-5}
\correl{12,6,0,-6}
\correl{11,5,-1,-7}
\correl{10,4,-2,-8}
\correl{9,3,-3,-9}
\correl{8,2,-4,-10}
\correl{7,1,-5,-11}
\correl{6,0,-6,-12}
\correl{5,-1,-7,-13}
\correl{4,-2,-8,-14}
\correl{3,-3,-9,-15}

\end{document}




Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.