roza / Tikz

Galley of Tikz drawings.

Home Page:http://leg.ufpr.br/~walmes/Tikz/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

title author output
Tikz Gallery
Prof. Walmes M. Zeviani
html_document
css keep_md toc number_sections
style.css
true
true
false

This is my collection, or gallery, of Tikz Art. The official Tikz Gallery is on TeXample.net. A interesting exposition of Tikz features is done in http://tug.ctan.org/info/visualtikz/VisualTikZ.pdf. The official manual is available at http://linorg.usp.br/CTAN/graphics/pgf/base/doc/pgfmanual.pdf.

There are 298 Tikz figures in this gallery. Most of them were done to teach statistics, inspired by content on the web or done from the scratch. Also, a lot were caught in the web and copied with few modifications (I run tests on it).

I use ktikz editor to edit these Tikz files.

This repository is maintained in to Git Version Control and is hosted on GitHub.

If you want to reproduce these figures, do not forget of seeing the corresponding preamble that list all tikz libraries used: TIKZ_PREAMBLE.pgs.

The figures are in file file order. A page with all figures displayed in on http://www.leg.ufpr.br/~walmes/Tikz/ (updated less frequently).

Some useful tutorials or galleries:


\begin{tikzpicture}

  % \fill[red] (0, 0) circle (1pt);
  % \draw (0, 0) --
  % ++(0.375, 0) --
  % ++(60:2) --
  % ++(-0.5, 0) --
  % ++(-120:0.5) --
  % ++(-1.25, 0) --
  % ++(120:0.5) --
  % ++(-0.5, 0) --
  % ++(-60:2) --
  % cycle;

  \begin{scope}
    \foreach \angle in {0, 60, ..., 300} {
      \begin{scope}[rotate = \angle, shift = {(0, 1)}]
        \draw[draw = none, fill = green!40!black]
          (0, 0) --
          ++(0.375, 0) --
          ++(60:2) --
          ++(-0.5, 0) --
          ++(-120:0.5) --
          ++(-1.25, 0) --
          ++(120:0.5) --
          ++(-0.5, 0) --
          ++(-60:2) --
          cycle;
      \end{scope}
    }
  \end{scope}

  \begin{scope}[yshift = 0cm, xshift = 5.5cm, scale = 0.5]

    \foreach \angle in {0, 60, 120} {
      \begin{scope}[rotate = \angle, shift = {(0, 1)}]
        \draw[draw = none, fill = green!40!black]
          (0, 0) --
          ++(0.375, 0) --
          ++(60:2) --
          ++(-0.5, 0) --
          ++(-120:0.5) --
          ++(-1.25, 0) --
          ++(120:0.5) --
          ++(-0.5, 0) --
          ++(-60:2) --
          cycle;
      \end{scope}
    }

    \begin{scope}[xshift = 2cm]
      \foreach \angle in {180, 240, 300} {
        \begin{scope}[rotate = \angle, shift = {(0, 1)}]
          \draw[draw = none, fill = green!40!black]
            (0, 0) --
            ++(0.375, 0) --
            ++(60:2) --
            ++(-0.5, 0) --
            ++(-120:0.5) --
            ++(-1.25, 0) --
            ++(120:0.5) --
            ++(-0.5, 0) --
            ++(-60:2) --
            cycle;
        \end{scope}
      }
    \end{scope}

    \node[color = green!40!black] at (0.75, 0.25) {\huge\it PET};
    \node[color = green!40!black] at (0.95, -0.65) {\it Agronomia};
    \node[color = green!40!black] at (0.2, -1.35) {\it UFGD};

  \end{scope}

\end{tikzpicture}

\begin{tikzpicture}[%
  auto, > = stealth',
  node distance = 0.0ex and 2em,
  pil/.style = {->},
  punkt/.style = {
    rectangle,
    rounded corners = 3pt,
    draw = black,
    text width = 5.5em,
    minimum height = 1.75em,
    text centered}
  ]

\def\tratamentos{Tratamentos}
\def\respostas{Respostas}
\def\covariaveis{Covari{\' a}veis}
\def\rede{Rede de efeitos}

\begin{scope}
  \node[punkt] (y1) {Respostas};
  \node[punkt, above left = of y1] (t1) {\tratamentos};
  \node[punkt, below left = of y1] (x1) {Covari{\' a}veis};
  \path[pil] (t1) edge (y1);
  \path[pil] (x1) edge (y1);
  \node[fit = (t1)(x1)(y1), above, yshift = 1em] (fit1) {Rede de efeitos 1};
\end{scope}

\begin{scope}[xshift = 3.5cm]
  \node[punkt] (t3) {\tratamentos};
  \node[punkt, below right = of t3] (y3) {\respostas};
  \node[punkt, above right = of t3] (x3) {\covariaveis};
  \path[pil] (t3) edge (y3);
  \path[pil] (t3) edge (x3);
  \path[pil, dashed] (x3) edge (y3);
  \node[fit = (t3)(x3)(y3), above, yshift = 1em] (fit3) {\rede{} 2};
\end{scope}

\begin{scope}[xshift = 3.25cm, yshift = -3cm]
  \node[punkt] (y2) {\respostas};
  \node[punkt, left = of y2] (t2) {\tratamentos};
  \node[punkt, below left = 1.75em and -2em of y2] (x2) {\covariaveis};
  \path[pil] (t2) edge (y2);
  \path[pil] (x2) edge (y2);
  \path[pil] (t2) edge (x2);
  \node[fit = (t2)(x2)(y2), above, yshift = 1em] (fit2) {\rede{} 3};
\end{scope}

\end{tikzpicture}%

%% http://tex.stackexchange.com/questions/129571/add-variable-tick-in-axis

\makeatletter
\def\markxof#1{
  \pgf@process{#1}
  \pgfmathparse{
    \pgf@x/\pgfplotsunitxlength+
    \pgfplots@data@scale@trafo@SHIFT@x)/10^\pgfplots@data@scale@trafo@EXPONENT@x}
}
\makeatother

\pgfplotsset{
  every axis/.append style={font=\small},
  mystyle/.style={%
    clip=true,
    axis x line=bottom,
    axis y line=left,
    xmin=1, xmax=64,
    samples =32,
    ymax = 1.6, ymin  = -0.2}
}

\begin{tikzpicture}
  \begin{axis}[
    mystyle,
    grid = major,
    grid style={dashed},
    xlabel={\emph{sample number}},
    xlabel style={at={(1,-0.2)}, anchor=south},
    legend cell align=left,
    legend pos=outer north east]

    \addplot[name path global=one,blue,mark=+,domain=1:64]
      {exp(-log10(2)/(8^2/4)*(\x-32)^2)};
    \addplot[name path global=two,red,domain=1:64] {0.5};
    \path [name intersections={of=one and two, name=i}];
    \pgfplotsextra{
      \path (i-1) \pgfextra{\markxof{i-1}\xdef\mytick{\pgfmathresult}};
    }
    \path let \p1=($(i-1)$) in (\x1,\y1);
    \draw[dashed] (i-1) -- ($(axis cs:0,-0.2)!(i-1)!(axis cs:64,-.2)$);
    \legend{Sampled signal, Threshold}
  \end{axis}

  \begin{axis}[
    mystyle,
    xtick=\empty, ytick=\empty,
    extra x ticks={\mytick},
    extra x tick labels={$t_{step}$},
    extra x tick style={
      xticklabel style={yshift=-10}
    }]
  \end{axis}
\end{tikzpicture} 

\begin{tikzpicture}[%
  auto, > = stealth',
  node distance = 0.0ex and 3em,
  pil/.style = {->},
  punkt/.style = {
    rectangle,
    rounded corners = 3pt,
    draw = black,
    text width = 8em,
    minimum height = 4em,
    text centered}
  ]

\begin{scope}[xshift = 3.5cm]
  \node[punkt, fill = gray!10] (t0) {Aumento da temperatura};
  \node[punkt, fill = gray!10, right = of t0] (t1) {Aumento de banhistas};
  \node[punkt, fill = cyan!30, below right = of t1] (t2) {Aumento das vendas de sorvete ($Y_1$)};
  \node[punkt, fill = orange!30, above right = of t1] (t3) {Aumento dos ataques de tubar{\~a}o ($Y_2$)};
  \path[pil] (t0) edge (t1)
    (t1) edge (t2)
    (t1) edge (t3);
   \path[pil, <->, dashed] (t2) edge (t3);
\end{scope}

\end{tikzpicture}%
kt, below right = of t3] (y3) {\respostas};
  \node[punkt, above right = of t3] (x3) {\covariaveis};
  \path[pil] (t3) edge (y3);
  \path[pil] (t3) edge (x3);
  \path[pil, dashed] (x3) edge (y3);
  \node[fit = (t3)(x3)(y3), above, yshift = 1em] (fit3) {\rede{} 2};
\end{scope}

\begin{scope}[xshift = 3.25cm, yshift = -3cm]
  \node[punkt] (y2) {\respostas};
  \node[punkt, left = of y2] (t2) {\tratamentos};
  \node[punkt, below left = 1.75em and -2em of y2] (x2) {\covariaveis};
  \path[pil] (t2) edge (y2);
  \path[pil] (x2) edge (y2);
  \path[pil] (t2) edge (x2);
  \node[fit = (t2)(x2)(y2), above, yshift = 1em] (fit2) {\rede{} 3};
\end{scope}

\end{tikzpicture}%

%% http://tex.stackexchange.com/questions/69445/using-pgfplots-why-do-i-get-undefined-control-sequence-when-trying-to-use-a-f

\begin{tikzpicture}
  \begin{axis}
    \foreach \x/\y in {a/-1cm, b/0cm, c/1cm} {
      \edef\temp{
        \noexpand\addplot+[
          every error bar/.append style={xshift=\y},
          every node/.style={xshift=\y},
          error bars/y dir=both,
          error bars/y explicit]
      }
      \temp
      coordinates {
        (0, 0) +- (0, 1)
        (1, 0) +- (0, 1)
        (2, 0) +- (0, 1)
      };
    }
  \end{axis}
\end{tikzpicture}

\pgfplotsset{
  select row/.style={
    x filter/.code={\ifnum\coordindex=#1\else\def\pgfmathresult{}\fi}
  }
}

\pgfplotstableread[col sep=comma,header=false]{
  1999/00,167.1
  2000/1,172.5
  2001/2,175
  2002/3,179.3
  2003/4,184.4
  2004/5,188
  2005/6,201.7
  2006/7,208.3
  2007/8,210.2
  2008/9,210.5
  2009/10,209.8
  2010/11,207.5
  2011/12,203.4
  2012/13,198.2
  % 2013/14(YTD),97
}\datatable

\begin{tikzpicture}[scale=0.8]
  \begin{axis}[
    % title=Australia's Primary Energy Consumption by sector - 2012,
    ybar, bar shift=0pt,
    enlarge y limits=0.1,
    % xmin=0,
    xtick={0,...,13},
    xticklabels from table={\datatable}{0},
    ymajorgrids = true,
    bar width=3mm, 
    width=12cm, height=9cm, 
    xlabel={year},
    ylabel={TWh},
    x tick label style={font=\footnotesize,rotate=45, anchor=east},
    nodes near coords align={horizontal}]

    \pgfplotsinvokeforeach{0,...,13}{
      \addplot table [x expr=\coordindex, select row=#1] {\datatable};
    }
    \node[
      pin={[pin distance=1cm, pin edge={<-,>=stealth'},
        shift={(-1.2cm,0.5cm)}]
      Tasmania entry to NEM}] at (axis cs:5,190) {};
  \end{axis}
\end{tikzpicture}

\newcommand{\target}[1]{%
  \foreach \r in {2.5, 2, 1.5, 1, 0.5, 0.05} {
    \draw [
      fill = black,
      fill opacity = 0.05
    ] (0, 0) circle (\r cm);
  }
}%

\begin{tikzpicture}[
  every path/.style = {draw, > = stealth'},
  nodetext/.style = {
    draw, rounded corners = 2pt, fill = white,
  },
  labeltext/.style = {
    draw, minimum width = 5.25cm, minimum height = 1.5em, fill = gray!20,
  }]

\def\dist{5.5};

\begin{scope}[shift = {(0, 0)}, scale = 1.25]

  \target

  \foreach \x/\y in {0.825/1.414, 1.827/0.407, 1.068/0.855, 2.016/0.645, 2.131/-0.294, 0.341/1.3, 1.306/-0.008, 2.035/-0.416, 1.353/0.156, 1.163/1.409} {
    \draw[fill = orange] (\x, \y) circle (2pt);
  }

  \node[text = cyan] (mean) at (1.4065, 0.5468) {$\times$};
  \node[text = magenta] (theta) at (0, 0) {$\times$};

  \path[->] (mean) to[out = 90, in = 180] ++(1, 1) node[nodetext, right] {$\text{E}(\hat{\theta)}$};
  \path[->] (theta) to[out = 90, in = 0] ++(-1, 1) node[nodetext, left] {$\theta$};
  \path[->] (1.163, 1.409) to[out = 90, in = 180] ++(1, 1) node[nodetext, right] {$\hat{\theta}_i$};

  \node[nodetext] at (0, -3) {$\textcolor{magenta}{\text{EQM}(\hat{\theta})} = \textcolor{cyan}{\text{V}(\hat{\theta})} - \textcolor{red}{\text{B}(\hat{\theta})}^2$};

\end{scope}

\begin{scope}[shift = {(7, 0)}]

  \target

  \foreach \x/\y in {0.825/1.414, 1.827/0.407, 1.068/0.855, 2.016/0.645, 2.131/-0.294, 0.341/1.3, 1.306/-0.008, 2.035/-0.416, 1.353/0.156, 1.163/1.409} {
    \draw[fill = orange] (\x, \y) circle (2pt);
    \draw[dashed, magenta] (\x, \y) -- (0, 0);
  }

  \node[nodetext] at (0, -1) {$\textcolor{magenta}{\text{EQM}(\hat{\theta})} = 1/n\sum (\hat{\theta}_i - \theta)^2$};

  \node[text = cyan] at (1.4065, 0.5468) {$\times$};
  \node[text = magenta] at (0, 0) {$\times$};

\end{scope}

\begin{scope}[shift = {(12, 2.75)}]

  \target

  \foreach \x/\y in {0.825/1.414, 1.827/0.407, 1.068/0.855, 2.016/0.645, 2.131/-0.294, 0.341/1.3, 1.306/-0.008, 2.035/-0.416, 1.353/0.156, 1.163/1.409} {
    \draw[fill = orange] (\x, \y) circle (2pt);
    \draw[dashed, cyan] (\x, \y) -- (1.4065, 0.5468);
  }

  \node[nodetext] at (0, -1) {Vari{\^a}ncia: $\textcolor{cyan}{\text{V}(\hat{\theta})} = 1/n\sum (\hat{\theta}_i - \text{E}(\hat{\theta}))^2$};

  \node[text = cyan] at (1.4065, 0.5468) {$\times$};
  \node[text = magenta] at (0, 0) {$\times$};

\end{scope}

\begin{scope}[shift = {(12, -2.75)}]

  \target

  \foreach \x/\y in {0.825/1.414, 1.827/0.407, 1.068/0.855, 2.016/0.645, 2.131/-0.294, 0.341/1.3, 1.306/-0.008, 2.035/-0.416, 1.353/0.156, 1.163/1.409} {
    \draw[fill = orange] (\x, \y) circle (2pt);
  }

  \node[nodetext] at (0, -1) {V{\'i}cio: $\textcolor{red}{\text{B}(\hat{\theta})} = \text{E}(\hat{\theta}) - \theta$};

  \node[text = cyan] at (1.4065, 0.5468) {$\times$};
  \node[text = magenta] at (0, 0) {$\times$};

  \draw[dashed, red] (0, 0) -- (1.4065, 0.5468);

\end{scope}

\end{tikzpicture}%

% # R code.
% set.seed(123)
% n <- 10
% xy <- round(cbind(1.25 + 1 * runif(n, -1, 1),
%                   0.50 + 1 * runif(n, -1, 1)),
%             digits = 3)
% colMeans(xy)
% u <- apply(xy,
%            MARGIN = 1,
%            FUN = function(x) {
%                paste(x, collapse = "/")
%            })
% cat(u, sep = ", ", "\n")

\begin{tikzpicture}[
  every path/.style = {draw, > = stealth'},
  nodetext/.style = {
    rounded corners = 2pt, fill = white, minimum height = 2em
  },
  ]

  \draw (0, 0) -- ++(0, 4) node[nodetext, above] {$\theta$};
  \draw (1.4065, 0) -- ++(0, 4) node[nodetext, above] {$\text{E}(\hat{\theta})$};

  \def\fac{0.38}

  \foreach \x [count = \y] in {0.825, 1.827, 1.068, 2.016, 2.131, 0.341, 1.306, 2.035, 1.353, 1.163} {
    \draw[fill = orange] (\x, \fac*\y) circle (2pt);
    \draw[dashed, yshift =  1pt, magenta] (0, \fac*\y) -- (\x, \fac*\y);
    \draw[dashed, yshift = -1pt, cyan] (1.4065, \fac*\y) -- (\x, \fac*\y);
  }

  \path[->] (2.035, \fac*8) to[out = 90, in = 180] ++(1, 1) node[nodetext, right] {$\hat{\theta}_i$};

  \node[nodetext, right] at (3, 2.5) {
    $\textcolor{magenta}{\text{EQM}(\hat{\theta})} =
    \textcolor{cyan}{\text{V}(\hat{\theta})} - \textcolor{red}{\text{B}(\hat{\theta})}^2$};


  \path[->, yshift = 1pt, magenta] (1.827 - 0.2, \fac*2) to[out = 90, in = 180] (3, 1.2)
    node[nodetext, right, text = black] {
      $\textcolor{magenta}{\text{EQM}(\hat{\theta})} = (1/n) \sum (\hat{\theta}_i - \theta)^2$};

  \path[->, yshift = -1pt, cyan] (1.827 - 0.2, \fac*2) to[out = -90, in = 180] (3, 0.50)
    node[nodetext, right, text = black] {
      Vari{\^a}ncia: $\textcolor{cyan}{\text{V}(\hat{\theta})} =
      (1/n)\sum (\hat{\theta}_i - \text{E}(\hat{\theta}))^2$};

  \draw[dashed, yshift = -4pt, red] (1.4065, 0) -- (0, 0);
  \path[->, red] (1.4065/2, -4pt) to[out = -90, in = 180] (3, -0.3)
    node[nodetext, right, text = black] {
      V{\'i}cio: $\textcolor{red}{\text{B}(\hat{\theta})} = \text{E}(\hat{\theta}) - \theta$};

\end{tikzpicture}%

% # R code.
% set.seed(123)
% n <- 10
% xy <- round(cbind(1.25 + 1 * runif(n, -1, 1),
%                   0.50 + 1 * runif(n, -1, 1)),
%             digits = 3)
% colMeans(xy)
% u <- apply(xy,
%            MARGIN = 1,
%            FUN = function(x) {
%                paste(x, collapse = "/")
%            })
% cat(u, sep = ", ", "\n")

\newcommand{\target}[1]{%
  \foreach \r in {2.5, 2, 1.5, 1, 0.5, 0.05} {
    \draw [
      fill = black,
      fill opacity = 0.15
    ] (0, 0) circle (\r cm);
  }
}%

\newcommand{\points}[3]{%
  \foreach \i in {1, 2, ..., 20} {
    \pgfmathsetmacro{\xcoord}{#1 + rand * #3}
    \pgfmathsetmacro{\ycoord}{#2 + rand * #3}
    \draw[fill = orange] (\xcoord, \ycoord) circle (2pt);
  }
}%


\newcommand{\circlevar}[3]{%
  \draw[color = green] (#1, #2) circle (#3 cm);
  \node[text = green] at (#1, #2) {$\times$};
}%

\def\border{
  \draw (-2.65, -2.75) -- ++(5.25, 0);
  \draw (2.75, 2.65) -- ++(0, -5.25);
}%

\begin{tikzpicture}[
  labeltext/.style = {
    draw, minimum width = 5.25cm, minimum height = 1.5em, fill = gray!20,
  }]

\def\dist{5.5};

\begin{scope}[shift = {(0, 0)}]

  \node[labeltext] at (0, 3) {Sem v{\'i}cio};
  \node[labeltext, rotate = 90] at (-3, 0) {Alta vari{\^a}ncia};
  \target

  \points{0}{0}{1}

  \circlevar{0}{0}{1.15}
  \border
\end{scope}

\begin{scope}[shift = {(\dist, 0)}]

  \node[labeltext] at (0, 3) {Com v{\'i}cio};
  \target 

  \points{1.25}{0.50}{1}

  \circlevar{1.25}{0.50}{1.15}
  \border
\end{scope}

\begin{scope}[shift = {(0, -\dist)}]

  \node[labeltext, rotate = 90] at (-3, 0) {Baixa vari{\^a}ncia};
  \target

  \points{0}{0}{0.5}

  \circlevar{0}{0}{0.65}
  \border
\end{scope}

\begin{scope}[shift = {(\dist, -\dist)}]

  \target

  \points{1.25}{0.5}{0.5}

  \circlevar{1.25}{0.50}{0.65}
  \border
\end{scope}

\end{tikzpicture}%cope}[shift = {(\dist, -\dist)}]

  \target

  \foreach \j in {1, 2, ..., 20} {
    \pgfmathsetmacro{\xcoord}{1.25 + rand * 0.5}
    \pgfmathsetmacro{\ycoord}{0.50 + rand * 0.5}
    \draw[fill = orange] (\xcoord, \ycoord) circle (2pt);
  }

  \circlevar{1.25}{0.50}{0.75}
  \border
\end{scope}

\end{tikzpicture}%scope}[minimum width = 1em, text width = 5.0em, text centered]
% 
%   \node[state] (int) at ( 90:5.5) {\emph{Intui{\c c}{\~ a}o e viabilidade}};
%   \node[state] (val) at (210:5.0) {\emph{Solu{\c c}{\~ a}o e valida{\c c}{\~ a}o}};
%   \node[state] (aut) at (-30:5.0) {\emph{Automa{\c c}{\~ a}o e escala}};
% 
%   \node (con) at (90:3) {Dom{\' i}nio de\\ conhecimento};
%   \node (est) at (210:3) {Matem{\' a}tica \& Estat{\' i}stica};
%   \node[text width = 7em] (hac) at (-30:3) {Habilidades de\\ computa{\c c}{\~ a}o};
% 
%   \node[color = red] (sof) at (30:2) {Processamento tradicional};
%   \node[color = red] (pes) at (150:2) {Pesquisa tradicional};
%   \node[color = red] (mac) at (-90:2) {Zona perigosa};
% 
%   \node (ds) at (0:0) {\large Data Science};
% 
% \end{scope}

% \begin{scope}[
%   every node/.style = {
%     text centered,
%     font = \footnotesize,
%     text width = 5em
%   }]
% 
%   \node at ( 50:3.50) {Engenharia};
%   \node at (130:3.50) {Direito};
%   \node at ( 70:5.00) {Biologia};
%   \node at (110:5.00) {Marketing};
%   \node at ( 60:4.25) {Economia};
%   \node at (120:4.25) {Comunica{\c c}{\~a}o};
%   \node at ( 90:4.25) {Gest{\~a}o};
% 
%   \node at ( 05:4.0) {Programa{\c c}{\~a}o};
%   \node at (-05:4.5) {Algor{\'\i}tmos};
%   \node at (-15:5.0) {Bancos de dados};
%   \node at (-50:3.5) {Computa{\c c}{\~a}o em n{\'u}vem};
%   \node at (-60:4.5) {Machine learning};
% 
%   \node at (175:4.0) {Visualiza{\c c}{\~a}o};
%   \node at (185:4.5) {Otimiza{\c c}{\~a}o};
%   \node at (195:5.0) {Infer{\^e}ncia estat{\'\i}stica};
%   \node at (230:3.5) {An{\'a}lise multivariada};
%   \node at (240:4.5) {Modelagem estat{\'\i}stica};
% 
% \end{scope}

\end{tikzpicture}%%

\begin{tikzpicture}%

  \definecolor{colorA}{HTML}{66ffff}
  \definecolor{colorB}{HTML}{0066ff}

  \begin{scope}

    \begin{axis}[
      domain   = -3.5:3.5,
      domain y = -3.5:3.5,
      view = {-70}{12},
      % xlabel=$\beta_0$,
      % ylabel=$\beta_1$,
      % zlabel={$SSE(\beta_0, \beta_1)$},
      zmin = -0,
      xticklabels = \empty,
      yticklabels = \empty,
      zticklabels = \empty,
      axis lines = none,
      declare function = {mu1 = 0;},
      declare function = {mu2 = 0;},
      declare function = {sigma1 = 1;},
      declare function = {sigma2 = 1;},
      declare function = {ro = 0.7;},
      declare function = {
        bivar(\ma,\sa,\mb,\sb,\ro)=
        exp(-(((x-\ma)/\sa)^2+((y-\mb)/\sb)^2-(2*\ro)*((x-\ma)/\sa)*((y-\mb)/\sb))/(2*(1-\ro^2)))/(2*pi*\sa*\sb*(1-\ro^2)^0.5);
      },
      declare function = {condy = -0.75;},
%       declare function = {
%         conditionalnormal(\condy,\ma,\sa,\mb,\sb,\ro)=
%         exp(-(x-(\ma+\sa*\ro*(\condy-\mb)/\sb))^2/(2*\sa^2*(1-\ro^2)))/(\sa*(1-\ro^2)^0.5*(2*pi)^0.5);
%       },
      declare function = {
        bivarcond(\yc,\ma,\sa,\mb,\sb,\ro)=
        exp(-(((x-\ma)/\sa)^2+((\yc-\mb)/\sb)^2-(2*\ro)*((x-\ma)/\sa)*((\yc-\mb)/\sb))/(2*(1-\ro^2)))/(2*pi*\sa*\sb*(1-\ro^2)^0.5);
      },
      ]

    \addplot3 [domain = -3.5:3.5, samples = 31, samples y = 0,
      thick, smooth, color = red, fill = orange, opacity = 0.75]
          (x, condy, {bivarcond(condy, mu1, sigma1, mu2, sigma2, ro)});
    \draw (axis cs:-3, condy, 0) -- (axis cs: 3, condy, 0);

    \addplot3 [
      surf,
      samples = 31,
      opacity = 0.15,
      faceted color = colorB,
      colormap = {blueblack}{
        color = (colorB)
        color = (colorA!50!white)
        color = (colorA)},
      ] {bivar(mu1, sigma1, mu2, sigma2, ro)};

%     \addplot3 [domain = -3:3, samples = 31, samples y = 0,
%       thick, smooth, color = red, fill = orange, opacity = 0.75]
%           (x, condy, {exp(-(condy - mu2)^2/(2*sigma2))/(2*pi*sigma2^2)^0.5*conditionalnormal(condy, mu1, sigma1, mu2, sigma2, ro)});

%       \draw (axis cs: 0, -3, 0) -- (axis cs: 0, 3, 0);

    \end{axis}

  \end{scope}

\end{tikzpicture}%


\end{tikzpicture}%
gma2, ro)});

%       \draw (axis cs: 0, -3, 0) -- (axis cs: 0, 3, 0);

    \end{axis}

  \end{scope}

\end{tikzpicture}%
axis}

  \end{scope}

\end{tikzpicture}%

\def\xs{0.6}
\def\ys{1}
\def\ty{2.5}
\def\tx{1}
\def\tc{0.3}

\begin{tikzpicture}[xscale=\xs, yscale=\ys, >=latex]
  \begin{scope}
    \draw[->] (0,0) -- (5,0) node[below] {$x$};
    \draw[->] (0,0) -- (0,3) node[left] {$\eta(x)$};
    \foreach \tty in {0.8,1.6,2.4}
    \draw[color=green!30!black, thick, smooth]
      plot[id=x, domain=0:4.8]
      function{\tty*(x/\tx)*(1-\tc*(1-x/\tx))**(-1/\tc)};
    \draw[->,xshift=\tx cm] (0,0.35) -- (0,2.8)
      node[above] {$\vartheta_y$};
    \draw (\tx,0) node {$\times$} node[below] {$\vartheta_x$};
  \end{scope}
  \begin{scope}[xshift=6cm]
    \draw[->] (0,0) -- (5,0) node[below] {$x$};
    \draw[->] (0,0) -- (0,3) node[left] {$\eta(x)$};
    \foreach \ttx in {0.5,1.5,2.5}
    \draw[color=green!30!black, thick, smooth]
      plot[id=x, domain=0:4.8]
      function{\ty*(x/\ttx)*(1-\tc*(1-x/\ttx))**(-1/\tc)};
    \draw[->,xshift=0.25cm,yshift=0.1cm] (0,\ty) -- (3,\ty)
      node[midway,above] {$\vartheta_x$};
    \draw (0, \ty) node {$\times$} node[left] {$\vartheta_y$};
  \end{scope}
  \begin{scope}[xshift=12cm]
    \draw[->] (0,0) -- (5,0) node[below] {$x$};
    \draw[->] (0,0) -- (0,3) node[left] {$\eta(x)$};
    \foreach \ttc in {0.05,0.3,0.55}
    \draw[color=green!30!black, thick, smooth]
      plot[id=x, domain=0:4.8]
      function{\ty*(x/\tx)*(1-\ttc*(1-x/\tx))**(-1/\ttc)};
    \draw[->,xscale=1/\xs, yscale=1/\ys] (1.1,1.3) arc (290:350:1.5cm)
      node[above] {$\theta_2$};
    \draw (0, \ty) node {$\times$} node[left] {$\vartheta_y$};
    \draw (\tx,0) node {$\times$} node[below] {$\vartheta_x$};
  \end{scope}
\end{tikzpicture}

\begin{tikzpicture}[scale=2.2, >=latex]
  % preenchimentos
  \draw[draw=none, fill=gray!15] (0,0) -- (0,1.5) -- 
    plot[id=x, domain=0:1] function{1+2*(x-0.5)**2} -- (1,0);
  \draw[draw=none, fill=gray!15] (-1,-0.75) rectangle (2,0.13);
  \draw[draw=none, fill=gray!25]
    (1,1.52) arc (0:-180:0.5cm and 0.2cm) --
    plot[id=x, domain=0:1] function{1+2*(x-0.5)**2};
  \draw[draw=none, fill=gray!40] (0.5,1.52) ellipse (0.5cm and 0.2cm);

  % laterais do tubo
  \draw (-1,0.15) -- (-1,-0.75) -- (2,-0.75) -- (2,0.2);
  \draw (0,0) -- (0,2);
  \draw (1,0) -- (1,2);
  \draw[yshift=2cm, dashed] (0,0) -- (0,0.15);
  \draw[yshift=2cm, dashed] (1,0) -- (1,0.15);
  \draw[dashed] (0,0) -- (0,-0.15);
  \draw[dashed] (1,0) -- (1,-0.15);

  % parabola e elipses
  \draw plot[id=x, domain=0:1, samples=50, smooth]
    function{1+2*(x-0.5)**2};
  \draw[dashed] (0.5,2) ellipse (0.5cm and 0.2cm);
  \draw[dashed] (1,1.52) arc (0:180:0.5cm and 0.2cm);
  \draw (0,1.52) arc (180:360:0.5cm and 0.2cm);

  % chaves
  \draw [xshift=1.1cm, decorate, decoration={brace, amplitude=4pt}]
    (0,1) -- (0,0.1) node [black,midway,right=5pt] {$h$};
  \draw [yshift=-0.15cm, decorate, decoration={brace, amplitude=4pt}]
    (0.5,0) -- (0,0) node [black,midway,below=5pt] {$r$};

  % angulo
  \draw[<->,yshift=-0.5cm] (1,1.55) arc (270:246:0.5cm and 0.5cm);
  \path (1,1.52)++(255:0.5) node[below] {$\alpha$};

  % setas do menisco
  \path[yshift=-0.5cm,xshift=-0.24cm,->, draw=black]
    (0.5,1.52)++(0:0.5 and 0.2) -- ++(0.5,1);
  \path[yshift=-0cm,xshift=-1.0cm,->, draw=black]
    (0.5,1.52)++(0:0.5 and 0.2) -- ++(-0.25,0.5);
  \path[->, draw=black] (0.5,1.52)++(45:0.5 and 0.2) -- ++(0.15,0.55);
  \path[->, draw=black] (0.5,1.52)++(90:0.5 and 0.2) -- ++(0.0,0.58);
  \path[->, draw=black] (0.5,1.52)++(135:0.5 and 0.2) -- ++(-0.15,0.55);
  \path[->, draw=black] (0.5,1.52)++(225:0.5 and 0.2) -- ++(-0.15,0.4);
  \path[->, draw=black] (0.5,1.52)++(315:0.5 and 0.2) -- ++(0.15,0.4);
  \path[->, draw=black] (0.5,1.52)++(270:0.5 and 0.2) -- ++(0.0,0.38);
  % \draw[color=gray!10] (0.5,2) ellipse (0.75cm and 0.3cm);

  % setas grossas
  \draw[->, line width=3pt] (0.5,0.8) -- ++(0,-0.5)
    node[below] {$\pi r^2 h\rho g$};
  \draw[->, line width=3pt] (0.5,2.4) -- ++(0,0.5)
    node[above] {$2\pi r \gamma \cos(\alpha)$};

  % setas com textos
  \path[xshift=2pt, yshift=-2pt, ->, draw]
    (1,1.52)++(255:0.5) to[out=0, in=180] ++(0.3,0.3)
    node[anchor=west, text ragged, text width=3cm]
    {\^angulo entre o menisco e a parede do tubo capilar};
  \path[xshift=5.5pt, yshift=-2pt, ->, draw]
    (1.1,0.5) to[out=270, in=180] ++(0.2,-0.15)
    node[anchor=west, text ragged, text width=2cm] {ascens\~ao};
  \path[xshift=2pt, yshift=-5pt, ->, draw]
    (0.25,-0.15) to[out=0, in=180] ++(0.3,-0.2)
    node[anchor=west, text ragged, text width=3cm]
    {raio do tubo capilar};

  \begin{scope}[xshift=3.25cm, yshift=-0.75cm, scale=1.25]
    % base
    \draw[draw=none, fill=gray!40] (-0.5,0) rectangle (1.5,0.7);
    \draw (-0.5,0.75) -- (-0.5,0) -- (1.5,0) -- (1.5,0.75);

    % preenchimento
    \draw[draw=none, fill=gray!40] (0,0.5) --
      plot[id=x, domain=0:0.45, smooth]
      function{0.8+1*(x-0.225)**2} --
      plot[id=x, domain=0.45:0.70, smooth]
      function{1.25+2*(x-0.575)**2} --
      plot[id=x, domain=0.70:0.80, smooth]
      function{2+4*(x-0.75)**2} --
      plot[id=x, domain=0.8:0.85, smooth]
      function{2.45+8*(x-0.825)**2} -- 
      plot[id=x, domain=0.85:1, smooth]
      function{1.6+3*(x-0.925)**2} -- (1,0.5);

    % tubos
    \draw (0,0.5) -- ++(0,2);
    \draw (0.45,0.5) -- ++(0,2);
    \draw (0.70,0.5) -- ++(0,2);
    \draw (0.80,0.5) -- ++(0,2);
    \draw (0.85,0.5) -- ++(0,2);
    \draw (1,0.5) -- ++(0,2);
  \end{scope}
\end{tikzpicture}

% http://tex.stackexchange.com/questions/22406/how-to-make-a-textbox-with-this-tikz-code

\xdefinecolor{mycolor}{RGB}{62,96,111} % Neutral Blue
\colorlet{bancolor}{mycolor}
% \def\bancolor{mycolor}

\newenvironment{mybox}[3][]{%
  \begin{tikzpicture}[#1]%
    \def\myboxname{#3}%
    % good options: minimum height, minimum width
    \node [draw, inner sep=1.5ex, text width=#2, align=justify]
      (BOXCONTENT) \bgroup\rule{0pt}{3ex}\ignorespaces
  }{%
    \egroup;
    \node [right, inner xsep=1em, fill=bancolor!75, outer sep=0pt,
      text height=2ex, text depth=.5ex] (BOXNAME) 
      at ([shift={(-1em,0pt)}]BOXCONTENT.north west) {\myboxname};
    \fill[bancolor] (BOXNAME.north east) -- +(-1em,1em)
      -- +(-1em,0) -- cycle;
    \fill[bancolor] (BOXNAME.south west) -- +(1em,-1em)
      -- +(1em,0) -- cycle;
  \end{tikzpicture}
}

\begin{mybox}{10em}{Test}
  This is the content
\end{mybox}

\begin{mybox}{25em}{Test it really good}
  This is the longer content
  This is the longer content
  This is the longer content
  This is the longer content
  This is the longer content
\end{mybox}

% https://blog.karssen.org/2009/09/14/using-tikz-to-generate-an-abstract-box-in-latex/

\tikzset{
  abstractbox/.style={
    draw=black, fill=white, rectangle, 
    inner sep=10pt, style=rounded corners,
    drop shadow={fill=black, opacity=1}
  },
  abstracttitle/.style={fill=white}
}

\newcommand{\boxabstract}[2][fill=white]{
  \begin{tikzpicture}
    \node [abstractbox, #1] (box)
    {\begin{minipage}{0.80\linewidth}
        \setlength{\parindent}{2mm} % Indentar.
        \footnotesize #2
      \end{minipage}};
    \node[abstracttitle, right=10pt] at (box.north west) {Abstract};
    \node[draw=none, fit=(box)] {};
  \end{tikzpicture}
}

\boxabstract{
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum
  egestas tempor bibendum. Pellentesque et elit eu tellus malesuada
  consequat. Donec lacinia volutpat tortor quis aliquet. Vestibulum
  posuere vehicula massa non ornare. Praesent condimentum maximus
  consectetur. Cras porttitor eget augue vitae lacinia. Nunc eu bibendum
  mauris. Sed a libero velit. Nunc sed posuere leo, a bibendum
  dui. Vivamus quis purus accumsan, euismod sem pellentesque, facilisis
  nisl. Donec a massa pulvinar, ultrices arcu nec, ultricies
  enim. Quisque id condimentum orci. Fusce id vulputate leo, vel ornare
  lorem.
}

\makeatletter
% Define our own style
\tikzstyle{week list sunday}=[
  % Note that we cannot extend from week list,
  % the execute before day scope is cumulative
  execute before day scope={%
    \ifdate{day of month=1}{\ifdate{equals=\pgfcalendarbeginiso}{}{
        % On first of month, except when first date in calendar.
        \pgfmathsetlength{\pgf@y}{\tikz@lib@cal@month@yshift}%
        \pgftransformyshift{-\pgf@y}
      }}{}%
  },
  execute at begin day scope={%
    % Because for TikZ Monday is 0 and Sunday is 6,
    % we can't directly use \pgfcalendercurrentweekday,
    % but instead we define \c@pgf@counta (basically) as:
    % (\pgfcalendercurrentweekday + 1) % 7
    \pgfmathsetlength\pgf@x{\tikz@lib@cal@xshift}%
    \ifnum\pgfcalendarcurrentweekday=6
    \c@pgf@counta=0
    \else
    \c@pgf@counta=\pgfcalendarcurrentweekday
    \advance\c@pgf@counta by 1
    \fi
    \pgf@x=\c@pgf@counta\pgf@x
    % Shift to the right position for the day.
    \pgftransformxshift{\pgf@x}
  },
  execute after day scope={
    % Week is done, shift to the next line.
    \ifdate{Saturday}{
      \pgfmathsetlength{\pgf@y}{\tikz@lib@cal@yshift}%
      \pgftransformyshift{-\pgf@y}
    }{}%
  },
  % This should be defined, glancing from the source code.
  tikz@lib@cal@width=7
]
\tikzoption{day headings}{\tikzstyle{day heading}=[#1]}
\tikzstyle{day heading}=[]
\tikzstyle{day letter headings}=[
  execute before day scope={\ifdate{day of month=1}{%
      \pgfmathsetlength{\pgf@ya}{\tikz@lib@cal@yshift}%
      \pgfmathsetlength\pgf@xa{\tikz@lib@cal@xshift}%
      \pgftransformyshift{-\pgf@ya}
      \foreach \d/\l in {0/D,1/S,2/T,3/Q,4/Q,5/S,6/S} {
        \pgf@xa=\d\pgf@xa%
        \pgftransformxshift{\pgf@xa}%
        \pgftransformyshift{\pgf@ya}%
        \node[every day, day heading]{\tiny\l};%
      } 
    }{}%
  }%
]
\makeatother

\tikzstyle{labest}=[font=\footnotesize, fill=orange!50, inner sep=2pt]
\tikzstyle{evento}=[font=\footnotesize, fill=red!50, inner sep=2pt]

% The actual calendar is now rather easy:
\begin{tikzpicture}[
  every calendar/.style={
    month label above centered,
    % day letter headings,
    month text={\textit{\%mt}},
    if={(Sunday) [blue!75]},
    if={(Saturday) [black!50]},
    week list sunday,
    day yshift=1em, day xshift=1.25em}]

  % % Layout 3 colunas e 4 linhas.
  % \matrix[column sep=0.1em, row sep=0.2em] {
  %   \calendar[dates=2016-01-01 to 2016-01-last]; &
  %   \calendar[dates=2016-02-01 to 2016-02-last]
  %     if (equals=02-29) [orange]; &
  %   \calendar[dates=2016-03-01 to 2016-03-last]; \\
  %   \calendar[dates=2016-04-01 to 2016-04-last]; &
  %   \calendar[dates=2016-05-01 to 2016-05-last]
  %     if (between=05-23 and 05-25) [red]
  %     if (equals=05-06) [orange]; &
  %   \calendar[dates=2016-06-01 to 2016-06-last]; \\
  %   \calendar[dates=2016-07-01 to 2016-07-last]
  %     if (between=07-24 and 07-29) [red]; &
  %   \calendar[dates=2016-08-01 to 2016-08-last]; &
  %   \calendar[dates=2016-09-01 to 2016-09-last]; \\
  %   \calendar[dates=2016-10-01 to 2016-10-last]
  %     if (between=10-04 and 10-05) [red]; &
  %   \calendar[dates=2016-11-01 to 2016-11-last]; &
  %   \calendar[dates=2016-12-01 to 2016-12-last]; \\
  % };

  % Layout 4 colunas e 3 linhas.
  \matrix[column sep=0.1em, row sep=0em] {
    \calendar[dates=2016-01-01 to 2016-01-last]; &
    \calendar (Fev) [dates=2016-02-01 to 2016-02-last]
      if (equals=02-29) [orange]; &
    \calendar[dates=2016-03-01 to 2016-03-last]; &
    \calendar[dates=2016-04-01 to 2016-04-last]; \\
    \calendar (Mai) [dates=2016-05-01 to 2016-05-last]
      if (between=05-23 and 05-25) [red]
      if (equals=05-06) [orange]; &
    \calendar[dates=2016-06-01 to 2016-06-last]; &
    \calendar (Jul) [dates=2016-07-01 to 2016-07-last]
      if (between=07-24 and 07-29) [red]; &
    \calendar (Ago) [dates=2016-08-01 to 2016-08-last]
      if (equals=08-01) [orange]; \\
    \calendar[dates=2016-09-01 to 2016-09-last]; &
    \calendar (Out) [dates=2016-10-01 to 2016-10-last]
      if (between=10-04 and 10-05) [red]
      if (equals=10-07) [orange]; &
    \calendar[dates=2016-11-01 to 2016-11-last]; &
    \calendar[dates=2016-12-01 to 2016-12-last]; \\
  };

  \draw[black] (Fev-2016-02-29) |- +(0.3,-0.4)
    node [labest, right] {$\blacktriangleright$ \textit{labest}};
  \draw[black] (Mai-2016-05-06) |- +(0.3,0.4)
    node [labest, right] {{\tiny $\blacksquare$} \textit{labest}};
  \draw[black] (Ago-2016-08-01) -| +(-0.4,0.4)
    node [labest, above] {$\blacktriangleright$ \textit{labest}};
  \draw[black] (Out-2016-10-07) |- +(0.1,0.8)
    node [labest, right] {{\tiny $\blacksquare$} \textit{labest}};

  \draw[black] (Mai-2016-05-25) |- +(0.1,-0.5)
    node [evento, right] {\textit{RBRAS}};
  \draw[black] (Jul-2016-07-28) |- +(0.1,-0.4)
    node [evento, right] {\textit{SINAPE}};
  \draw[black] (Out-2016-10-04) |- +(-0.1,0.4)
    node [evento, left] {\textit{SIEPE}};

\end{tikzpicture}

% http://tex.stackexchange.com/questions/159408/plotting-multivariable-functions-with-dependent-variables-in-domain

\xdefinecolor{lightgrey}{RGB}{220,220,220}
\xdefinecolor{goldenrod}{RGB}{255,223,66}
\xdefinecolor{newblue}{RGB}{57,106,177}
\xdefinecolor{newred}{RGB}{204,37,41}
\xdefinecolor{newgreen}{RGB}{132,186,91}
\xdefinecolor{newpurple}{RGB}{144,103,167}

\begin{tikzpicture}[scale=1.2]
  \begin{axis}[axis equal, view={0}{90}]
    \addplot3[surf, shader=interp, opacity=0.5,
      domain=-7:7, point meta min=1] {(50-x^2-y^2)};
    \addplot [domain=0:2*pi,samples=50]
      ({cos(deg(x))},{sin(deg(x))});
    \addplot [domain=0:2*pi,samples=50]
      ({2*cos(deg(x))},{2*sin(deg(x))});
    \addplot [domain=0:2*pi,samples=50]
      ({3*cos(deg(x))},{3*sin(deg(x))});
    \addplot [domain=0:2*pi,samples=50]
      ({4*cos(deg(x))},{4*sin(deg(x))});
    \addplot [domain=0:2*pi,samples=50]
      ({5*cos(deg(x))},{5*sin(deg(x))});
    \addplot [domain=0:2*pi,samples=50]
      ({6*cos(deg(x))},{6*sin(deg(x))});
    \addplot [domain=0:2*pi,samples=50]
      ({7*cos(deg(x))},{7*sin(deg(x))});
    \addplot [newpurple,double=newpurple,->]
      plot coordinates {
        (0,0)
        (-1,3)
      };
    \addplot [newblue,double=newblue,->]
      plot coordinates {
        (0,0)
        (7,-1)
      };
    \addplot [newred,double=newred,->]
      plot coordinates {
        (7,-1)
        (-1,3)
      };
    \addplot+[newred,double=newred]
      plot coordinates {
        (1,2)
      };
    \addplot [newgreen,double=newgreen]
      plot coordinates {
        (-3,-6)
        (3,6)
      };
    \addplot3 [blue,/pgfplots/quiver,
      quiver/u=-x/50,
      quiver/v=-y/50,
      quiver/scale arrows=0.1,
      -stealth,samples=10] {1};
    \fill [white] (rel axis cs:0,0)
      rectangle (rel axis cs:1,1) (axis cs:0,0) circle [radius=7];         
  \end{axis}
\end{tikzpicture}

\begin{tikzpicture}[>=latex]

\def\ellip{ellipse (2.4cm and 0.65cm)}%

% The x and y-axis.
\draw[->] (0, 0) -- (9, 0) node[right] {$y_1$};
\draw[->] (0, 0) -- (0, 9) node[above] {$y_2$};

% The z-axis.
\draw[->, dashed] (5, 0) 
  coordinate (b_1) -- +(4.5, 4.5) coordinate (b_2) node[right] {$z$};

% Loop over a 3-level factor.
\foreach \x/\y/\col in {4.3/6.7/red, 4.0/5.0/blue, 2.5/4.5/green} {

  % Draw the ellipses.
  \draw [thick, \col, xshift = \x cm, yshift = \y cm, rotate = -45]  \ellip;

  % Projection on x-axis.
  \draw[thick, color = \col, smooth, xshift = \x cm, yshift = -1.5cm]
    plot [id = x, domain = -4:4] function{exp(-(x-0)**2/2)};

  % Projection on y-axis.
  \draw[thick, color = \col, smooth, rotate = 90, xshift = \y cm, yshift = 1.5cm]
    plot [id = x, domain = -4:4] function{-exp(-(x-0)**2/2)};

  \draw [draw = none] (\x, \y) coordinate (a_1) -- +(5, -5) coordinate (a_2);

  % Define the coordinate `c` as the intersection of segments.
  \coordinate (c) at (intersection of a_1--a_2 and b_1--b_2);

  % Draw points.
  \draw[fill = \col] (c) circle (2pt);
  \draw[fill = \col] (\x, \y) circle (2pt);

%   \draw [gray] let \p{c} = (c) in (\x{c}, \y{c}) -- (0, 0);
%   \draw [gray] let \p{c} = (c) in node [anchor=west] at (\x{c}, \y{c}) {\x{c} -- \y{c}};

  % Projection on the first canonical dimension ou z1-axis.
  \draw [draw = \col, thick, smooth] let \p{c} = (c) in 
    plot [id = x,
          domain = -1.25:1.25,
          yshift = \y{c},
          xshift = \x{c},
          rotate = 45] function{1.5*exp(-(x-0)**2/0.25)};

}

\draw[draw = none] (-2, -2) rectangle (10.25, 11.25);

\end{tikzpicture}%

\tikzset{
  >=stealth',
  node distance=2mm and 3mm,
  every node/.style={draw},
}

\begin{tikzpicture}
  \coordinate (c0) at (1.5,0);
  \coordinate (x1) at ($(-0.8,0)+(c0)$);
  \coordinate (x0) at ($(-0.5,0)+(x1)$);
  \coordinate (x2) at ($(0.8,0)+(c0)$);
  \coordinate (x3) at ($(0.5,0)+(x2)$);
  \node (r1) [above=of c0] {0.95};
  \draw[->] (x0) -- (x1) |- (r1) -| (x2) -- (x3);
  \node (r2) [below=of c0] {0.85};
  \draw (x1) |- (r2) -| (x2);
\end{tikzpicture}

\tikzset{
  >=stealth',
  node distance=2mm and 3mm,
  every node/.style={draw},
}

\begin{tikzpicture}
  \node (s1) at (0,0) {0.95};
  \node (s2) [right=of s1] {0.85};
  \draw (s1) -- (s2);
  \draw (s1) -- ++(-0.8,0);
  \draw [->] (s2) -- ++(0.8,0);
\end{tikzpicture}

\def\elementA{0.1}
\def\elementB{0.2}
\def\elementC{0.3}
\def\elementD{0.4}

\tikzset{
  > = stealth,
  draw = black,
  every path/.style = {rounded corners = 0pt},
  terminal/.style = {rectangle, minimum size = 6mm, draw = black},
  point/.style = {coordinate},
  mtx/.style = {
    matrix of nodes,
    column sep = 7mm, row sep = 4mm,
    nodes = {draw, outer sep = 5pt, fill = orange,
      text width = 2em, text centered}
  },
}

\begin{tikzpicture}

  \matrix[mtx] (Y) {
    \elementA & \elementB \\
    \elementC & \elementD \\
  };
  \begin{scope}[on background layer]
    \path[->, draw] ($(Y-1-1.south west) - (0.5,0)$) -- (Y-1-1.south west) |- (Y-1-1.east) |- (Y-1-2.south west) |- (Y-1-2.east) |- ($(Y-1-2.south east) + (0.5,0)$);
    \path[draw] (Y-1-1.south west) |- (Y-2-1.east) |- (Y-1-2.south west) |- (Y-2-2.east) |- (Y-1-2.south east);
  \end{scope}

  \matrix[mtx, below=of Y] (X) {
    \elementA & \elementB \\
    \elementC & \elementD \\
  };
  \begin{scope}[on background layer]
    \path[->, draw] ($(X-1-1.south west) - (0.5,0)$) -- (X-1-1.south west) |- (X-1-1.east) |- (X-1-2.east) |- ($(X-1-2.south east) + (0.5,0)$);
    \path[draw] (X-1-1.south west) |- (X-2-1.east) |- (X-2-2.east) |- (X-1-2.south east);
  \end{scope}

  \matrix[mtx, below=of X] (Z) {
    \elementA & \\
    \elementB & \elementD \\
    \elementC & \\
  };
  \begin{scope}[on background layer]
    \path[->, draw] ($(Z-2-1.west) - (0.5,0)$) -| (Z-1-1.west) |- (Z-1-1.east) |- ($(Z-2-2.east) + (0.5,0)$);
    \path[draw] (Z-2-1.west) -- (Z-2-1.east);
    \path[draw] (Z-2-1.west) -| (Z-3-1.west) -| (Z-2-1.east);
  \end{scope}

  \matrix[mtx, below=of Z] (W) {
              & \elementB & \\
    \elementA &           & \elementD \\
              & \elementC & \\
  };
  \begin{scope}[on background layer]
    \path[->, draw] ($(W-2-1.west) - (0.5, 0)$) -| (W-2-1.east) |- (W-1-2.east) -| (W-2-3.west) -- ($(W-2-3.east) + (0.5, 0)$);
    \path[draw] (W-2-1.east) |- (W-3-2.east) -| (W-2-3.west);
  \end{scope}

\end{tikzpicture}3.west);
  \end{scope}



\end{tikzpicture} 

\def\ABC{0.95}
\def\DEF{0.7}

\tikzset{
  >=stealth,
  terminal/.style={rectangle, minimum size=6mm, draw=black},
  point/.style={coordinate},
  draw=black,
  mtx/.style={
    matrix of nodes,
    column sep=7mm, row sep=0mm,
    nodes={draw, outer sep=5pt, fill=green!60!blue,
      text width=2em, text centered}
  },
  every path/.style={rounded corners=1pt}
}

\begin{tikzpicture}
  \matrix[mtx] (Y) {
    \ABC &      & \\
         & \DEF & \\
    \ABC &      & \DEF \\
         & \DEF & \\
    \ABC &      & \\
  };
  \begin{scope}[on background layer]
    \path[draw] (Y-3-1.east) -- (Y-3-1.west) -- ++(-0.5, 0);
    \path[->, draw]
    (Y-3-1.west)
    |- (Y-1-1.east)
    |- (Y-3-1.east)
    -| (Y-2-2.west) -- (Y-2-2.east)
    |- (Y-3-3.west) -- (Y-3-3.east) -- ++(0.5,0);
    \path[draw]
    (Y-3-1.west)
    |- (Y-5-1.east)
    |- (Y-3-1.east)
    -| (Y-4-2.west) -- (Y-4-2.east)
    |- (Y-3-3.west) -- (Y-3-3.east);
  \end{scope}
\end{tikzpicture} 

\def\ABC{0.95}
\def\DEF{0.7}

\tikzset{
  >=stealth,
  draw=black,
  every path/.style={rounded corners=1pt},
  terminal/.style={rectangle, minimum size=6mm, draw=black},
  point/.style={coordinate},
  mtx/.style={
    matrix of nodes,
    column sep=7mm, row sep=4mm,
    nodes={draw, outer sep=5pt, fill=red!80!blue,
      text width=2em, text centered}
  },
}

\begin{tikzpicture}

  \matrix[mtx] (Y) {
    \ABC & \ABC & \ABC \\
    \ABC & \DEF & \DEF \\
  };
  \begin{scope}[on background layer]
    \path[->, draw]
    (Y-1-1.south west)
    |- (Y-1-1.east)
    |- (Y-1-2.south west)
    |- (Y-1-2.east)
    |- (Y-1-3.south west)
    |- (Y-1-3.east)
    |- (Y-1-3.south east) -- ++(0.5,0);
    \path[draw]
    (Y-1-3.south east)
    |- (Y-2-3.west)
    |- (Y-1-2.south east)
    |- (Y-2-2.west)
    |- (Y-1-1.south east)
    |- (Y-2-1.west)
    |- (Y-1-1.south west) -- ++(-0.5,0);
  \end{scope}

  \matrix[mtx, below=of Y] (Z) {
    \ABC & \ABC & \ABC \\
    \ABC & \DEF & \DEF \\
  };
  \begin{scope}[on background layer]
    \path[->, draw]
    (Z-1-1.south west)
    |- (Z-1-1.east)
    |- (Z-1-2.south west)
    |- (Z-1-3.east)
    |- (Z-1-3.south east) -- ++(0.5,0);
    \path[draw]
    (Z-1-3.south east)
    |- (Z-2-2.west)
    |- (Z-1-1.south east)
    |- (Z-2-1.west)
    |- (Z-1-1.south west) -- ++(-0.5,0);
  \end{scope}

  \matrix[mtx, below=of Z] (X) {
    \ABC & \ABC & \ABC \\
    \ABC & \DEF & \DEF \\
  };
  \begin{scope}[on background layer]
    \path[->, draw]
    (X-1-1.south west)
    |- (X-1-3.east)
    |- (X-1-3.south east) -- ++(0.5,0);
    \path[draw]
    (X-1-3.south east)
    |- (X-2-1.west)
    |- (X-1-1.south west) -- ++(-0.5,0);
  \end{scope}

\end{tikzpicture} 

\begin{tikzpicture}[
  very thick,
  scale = 10,
  every node/.style = {scale = 3},
  >=latex']
\def\lim{1.2}
\draw[->] (-\lim, 0) -- (\lim, 0);
\draw[->] (0, -\lim) -- (0, \lim);
\draw (0, 0) circle (1cm);
\draw (0, 0 ) -- node [above, sloped, pos = 0.5] {$v$} (0.65, 0.45) circle (0.3pt);
\draw[dashed] (0.65, 0.45) -- (0.65, 0) node[below] {$u_1$};
\draw[dashed] (0.65, 0.45) -- (0, 0.45) node[left] {$u_2$};
\draw (0.2, 0) arc (0:35:0.2) node[pos = 0.7, right] {$\theta$};
\end{tikzpicture}

\begin{tikzpicture}[domain=-0.25:9, scale=0.7, >=latex]
  % \draw[very thin,color=gray!30] (-1.1,-1.1) grid (12.1,7.1);
  \draw[->] (-0.2,0) -- (9.2,0) node[right] {$x$};
  \draw[->] (0,-0.2) -- (0,5.5) node[above] {$Y$};

  \begin{scope}[line width=1pt]
    \coordinate (a1) at (0,0);
    \coordinate (a2) at (4,3);
    \coordinate (a3) at (9,5);
    \draw (a1) ..controls (2,1) and (1,5).. (a2);
    \draw (a2) ..controls (7,1) and (7,3).. (a3);
    \node[right] at (a3) {$\eta(x)$};
  \end{scope}

  \begin{scope}[
    color=gray, fill opacity=0.3, fill=gray, smooth, domain=-1:1]

    \def\x{1.5}; \def\y{2.4};
    \filldraw[xshift=\x cm, yshift=\y cm]
      (0,-0.8) -| (0.8,0) |- (0,0.9);
    \draw (\x,\y) -- ++(0.8,0);
    \draw[dashed] (\x,0) -- ++(0,5.5);

    \def\x{3.75}; \def\y{3.15};
    \filldraw[xshift=\x cm, yshift=\y cm]
      (0,-1) -- (1,0) -- (0,1);
    \draw (\x,\y) -- ++(1,0);
    \draw[dashed] (\x,0) -- ++(0,5.5);

    \def\x{6}; \def\y{2.7};
    \filldraw[xshift=\x cm, yshift=\y cm]
      plot[id=x, rotate=-90]
      function{0.55*(1+x)**3*(1-x)**0.9};
    \draw (\x,2.17) -- ++(1,0);
    \draw[dashed] (\x,0) -- ++(0,5.3);

    \def\x{8}; \def\y{3.85};
    \filldraw[xshift=\x cm, yshift=\y cm]
      plot[id=x, rotate=-90, domain=-1.2:1.2]
      function{exp(-(x)**2/0.29)};
    \draw (\x,\y) -- ++(1,0);
    \draw[dashed] (\x,0) -- ++(0,5.5);

  \end{scope}

  \coordinate (a) at (8.25,3.5);
  \node (b) at (10,2.8) {$[Y|x]$};
  \draw (a) edge[out=0, in=180,->] (b);

\end{tikzpicture}

\tikzstyle{mybox} = [draw=gray!50, fill=gray!20, very thick, rectangle, inner sep=7pt, inner ysep=7pt]
\tikzstyle{bola} = [circle, draw, near end, fill=white, inner sep=0.5pt, font=\footnotesize]
\tikzstyle{nodedir} = [right, text width=4cm, align=flush left, color=black]
\tikzstyle{nodeesq} = [left, text width=4cm, align=flush right, color=black]

\begin{tikzpicture}[%overlay, 
                    remember picture,
                    scale=0.7, rounded corners=4pt,
                    bla/.style={color=blue, 
                    thin, shorten >=4pt, shorten <=4pt, |-latex}]

\newcommand{\tm}[1]{
  \tikz[remember picture, overlay]
  \node[anchor=south west] (#1) {};} % setas 
\newcommand{\tmc}[2]{
  \tikz[remember picture, overlay]
  \node[xshift=#2 ex, yshift=0.5 ex] (#1) {};} 

\def\hd{1};
\def\vd{1.5};

\node {
\begin{minipage}{10cm}
\begin{eqnarray*}
  [\tmc{Y}{1}Y\tmc{pipe1}{0.3}|\tm{x}x]\\
\end{eqnarray*}

\begin{eqnarray*}
  \tmc{Q}{1}Q(Y\tmc{pipe2}{0.3}|x) =
    \tmc{eta}{0.5}\eta(\tmc{x}{0.5}x \tmc{comma}{0.3}, \tmc{theta}{0.5}\theta)
\end{eqnarray*}
\end{minipage}
};

\draw[bla] (pipe1) |- +(\vd,\hd)
  node[nodedir] {Distribui\c{c}\~ao \\ \footnotesize{Normal, Beta, \\[-1ex] Poisson, Binomial, \ldots}}
  node[bola] {1};

\draw[bla] (pipe1) |- ++(-0.5,-1) -| (pipe2) node[bola] {2};
\draw[bla] (Q) |- +(-\vd,-\hd)
  node[nodeesq] {Quantidade\\ \footnotesize{M\'edia, quantil, \\[-1ex] par\^ametro, \ldots}}
  node[bola] {3};

\draw[bla] (pipe1) |- ++(0.5,-1) -| (comma) node[bola] {4};

\draw[bla] (eta) |- +(-\vd,-\hd-1)
  node[nodeesq] {Fun\c{c}\~ao\\ \footnotesize{Linear, n\~ao linear, \\[-1ex] semiparam\'eetrica, \ldots}}
  node[bola] {5};

\draw[bla] (x) |- +(\vd,-\hd-1)
  node[nodedir] {Explicativa\\ \footnotesize{M\'etrica, categ\'oica.}}
  node[bola] {6};

\draw[bla] (theta) |- +(\vd,-\hd+0.25)
  node[nodedir] {Par\^ametros \\ \footnotesize{Emp\'iricos, interpret\'aveis.}}
  node[bola] {7};

\end{tikzpicture}

\begin{tikzpicture}[>=stealth']

  \begin{scope}[scale = 2]

    \def\zval{1.65}

    \draw[|-|, thick] (-\zval, 1) -- (\zval, 1);
    \draw[fill = green] (0, 1) circle (1pt);
    \node[below = 1ex] at (0, 1) {$\overline{y}$};
    \node[below] at (-\zval, 1) {$\overline{y} - \textcolor{cyan}{z_{\alpha/2}}\cdot \sigma/\sqrt{n}$};
    \node[below] at (\zval, 1) {$\overline{y} + \textcolor{orange}{z_{\alpha/2}}\cdot \sigma/\sqrt{n}$};

    \draw [yshift = 1ex, decorate, decoration = {brace, amplitude = 5pt}] (-\zval, 1) -- (0, 1)
      node [black, midway, yshift = 1.5em] {$e = z_{\alpha/2}\cdot \sigma/\sqrt{n}$};

    \draw [yshift = 1ex, decorate, decoration = {brace, amplitude = 5pt}] (-\zval, 1.5) -- (\zval, 1.5)
      node [black, midway, yshift = 1.5em] {$2e$};

  \end{scope}

\end{tikzpicture}%

\pgfplotsset{
  myplot/.style={
    width = 12cm, height = 6cm,
    xlabel = $t$, ylabel = $f(t)$,
    samples = 75,
    domain = -5:5,
    xlabel style = {at = {(1,0)}, anchor = west},
    ylabel style = {rotate = -90, at = {(0, 1)}, anchor = south west},
    legend style = {draw = none, fill = none},
  }
}

\begin{tikzpicture}[>=stealth,
  every node/.style={rounded corners},
  declare function={
    gamma(\z)=
    (2.506628274631*sqrt(1/\z)+0.20888568*(1/\z)^(1.5)+
    0.00870357*(1/\z)^(2.5)-(174.2106599*(1/\z)^(3.5))/25920-
    (715.6423511*(1/\z)^(4.5))/1244160)*exp((-ln(1/\z)-1)*\z);
  },
  declare function={
    student(\x,\n)=
    gamma((\n+1)/2)/(sqrt(\n*pi)*
    gamma(\n/2))*((1+(\x*\x)/\n)^(-(\n+1)/2));
  }]

  \begin{axis}[myplot, smooth]

  \foreach \zValue/\al/\pos in {2.145/0.025/0.30} {
    \addplot[domain = -4:-\zValue, draw = none, fill = cyan, opacity = 0.5] {student(x, 14)} \closedcycle;
    \addplot[domain = \zValue:4, draw = none, fill = orange, opacity = 0.5] {student(x, 14)} \closedcycle;
    \edef\temp{\noexpand
      \path[<->, draw] (axis cs: -\zValue, 0) to[out = 90, in = 0]
        (axis cs: -\zValue + 0.2, \pos) node[left] {$-t_{\al} = -\zValue$};
    }
    \temp
    \edef\temp{\noexpand
      \path[<->, draw] (axis cs: \zValue, 0) to[out = 90, in = 180]
        (axis cs: \zValue - 0.2, \pos) node[right] {$t_{\al} = \zValue$};
    }
    \temp
  }

  \addplot[smooth, thick, domain = -4:4, color = gray] {student(x, 14)}
    node[pos = 0.54, pin = {right:$\nu = 15 - 1$}] {};

  \end{axis}
\end{tikzpicture}%

\pgfplotsset{
  myplot/.style={
    width = 12cm, height = 6cm,
    xlabel = $z$, ylabel = $f(z)$,
    samples = 75,
    xlabel style = {at = {(1,0)}, anchor = west},
    ylabel style = {rotate = -90, at = {(0, 1)}, anchor = south west},
    legend style = {draw = none, fill = none},
  }
}

\begin{tikzpicture}[>=stealth,
  every node/.style={rounded corners},
  declare function={
    normalpdf(\x,\mu,\sigma)=
    (2*3.1415*\sigma^2)^(-0.5)*exp(-(\x-\mu)^2/(2*\sigma^2));
  }]

  \begin{axis}[myplot, smooth]

  \foreach \zValue/\al/\pos in {1.645/0.05/0.25, 1.960/0.025/0.20, 2.576/0.005/0.15} {
    \addplot[domain = -4:-\zValue, draw = none, fill = cyan, opacity = 0.15] {normalpdf(x, 0, 1)} \closedcycle;
    \addplot[domain = \zValue:4, draw = none, fill = orange, opacity = 0.15] {normalpdf(x, 0, 1)} \closedcycle;
    \edef\temp{\noexpand
      \path[<->, draw] (axis cs: -\zValue, 0) to[out = 90, in = 0]
        (axis cs: -2, \pos) node[left] {$-z_{\al} = -\zValue$};
    }
    \temp
    \edef\temp{\noexpand
      \path[<->, draw] (axis cs: \zValue, 0) to[out = 90, in = 180]
        (axis cs: 2, \pos) node[right] {$z_{\al} = \zValue$};
    }
    \temp
  }

  \addplot[smooth, thick, domain = -4:4, color = gray] {normalpdf(x,0,1)};

  \end{axis}
\end{tikzpicture}%

\begin{tikzpicture}[>=stealth,
  every node/.style = {rounded corners},
  declare function={
    normalpdf(\x,\mu,\sigma)=
    (2*3.1415*\sigma^2)^(-0.5)*exp(-(\x-\mu)^2/(2*\sigma^2));
  }]

  \begin{axis}[
    samples = 150,
    width = 9cm, height = 7cm,
    yticklabels = {,,},
    xtick = {-4, -3, -2, -1, 0, 1, 2, 3, 4},
%     xticklabels = {$\mu -4\sigma$, $\mu -3\sigma$, $\mu - 2\sigma$, $\mu -1\sigma$, $\mu$,
%       $\mu + 1\sigma$, $\mu + 2\sigma$, $\mu + 3\sigma$, $\mu +4\sigma$},
    xticklabels = {$\bar{y} -4\frac{\sigma}{\sqrt{n}}$, $\bar{y} -3\frac{\sigma}{\sqrt{n}}$, $\bar{y} - 2\frac{\sigma}{\sqrt{n}}$, $\bar{y} -1\frac{\sigma}{\sqrt{n}}$, $\bar{y}$,
      $\bar{y} + 1\frac{\sigma}{\sqrt{n}}$, $\bar{y} + 2\frac{\sigma}{\sqrt{n}}$, $\bar{y} + 3\frac{\sigma}{\sqrt{n}}$, $\bar{y} +4\frac{\sigma}{\sqrt{n}}$},
    every x tick label/.append style = {font = \small},
    xticklabel style = {rotate = 45},
    ]

    \addplot[smooth, domain = -4:4, draw = none, fill = gray!10] {normalpdf(x, 0, 1)} \closedcycle;
    \addplot[smooth, domain=-4:-1.65, draw = none, fill = cyan] {normalpdf(x,0,1)} \closedcycle;
    \addplot[smooth, domain=1.65:4, draw = none, fill = orange] {normalpdf(x,0,1)} \closedcycle;
    \addplot[smooth, thick, domain = -4:4] {normalpdf(x, 0, 1)};
    \addplot [ycomb, samples at={0}, color = green] {normalpdf(x, 0, 1)};

    \path[<->, draw] (axis cs: -1.65,0) to[out = 90, in = 0]
      (axis description cs: 0.25, 0.35) node[left] {$\overline{y}_{LI}$};
    \path[<->, draw] (axis cs: 1.65,0) to[out = 90, in = 180]
      (axis description cs: 0.75, 0.35) node[right] {$\overline{y}_{LS}$};

    \node[fill = white] at (axis cs: 0, 0.15) {$1 - \alpha$};
    \path[o->, draw] (axis cs: 2, 0.02) to[out = 90, in = 180]
      (axis description cs: 0.8, 0.2) node[right, fill = orange] {$\alpha/2$};
    \path[o->, draw] (axis cs: -2, 0.02) to[out = 90, in = 0]
      (axis description cs: 0.2, 0.2) node[left, fill = cyan] {$\alpha/2$};

  \end{axis}

\end{tikzpicture}%

\pgfplotsset{
  myplot/.style={
    width = 12cm, height = 6cm,
%     xlabel = $t$, ylabel = $f(t)$,
    samples = 75,
    domain = -5:5,
    xlabel style = {at = {(1,0)}, anchor = west},
    ylabel style = {rotate = -90, at = {(0, 1)}, anchor = south east},
  }
}

\begin{tikzpicture}[>=stealth,
  every node/.style={rounded corners},
  declare function = {
    gamma(\z) =
    (2.506628274631*sqrt(1/\z)+0.20888568*(1/\z)^(1.5)+
    0.00870357*(1/\z)^(2.5)-(174.2106599*(1/\z)^(3.5))/25920-
    (715.6423511*(1/\z)^(4.5))/1244160)*exp((-ln(1/\z)-1)*\z);
  },
  declare function = {
    gammapdf(\x,\a,\b) = (\b^\a)*\x^(\a-1)*exp(-\b*\x)/gamma(\a);
  }]

  \begin{axis}[myplot, smooth]

  \def\chisqLeft{10.117}
  \addplot[smooth, draw = none, domain = 0:\chisqLeft, fill = cyan!40] {gammapdf(x, 19/2, 0.5)} \closedcycle;
  \path[<->, draw] (axis cs: \chisqLeft, 0) to[out = 90, in = 0]
    (axis cs: \chisqLeft, 0.05) node[left] {$\chi^2_{0.1/2} = \chisqLeft$};

  \def\chisqRight{30.143}
  \addplot[smooth, draw = none, domain = \chisqRight:50, fill = orange!40] {gammapdf(x, 19/2, 0.5)} \closedcycle;
  \path[<->, draw] (axis cs: \chisqRight, 0) to[out = 90, in = 180]
    (axis cs: \chisqRight, 0.05) node[right] {$\chi^2_{1 - 0.1/2} = \chisqRight$};

  \addplot[smooth, thick, domain = 0:50, color = gray] {gammapdf(x, 19/2, 0.5)}
    node[pos = 0.38, pin = {right:$\nu = 20 - 1$}] {};

  \end{axis}
\end{tikzpicture}%

\begin{tikzpicture}[>=stealth']

  \begin{scope}[scale = 2]

    \def\chiLeft{3}
    \def\chiRight{5.5}
    \def\sigmasquare{4}

    \draw[|-, dashed] (0, 1) node[below] {$0$} -- (\chiLeft, 1);
    \draw[|-|, thick] (\chiLeft, 1) -- (\chiRight, 1);
    \draw[fill = green] (\sigmasquare, 1) circle (1pt);
    \node[below = 1ex] at (\sigmasquare, 1) {$\sigma^2$};
    \node[below] at (\chiLeft, 1) {$\dfrac{(n - 1) s^2}{\chi^2_{\alpha/2, n - 1}}$};
    \node[below] at (\chiRight, 1) {$\dfrac{(n - 1) s^2}{\chi^2_{1 - \alpha/2, n - 1}}$};

    \draw [yshift = 1ex, decorate, decoration = {brace, amplitude = 5pt}] (0, 1) -- (\sigmasquare, 1)
      node [black, midway, yshift = 1.5em] {$\sigma^2$};

    \draw [yshift = 1ex, decorate, decoration = {brace, amplitude = 5pt}] (\chiLeft, 1.25) -- (\chiRight, 1.25)
      node [black, midway, yshift = 1.5em] {$\rho \sigma^2$};

  \end{scope}

\end{tikzpicture}%

\tikzset{
  mtx/.style={
    matrix of math nodes,
    left delimiter={[}, right delimiter={]}
  },
  hlt/.style={opacity=0.2, line width=4 mm, line cap=round},
  hltr/.style={opacity=0.2, rounded corners=2pt, inner sep=-1pt},
  txt/.style={rotate=90, right}
}

%-----------------------------------------------------------------------
% Experimento fatorial 2^3 em dois blocos, ou 2^{3-1}.

\begin{tikzpicture}

  \matrix (X) at (2,2) [mtx, nodes={anchor=east}] {
    1 & 0 & 1  & -1 & 1  & -1 & 1  & -1 & -1 \\ 
    1 & 0 & -1 & -1 & 1  & 1  & -1 & -1 & 1  \\ 
    1 & 0 & 1  & 1  & -1 & 1  & -1 & -1 & -1 \\ 
    1 & 0 & -1 & 1  & -1 & -1 & 1  & -1 & 1  \\ 
    1 & 1 & 1  & 1  & 1  & 1  & 1  & 1  & 1  \\ 
    1 & 1 & -1 & 1  & 1  & -1 & -1 & 1  & -1 \\ 
    1 & 1 & 1  & -1 & -1 & -1 & -1 & 1  & 1  \\ 
    1 & 1 & -1 & -1 & -1 & 1  & 1  & 1  & -1 \\ 
  };

  %% Efeitos.
  \node[txt] at (X-1-1.north) {$\mu$};
  \node[txt] at (X-1-2.north) {$\beta_2$};
  \node[txt] at (X-1-3.north) {$\tau_a$};
  \node[txt] at (X-1-4.north) {$\tau_b$};
  \node[txt] at (X-1-5.north) {$\tau_c$};
  \node[txt] at (X-1-6.north) {$\tau_{ab}$};
  \node[txt] at (X-1-7.north) {$\tau_{ac}$};
  \node[txt] at (X-1-8.north) {$\tau_{bc}$};
  \node[txt] at (X-1-9.north) {$\tau_{abc}$};

  %% Colunas de efeitos.
  \node[hltr, fill=black, fit=(X-1-2)(X-8-2)] {};
  \node[hltr, fill=black, fit=(X-1-8)(X-8-8)] {};

  %% Divisoes.
  \draw[dashed] (X-4-1.south west) -- (X-4-9.south east);

  %% Descricao.
  \node[above=of X] {$2^3,\, p=2$};

\end{tikzpicture}

%-----------------------------------------------------------------------
% Experimento fatorial 2^3 em dois blocos, ou 2^{3-1}.

\begin{tikzpicture}

  \matrix (X) at (2,2) [mtx, nodes={anchor=east}] {
    1 & 0 & 0 & 0 & 1  & 1  & 1  & \phantom{-}1 & 1  & 1  & 1  \\ 
    1 & 0 & 0 & 0 & -1 & -1 & -1 & 1            & 1  & 1  & -1 \\ 
    1 & 1 & 0 & 0 & -1 & 1  & 1  & -1           & -1 & 1  & -1 \\ 
    1 & 1 & 0 & 0 & 1  & -1 & -1 & -1           & -1 & 1  & 1  \\ 
    1 & 0 & 1 & 0 & 1  & -1 & 1  & -1           & 1  & -1 & -1 \\ 
    1 & 0 & 1 & 0 & -1 & 1  & -1 & -1           & 1  & -1 & 1  \\ 
    1 & 0 & 0 & 1 & -1 & -1 & 1  & 1            & -1 & -1 & 1  \\ 
    1 & 0 & 0 & 1 & 1  & 1  & -1 & 1            & -1 & -1 & -1 \\ 
  };

  %% Colunas de efeitos.
  \node[hltr, fill=black, fit=(X-1-2)(X-8-4)] {};
  \node[hltr, fill=black, fit=(X-1-8)(X-8-10)] {};

  %% Divisoes.
  \draw[dashed] (X-2-1.south west) -- (X-2-11.south east);
  \draw[dashed] (X-4-1.south west) -- (X-4-11.south east);
  \draw[dashed] (X-6-1.south west) -- (X-6-11.south east);

  %% Nomes dos efeitos.
  \node[txt] at (X-1-1.north) {$\mu$};
  \node[txt] at (X-1-2.north) {$\beta_2$};
  \node[txt] at (X-1-3.north) {$\beta_3$};
  \node[txt] at (X-1-4.north) {$\beta_4$};
  \node[txt] at (X-1-5.north) {$\tau_a$};
  \node[txt] at (X-1-6.north) {$\tau_b$};
  \node[txt] at (X-1-7.north) {$\tau_c$};
  \node[txt] at (X-1-8.north) {$\tau_{ab}$};
  \node[txt] at (X-1-9.north) {$\tau_{ac}$};
  \node[txt] at (X-1-10.north) {$\tau_{bc}$};
  \node[txt] at (X-1-11.north) {$\tau_{abc}$};

  %% Descricao.
  \node[above=of X] {$2^3,\, p=4$};

\end{tikzpicture}

%-----------------------------------------------------------------------
% Experimento fatorial 3^2 em tres blocos (confundimento parcial).

\begin{tikzpicture}

  \matrix (X) at (2,2) [mtx, nodes={anchor=east}] {
    1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 
    1 & 0 & 0 & 1 & 0 & 1 & 0 & 1 & 0 & 0 & 0 \\ 
    1 & 0 & 0 & 0 & 1 & 0 & 1 & 0 & 0 & 0 & 1 \\ 
    1 & 1 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 
    1 & 1 & 0 & 0 & 1 & 1 & 0 & 0 & 1 & 0 & 0 \\ 
    1 & 1 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ 
    1 & 0 & 1 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\ 
    1 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\ 
    1 & 0 & 1 & 1 & 0 & 0 & 1 & 0 & 0 & 1 & 0 \\ 
  };

  %% Colunas de efeitos.
  \node[hltr, fill=black, fit=(X-1-2)(X-9-3)] {};
  \node[hltr, fill=black, fit=(X-1-8)(X-9-11)] {};

  %% Divisoes.
  \draw[dashed] (X-3-1.south west) -- (X-3-11.south east);
  \draw[dashed] (X-6-1.south west) -- (X-6-11.south east);

  %% Nomes dos efeitos.
  \node[txt] at (X-1-1.north) {$\mu$};
  \node[txt] at (X-1-2.north) {$\beta_2$};
  \node[txt] at (X-1-3.north) {$\beta_3$};
  \node[txt] at (X-1-4.north) {$\tau_{2}$};
  \node[txt] at (X-1-5.north) {$\tau_{3}$};
  \node[txt] at (X-1-6.north) {$\alpha_{2}$};
  \node[txt] at (X-1-7.north) {$\alpha_{3}$};
  \node[txt] at (X-1-8.north) {$\gamma_{22}$};
  \node[txt] at (X-1-9.north) {$\gamma_{32}$};
  \node[txt] at (X-1-10.north) {$\gamma_{23}$};
  \node[txt] at (X-1-11.north) {$\gamma_{33}$};

  %% Descricao.
  \node[above=of X] {$3^2,\, p=3$};

\end{tikzpicture}

% https://tex.stackexchange.com/questions/243521/how-can-i-rotate-a-function
\pgfmathdeclarefunction{gauss}{2}{%
  \pgfmathparse{1/(#2*sqrt(2*pi))*exp(-((\x-#1)^2)/(2*#2^2))}%
}%
\begin{tikzpicture}[
  scale = 0.5,
  >=stealth',
  node distance = 4mm,
  domain = -3:3,
  samples = 60]

  \begin{scope}
    \foreach \var [count = \pos] in {0.8, 0.6, 0.4, 0.3, 0.2, 0.15} {
      \draw[draw = orange, fill = orange!50, thick, smooth, domain = -4*\var:4*\var]
        plot ({gauss(0, \var) + 2.2*\pos - 1.75}, 1 + \x - 0.14*\pos);
    }
    \draw[dashed] (-0.25, 0) node[left] {$\theta$} -- +(15, 0);
    \draw[->] (-0.1, -3) -- +(15, 0) node[below] {$n$};
    \draw[->] (0, -3.1) -- (0, 4) node[left] {$\hat{\theta}_1$};
  \end{scope}

  \begin{scope}[yshift = -8cm]
    \foreach \var [count = \pos] in {0.6, 0.5, 0.4, 0.3, 0.2, 0.15} {
      \draw[draw = blue, fill = blue!50, thick, smooth, domain = -5*\var:5*\var]
        plot ({gauss(0, 1.5*\var) + 2.2*\pos - 1.75}, \x);
    }
    \draw[dashed] (-0.25, 0) node[left] {$\theta$} -- +(15, 0);
    \draw[->] (-0.1, -3) -- +(15, 0) node[below] {$n$};
    \draw[->] (0, -3.1) -- (0, 4) node[left] {$\hat{\theta}_2$};
  \end{scope}

\end{tikzpicture}%------------------------------------------------------

\begin{tikzpicture}[%
  box/.style = {
    rectangle split,
    rectangle split parts = 3,
    rectangle split part fill = {
      gray!30,
      orange!10!white,
      green!10!white},
    draw,
    text width = 4.5cm},
  every path/.style = {->, > = latex},
  ]

  \node[box] (t0)
  {\textbf{T0: Controle positivo}
    \nodepart{second}
    Preparo: solo com estrutura preservada.
    \nodepart{third}
    Objetivo: determinar a reten{\c c}{\~a}o de {\'a}gua (RA) {\'o}tima.
  };

  \node[box, right = 5em of t0] (t1)
  {\textbf{T1: Sem estrutura preservada}
    \nodepart{second}
    Preparo: solo peneirado em malha de 2 mm.
    \nodepart{third}
    Objetivo: quantificar o efeito da aus{\^e}ncia da estrutura
    preservada na RA.
  };

  \node[box, above right = 2em and 5em of t1, anchor = 180] (t2)
  {\textbf{T2: T1 + sem a fra{\c c}{\~a}o leve da MOS}
    \nodepart{second}
    Preparo: T1 com fra{\c c}{\~o}es leve livre e oclusa da MOS
    removidas.
    \nodepart{third}
    Objetivo: quantificar o efeito da aus{\^e}ncia da fra{\c c}{\~a}o
    leve da MOS na RA.
  };

  \node[box, below right = 2em and 5em of t1, anchor = 180] (t3)
  {\textbf{T3: T1 + sem MOS}
    \nodepart{second}
    Preparo: MOS removida com emprego de solu{\c c}{\~a}o de
    solu{\c c}{\~a}o H$_2$O$_2$/H$_2$O (15:85 v/v)
    \nodepart{third}
    Objetivo: quantificar o efeito da aus{\^e}ncia da MOS na RA.
  };

  \path (t0) edge node[above] {T0 vs T1} (t1);
  \path (t1) edge[bend left = 10] node[above = 1ex] {T1 vs T2} (t2);
  \path (t1) edge[bend right = 10] node[below = 1ex] {T1 vs T3} (t3);
  \path (t2) edge node[right = 1ex] {T2 vs T3} (t3);

\end{tikzpicture}%

\begin{filecontents*}{galton.dat}
     x      y
1.9042 1.9618
1.6095 1.4159
1.6750 1.3323
1.5793 1.5033
1.7846 1.6441
1.6580 1.7589
1.8022 2.0789
1.8168 1.5724
1.5277 1.7982
2.2290 2.3234
1.8467 1.8012
1.2815 1.3210
1.5189 1.5609
1.3392 1.2647
1.4282 1.4376
2.3150 2.1893
1.0115 0.9544
2.1810 2.2179
0.9433 0.5742
2.2594 1.9946
2.2742 2.4213
1.5422 1.8452
1.4814 1.7540
2.0522 2.0247
2.0164 1.8147
1.3238 1.6789
2.3727 2.0102
1.6782 1.8770
1.7112 1.7508
1.4119 1.4921
1.3997 1.3480
1.8825 1.8111
1.4035 1.7164
1.9845 1.9546
1.2613 1.4185
2.0998 2.3210
1.6218 1.8376
1.9008 1.9458
1.1555 1.2630
1.3793 1.3378
1.6014 1.7404
1.4219 1.8182
1.5087 1.3820
1.7182 1.6391
1.8483 1.7016
1.7815 1.6210
2.0682 2.0595
1.6333 1.9390
1.8845 1.8987
2.1268 2.2169
\end{filecontents*}

\begin{tikzpicture}[>=stealth,
  font = \small,
  proj/.style = {thick, solid},
  mynode/.style = {draw, rounded corners = 2pt, fill = white},
  compare/.style = {mynode, scale = 0.75, draw = gray!30},
  ]

  \begin{axis}[
    unit vector ratio*=1 1 1, % Para ter iso nos eixos.
    width = 9cm,
%     grid = major,
%     grid style = {dashed, gray!30},
    xlabel = $y_1$,
    ylabel = $y_2$,
%     xtick = {0.5, 0.75, ..., 3},
%     ytick = {0.5, 0.75, ..., 3},
%     xticklabels = \empty,
%     yticklabels = \empty,
    ticks = none,
    xmin = 0.15, xmax = 3,
    ymin = 0.15, ymax = 3,
    domain = 1.1:2.5,
    ]

    \def\mediaYa{1.705}
    \def\mediaYb{1.726}

    \addplot[only marks, mark=*, fill = gray, very thin, mark size = 1.5pt] table {galton.dat};

    \draw[green] (\mediaYa, 2.5) -- (\mediaYa, 0.7) node[mynode, below] {$\bar{y_1}$};
    \draw[magenta] (2.4, \mediaYb) -- (0.7, \mediaYb) node[mynode, left] {$\bar{y_2}$};

  \node[compare, anchor = south west] at (rel axis cs: 0.05, 0.05)
    {$\textcolor{blue}{y_{1} < \bar{y}_1}\, \& \, \textcolor{blue}{y_{2} < \bar{y}_2}$};
  \node[compare, anchor = north west] at (rel axis cs: 0.05, 0.95)
    {$\textcolor{blue}{y_{1} < \bar{y}_1}\, \& \, \textcolor{orange}{y_{2} > \bar{y}_2}$};
  \node[compare, anchor = north east] at (rel axis cs: 0.95, 0.95)
    {$\textcolor{orange}{y_{1} > \bar{y}_1}\, \& \, \textcolor{orange}{y_{2} > \bar{y}_2}$};
  \node[compare, anchor = south east] at (rel axis cs: 0.95, 0.05)
    {$\textcolor{orange}{y_{1} > \bar{y}_1}\, \& \, \textcolor{blue}{y_{2} < \bar{y}_2}$};

\draw[proj, color = orange] (1.816800, 1.572400) -- (1.705134, 1.572400);
\draw[proj, color = blue] (1.011500, 0.954400) -- (1.705134, 0.954400);
\draw[proj, color = orange] (2.372700, 2.010200) -- (1.705134, 2.010200);
\draw[proj, color = blue] (1.421900, 1.818200) -- (1.705134, 1.818200);
\draw[proj, color = blue] (1.816800, 1.572400) -- (1.816800, 1.726882);
\draw[proj, color = blue] (1.011500, 0.954400) -- (1.011500, 1.726882);
\draw[proj, color = orange] (2.372700, 2.010200) -- (2.372700, 1.726882);
\draw[proj, color = orange] (1.421900, 1.818200) -- (1.421900, 1.726882);

  \end{axis}

\end{tikzpicture}

% txt <- "     x      y
% 1.9042 1.9618
% ...
% 2.1268 2.2169"
%
% tb <- read.table(textConnection(txt), header = TRUE)
% closeAllConnections()
% 
% str(tb)
% colMeans(tb)
% 
% plot(y ~ x, data = tb, asp = 1)
% abline(v = mean(tb$x), h = mean(tb$y))
% # loc <- with(tb, identify(x, y))
% # dput(loc)
% loc <- c(8L, 17L, 27L, 42L)
% 
% fmt <- "\\draw[proj, color = %s] (%f, %f) -- (%f, %f);"
% draw <- with(tb[loc, ], {
%     c(sprintf(fmt, ifelse(x < mean(x), "blue", "orange"), x, y, mean(tb$x), y), 
%       sprintf(fmt, ifelse(y < mean(y), "blue", "orange"), x, y, x, mean(tb$y)))
% })
% cat(draw, sep = "\n")

\def\f1{0.8}
\def\xs{0.5}
\def\ys{4}

\begin{tikzpicture}[domain=-3:5, xscale=\xs, yscale=\ys, >=latex]
  \def\tr{0.1}
  \def\ts{0.6}
  \def\al{1.3}
  \def\n{1.6}
  \def\m{0.9}
  \def\I{0.3506}
  \def\ti{0.4071}
  \def\S{-0.1340}
  \def\Sangle{-42}

  \draw[very thin,color=gray!30] (-3-0.2/\xs,0-0.2/\ys)
    grid[xstep=0.5, ystep=0.1] (5+0.2/\xs,0.7+0.2/\ys);
  % \node at (6,1) {van Genuchten reparametrizado para $S$ e $I$};
  \draw[->, line width=1pt] (-3,0) -- (5.25,0)
    node[below] {$\log(\psi)$};
  \draw[->, line width=1pt] (-3,0) -- (-3,0.75)
    node[left] {$U(\psi)$};
  \foreach \SS in {-0.125,-0.15,-0.175,-0.2}
  \draw[color=darkgreen, thick, smooth] plot[id=x, domain=-3:5]
    function{\tr-\SS*(1+1/\m)**(\m+1)/(\n*(1+exp(\n*(x-\I))/\m)**\m)};
  \draw[->,xshift=-3.25cm] (0,0.4) -- (0,0.65) node[midway,left] {$S$};

  \begin{scope}[xshift=11.5cm]
    \draw[very thin,color=gray!30] (-3-0.2/\xs,0-0.2/\ys)
      grid[xstep=0.5, ystep=0.1] (5+0.2/\xs,0.7+0.2/\ys);
    \draw[->, line width=1pt] (-3,0) -- (5.25,0)
      node[below] {$\log(\psi)$};
    \draw[->, line width=1pt] (-3,0) -- (-3,0.75)
      node[left] {$U(\psi)$};
    \foreach \ttr in {0.05,0.1,0.15,0.2}
    \draw[color=darkgreen, thick, smooth] plot[id=x, domain=-3:5]
      function{\ttr-\S*(1+1/\m)**(\m+1)/(\n*(1+exp(\n*(x-\I))/\m)**\m)};
    \draw[->,xshift=5.25cm] (0,0.025) -- (0,0.25)
      node[midway,right] {$U_r$};
  \end{scope}

  \begin{scope}[xshift=0cm, yshift=-1cm]
    \draw[very thin,color=gray!30] (-3-0.2/\xs,0-0.2/\ys)
      grid[xstep=0.5, ystep=0.1] (5+0.2/\xs,0.7+0.2/\ys);
    \draw[->, line width=1pt] (-3,0) -- (5.25,0)
      node[below] {$\log(\psi)$};
    \draw[->, line width=1pt] (-3,0) -- (-3,0.75)
      node[left] {$U(\psi)$};
    \foreach \II in {-0.5,0,0.5,1}
    \draw[color=darkgreen, thick, smooth] plot[id=x, domain=-3:5]
      function{\tr-(\S-0.05)*(1+1/\m)**(\m+1)/
        (\n*(1+exp(\n*(x-\II))/\m)**\m)};
    \draw[<-] (1.75,0.35) -- ++(-3,0)
      node[left,circle,fill=white] {$I$};
  \end{scope}

  \begin{scope}[xshift=11.5cm, yshift=-1cm]
    \draw[very thin,color=gray!30] (-3-0.2/\xs,0-0.2/\ys)
      grid[xstep=0.5, ystep=0.1] (5+0.2/\xs,0.7+0.2/\ys);
    \draw[->, line width=1pt] (-3,0) -- (5.25,0)
      node[below] {$\log(\psi)$};
    \draw[->, line width=1pt] (-3,0) -- (-3,0.75)
      node[left] {$U(\psi)$};
    \foreach \nn in {1.5,2,2.5,3}
    \draw[color=darkgreen, thick, smooth] plot[id=x, domain=-3:5]
      function{\tr-(\S-0.05)*(1+1/\m)**(\m+1)/
        (\nn*(1+exp(\nn*(x-\I))/\m)**\m)};
    \path[->] (1,0.4) edge[bend left=3]
      node[at end, left,circle,fill=white] {$n$} (-1,0.2);
  \end{scope}

  \begin{scope}[xshift=0cm, yshift=-2cm]
    \draw[very thin,color=gray!30] (-3-0.2/\xs,0-0.2/\ys)
      grid[xstep=0.5, ystep=0.1] (5+0.2/\xs,0.7+0.2/\ys);
    \draw[->, line width=1pt] (-3,0) -- (5.25,0)
      node[below] {$\log(\psi)$};
    \draw[->, line width=1pt] (-3,0) -- (-3,0.75)
      node[left] {$U(\psi)$};
    \foreach \mm in {0.75,1.25,1.75,2.25}
    \draw[color=darkgreen, thick, smooth] plot[id=x, domain=-3:5]
      function{\tr-(\S-0.05)*(1+1/\mm)**(\mm+1)/
        (\n*(1+exp(\n*(x-\I))/\mm)**\mm)};
    \path[->] (1,0.4) edge[bend left=3]
      node[at end, left,circle,fill=white] {$m$} (-1,0.2);
  \end{scope}

  \begin{scope}[xshift=11.5cm, yshift=-2cm]
    \draw[very thin,color=gray!30] (-3-0.2/\xs,0-0.2/\ys)
      grid[xstep=0.5, ystep=0.1] (5+0.2/\xs,0.7+0.2/\ys);
    \draw[->, line width=1pt] (-3,0) -- (5.25,0)
      node[below] {$\log(\psi)$};
    \draw[->, line width=1pt] (-3,0) -- (-3,0.75)
      node[left] {$U(\psi)$};
    \foreach \nn in {1.5,2.25,3,3.75}
    \draw[color=darkgreen, thick, smooth] plot[id=x, domain=-3:5]
      function{\tr-\S*(1+1/(1-1/\nn))**(2-1/\nn)/
        (\n*(1+exp(\n*(x-\I))/(1-1/\nn))**(1-1/\nn))};
    \path[->] (1.25,0.5) edge[bend left=3]
      node[at end, left,circle,fill=white] {$n$} ++(-2,-0.2);
    \node[anchor=base,rectangle,fill=white] (i) at (2.5,0.6)
      {$m=1-1/n$};
  \end{scope}

\end{tikzpicture}

\def\f1{0.8}
\def\xs{0.5}
\def\ys{4}

\begin{tikzpicture}[domain=-3:5, xscale=\xs, yscale=\ys, >=latex]
  \def\tr{0.1}
  \def\ts{0.6}
  \def\al{1.3}
  \def\n{1.6}
  \def\m{0.9}
  \def\I{0.3506}
  \def\ti{0.4071}
  \def\S{-0.1340}
  \def\Sangle{-42}

  \draw[very thin,color=gray!30] (-3-0.2/\xs,0-0.2/\ys)
    grid[xstep=0.5, ystep=0.1] (5+0.2/\xs,0.7+0.2/\ys);
  % \node at (6,1) {van Genuchten original};
  \draw[->, line width=1pt] (-3,0) -- (5.25,0)
    node[below] {$\log(\psi)$};
  \draw[->, line width=1pt] (-3,0) -- (-3,0.75)
    node[left] {$U(\psi)$};
  \foreach \tts in {0.45,0.5,0.55,0.6}
  \draw[color=darkgreen, thick, smooth] plot[id=x, domain=-3:5]
    function{\tr+(\tts-\tr)/(1+(\al*exp(x))**\n)**(\m)};
  \draw[->,xshift=-3.25cm] (0,0.4) -- (0,0.65)
    node[midway,left] {$U_s$};

  \begin{scope}[xshift=11.5cm]
    \draw[very thin,color=gray!30] (-3-0.2/\xs,0-0.2/\ys)
      grid[xstep=0.5, ystep=0.1] (5+0.2/\xs,0.7+0.2/\ys);
    \draw[->, line width=1pt] (-3,0) -- (5.25,0)
      node[below] {$\log(\psi)$};
    \draw[->, line width=1pt] (-3,0) -- (-3,0.75)
      node[left] {$U(\psi)$};
    \foreach \ttr in {0.05,0.1,0.15,0.2}
    \draw[color=darkgreen, thick, smooth] plot[id=x, domain=-3:5]
      function{\ttr+(\ts-\ttr)/(1+(\al*exp(x))**\n)**(\m)};
    \draw[->,xshift=5.25cm] (0,0.025) -- (0,0.25)
      node[midway,right] {$U_r$};
  \end{scope}

  \begin{scope}[xshift=0cm, yshift=-1cm]
    \draw[very thin,color=gray!30] (-3-0.2/\xs,0-0.2/\ys)
      grid[xstep=0.5, ystep=0.1] (5+0.2/\xs,0.7+0.2/\ys);
    \draw[->, line width=1pt] (-3,0) -- (5.25,0)
      node[below] {$\log(\psi)$};
    \draw[->, line width=1pt] (-3,0) -- (-3,0.75)
      node[left] {$U(\psi)$};
    \foreach \all in {1,2,3,4}
    \draw[color=darkgreen, thick, smooth] plot[id=x, domain=-3:5]
      function{\tr+(\ts-\tr)/(1+(\all*exp(x))**\n)**(\m)};
    \draw[->] (1,0.35) node[right,circle,fill=white] {$A$} -- ++(-3,0);
  \end{scope}

  \begin{scope}[xshift=11.5cm, yshift=-1cm]
    \draw[very thin,color=gray!30] (-3-0.2/\xs,0-0.2/\ys)
      grid[xstep=0.5, ystep=0.1] (5+0.2/\xs,0.7+0.2/\ys);
    \draw[->, line width=1pt] (-3,0) -- (5.25,0)
      node[below] {$\log(\psi)$};
    \draw[->, line width=1pt] (-3,0) -- (-3,0.75)
      node[left] {$U(\psi)$};
    \foreach \nn in {1,2,3,4}
    \draw[color=darkgreen, thick, smooth] plot[id=x, domain=-3:5]
    function{\tr+(\ts-\tr)/(1+(\al*exp(x))**\nn)**(\m)};
    \draw[->] (-0.45,0.37)++(1,0) arc (0:-300:0.8 and 0.1)
      node[below right,circle,fill=white] {$n$};
  \end{scope}

  \begin{scope}[xshift=0cm, yshift=-2cm]
    \draw[very thin,color=gray!30] (-3-0.2/\xs,0-0.2/\ys)
      grid[xstep=0.5, ystep=0.1] (5+0.2/\xs,0.7+0.2/\ys);
    \draw[->, line width=1pt] (-3,0) -- (5.25,0)
      node[below] {$\log(\psi)$};
    \draw[->, line width=1pt] (-3,0) -- (-3,0.75)
      node[left] {$U(\psi)$};
    \foreach \mm in {0.5,1,1.5,2}
    \draw[color=darkgreen, thick, smooth] plot[id=x, domain=-3:5]
      function{\tr+(\ts-\tr)/(1+(\al*exp(x))**\n)**(\mm)};
    \path[->] (1,0.4) edge[bend left=3]
      node[at end, left,circle,fill=white] {$m$} (-1,0.2);
  \end{scope}

  \begin{scope}[xshift=11.5cm, yshift=-2cm]
    \draw[very thin,color=gray!30] (-3-0.2/\xs,0-0.2/\ys)
      grid[xstep=0.5, ystep=0.1] (5+0.2/\xs,0.7+0.2/\ys);
    \draw[->, line width=1pt] (-3,0) -- (5.25,0)
      node[below] {$\log(\psi)$};
    \draw[->, line width=1pt] (-3,0) -- (-3,0.75)
      node[left] {$U(\psi)$};
    \foreach \nn in {1.5,2,2.5,3}
    \draw[color=darkgreen, thick, smooth] plot[id=x, domain=-3:5]
      function{\tr+(\ts-\tr)/(1+(\al*exp(x))**\nn)**(1-1/\nn)};
    \path[->] (1.5,0.4) edge[bend left=3]
      node[at end, left,circle,fill=white] {$n$} (-1,0.2);
    \node[anchor=base,rectangle,fill=white] (i) at (2.5,0.6)
      {$m=1-1/n$};
  \end{scope}

\end{tikzpicture}

\tikzset{state/.style={
    rectangle, rounded corners, draw=black, thick, minimum height=2em,
    minimum width=7cm, inner sep=10pt, text centered,
  },
}

\begin{tikzpicture}[->, >=latex, line width=0.75pt]
  \node[state] (cra) {
    $U(x) = U_r+\displaystyle\frac{U_s-U_r}{(1+\exp\{a+x\})^n)^m}$\\
  };
  \node[above of=cra] {Curva de reten\c{c}\~{a}o de \'{a}gua no solo};
  \node[state, right of=cra, node distance=8cm]
  (dist) {
    $f(r) = \displaystyle\frac{nm\, (2\gamma\,\exp\{a\}/r)^n}{
      r(1+(2\gamma\,\exp\{a\}/r)^n)^{m+1}}$\\
  };
  \node[above of=dist] {Distribui\c{c}\~{a}o do tamanho de poros};
  \path (cra) edge[<->, bend right=30] node[below] {} (dist);
\end{tikzpicture}

% http://www.texample.net/tikz/examples/free-body-diagrams/

\def\tr{0.1}
\def\ts{0.6}
\def\al{1.3}
\def\n{1.6}
\def\I{0.3506} % -log(al)+log(m)/n = -log(al)+log(1-1/n)/n
\def\ti{0.4071}
\def\S{-0.1340}
\def\Sangle{-42}
\def\f1{0.8}

\begin{tikzpicture}[domain=-3:5, xscale=1.1, yscale=6, >=latex]
  \draw[very thin,color=gray!30] (-3,0)
    grid[xstep=0.5, ystep=0.1] (5,0.7);
  \draw[->, line width=1pt] (-3,0) -- (5.25,0)
    node[below] {$\log(\psi)$};
  \draw[->, line width=1pt] (-3,0) -- (-3,0.75)
    node[left] {$U(\psi)$};
  \draw[color=green!30!black, thick, smooth]
    plot[id=x, domain=-3:5]
    function{\tr+(\ts-\tr)/(1+(\al*exp(x))**\n)**(1-1/\n)};
  \node[left] (tr) at (-3,\tr) {$U_r$};
  \node[left] (ts) at (-3,\ts) {$U_s$};
  \draw[dashed] (\I,0) node[below] {$I$} -- (\I,\ti) -- (-3,\ti)
    node[left] {$U_i$};
  \draw[color=green!30!black, dashed]
    plot[id=x, domain=-1.5:3]
    function{\ti+\S*(x-\I)};
  \draw [decorate,decoration={brace,amplitude=4pt}]
    (-3.5,\tr) -- (-3.5,\ts) node [black,midway,left] {$\Delta$};
  \draw[|<->|] (\I,\ti)++(1,0) arc (0:\Sangle:0.8 and 0.15);
  \path (\I,\ti)++(0.5*1.5\Sangle/8:1)
    node[right=-1pt] {$\tan^{-1}(S)$};
  \node[anchor=base] (vg) at (1,0.8)
    {$U(\psi) = U_r+\displaystyle\frac{U_s-U_r}{(1+(\alpha\psi)^n)^m}$};

  \begin{scope}[yshift=-0.3cm,domain=-3:5, >=latex, yscale=3]
    \draw[very thin,color=gray!30] (-3,-0.15)
      grid[xstep=0.5, ystep=0.03] (5,0);
    \draw[->, line width=1pt] (-3,-0.15) -- (5.25,-0.15)
      node[below] {$x=\log(\psi)$};
    \draw[->, line width=1pt] (-3,-0.15) -- (-3,0.03)
      node[left] {$U'(x)$};
    \draw[color=green!30!black, thick, smooth]
      plot[id=x, domain=-3:5]
      function{-(\ts-\tr)*\n*(1-1/\n)*\al**\n*exp(\n*x)*
        (1+(\al*exp(x))**\n)**(-1+1/\n-1)} node[right] {};
    \node[left] (z) at (-3,0) {$0$};
    \draw[dashed] (\I,0) -- (\I,\S) -- (-3,\S) node[left] {$S$};
    \node[anchor=base] (dvg) at (1,0.02)
      {$U'(x) = -(U_s-U_r) \,n m\alpha^n
        \exp\{nx\}(1+(\alpha\exp\{x\})^n)^{-m-1}$};
  \end{scope}

  \begin{scope}[yshift=-1.6cm,domain=-3:5, >=latex, yscale=1.75]
    \draw[very thin,color=gray!30] (-3,0)
      grid[xstep=0.5, ystep=0.05] (5,0.35);
    \draw[->, line width=1pt] (-3,0) -- (5.25,0)
      node[below] {$x=\log(\psi)$};
    \draw[->, line width=1pt] (-3,-0.05) -- (5.25,-0.05)
      node[below] {$r=2\sigma\cos(\delta)/(\rho g \psi)$};
    \draw[->, line width=1pt] (-3,0) -- (-3,0.38) node[left] {$f(x)$};
    \draw[color=green!30!black, thick, smooth]
      plot[id=x, domain=-3:5]
      function{\n*(1-1/\n)*\al**\n*exp(\n*x)*
        (1+(\al*exp(x))**\n)**(-1+1/\n-1)};
    \node[left] (z) at (-3,0) {$0$};
    \node[anchor=base] (inte) at (1,0.32)
      {$\displaystyle\int_{-\infty}^{\infty} nm\alpha^n
        \exp\{nx\}(1+(\alpha\exp\{x\})^n)^{-m-1}\,\, dx=1$};
    \draw[dashed] (\I,0) -- (\I,-2*\S);
  \end{scope}

  \begin{scope}[yshift=-1.8cm, xshift=-0.5cm, xscale=8, yscale=1.5]
    \foreach \r/\x in {10/-2, 8/0, 6/2, 4/4, 2/5.5} {
      \draw (\x/8,0) circle (\r/150);
      \draw (\x/8,0) -- ++(\r/150,0);
    }
    \node[below right] (r) at (-2/8,0) {$r$};
    \node[anchor=base] (d) at (0.2,-0.12) {tamanho de poros ($r$)};
  \end{scope}
\end{tikzpicture}

\def\tr{0.1}
\def\ts{0.6}
\def\al{1.3}
\def\n{1.6}
\def\I{0.3506}
\def\ti{0.4071}
\def\S{-0.1340}
\def\Sangle{-42}
\def\f1{0.8}

\begin{tikzpicture}[domain=-3:5, xscale=1, yscale=5, >=latex]
  \draw[very thin,color=gray!30] (-3,0)
    grid[xstep=0.5, ystep=0.1] (5,0.7);
  \draw[->, line width=1pt] (-3,0) -- (5.25,0)
    node[below] {$\log(\psi)$};
  \draw[->, line width=1pt] (-3,0) -- (-3,0.75)
    node[left] {$U(\psi)$};
  \draw[color=green!30!black, thick, smooth]
    plot[id=x, domain=-3:5]
    function{\tr+(\ts-\tr)/(1+(\al*exp(x))**\n)**(1-1/\n)};
  \node[left] (tr) at (-3,\tr) {$U_r$};
  \node[left] (ts) at (-3,\ts) {$U_s$};
  \draw[dashed] (\I,0) node[below] {$I$} -- (\I,\ti) -- (-3,\ti)
    node[left] {$U_i$};
  \draw[color=green!30!black, dashed]
    plot[id=x, domain=-1.5:3]
    function{\ti+\S*(x-\I)};
  \draw[|<->|] (\I,\ti)++(1,0) arc (0:\Sangle:0.8 and 0.15);
  \path (\I,\ti)++(0.5*1.5\Sangle/8:1)
    node[right=-1pt] {$\tan^{-1}(S)$};
  \node[anchor=base] (vg) at (1,0.8)
    {$U(\psi) = U_r+\displaystyle\frac{U_s-U_r}{(1+(\alpha\psi)^n)^m}$};
\end{tikzpicture}

\def\xs{1}
\def\ys{6}

\begin{tikzpicture}[domain=-3:5, xscale=\xs, yscale=\ys, >=latex]
  % definicoes dos valores dos parametros e outras quantidades
  \def\tr{0.1}
  \def\ts{0.6}
  \def\al{1.3}
  \def\n{1.6}
  \def\I{0.3506}
  \def\ti{0.4071}
  \def\S{-0.1340}
  \def\Sangle{-42}
  \def\f1{0.8}

  % CRA
  % grid e eixos
  \draw[very thin,color=gray!30] (-3-0.2/\xs,0-0.2/\ys)
    grid[xstep=0.5, ystep=0.1] (5+0.2/\xs,0.7+0.2/\ys);
  \draw[->, line width=1pt] (-3,0) -- (5.25,0)
    node[below] {$\log(\psi)$};
  \draw[->, line width=1pt] (-3,0) -- (-3,0.75)
    node[left] {$U(\psi)$};
  % funcao
  \draw[color=darkgreen, thick, smooth] plot[id=x, domain=-3:5]
    function{\tr+(\ts-\tr)/(1+(\al*exp(x))**\n)**(1-1/\n)};
  % textos e chave
  \draw[dashed] (\I,0) node[below] {$I$} -- (\I,\ti) -- (-3,\ti)
    node[left] {$u_i$};
  \draw [decorate, decoration={brace, amplitude=4pt}]
    (-3.5,\tr) -- (-3.5,\ts) node [black,midway,left=3pt] {$\Delta$};
  % texto
  \path[->, draw]
    (\I,\ti) to[out=0, in=180] ++(0.75,0.1)
    node[anchor=west, text ragged, text width=1.6cm, fill=white]
    {ponto de inflex\~ao};
  \node[above] at (1,0.7)
    {Curva de reten\c{c}\~ao de {\'a}gua do solo (CRA)};

  % parametro S
  \draw[color=darkgreen, dashed] plot[id=x, domain=-1.5:2.6]
    function{\ti+\S*(x-\I)} node[below, fill=white] {reta tangente};
  \draw[|<->|] (\I,\ti)++(1,0) arc (0:\Sangle:0.8 and 0.15);
  \path (\I,\ti)++(0.5*1.5\Sangle/8:1)
    node[right=2pt, fill=white, inner sep=1pt] {$\tan^{-1}(S)$};

  % DRCA
  \def\ys{3}
  \begin{scope}[yshift=-0.3cm, domain=-3:5, >=latex, yscale=\ys]
    \draw[very thin,color=gray!30] (-3-0.2/\xs,-0.15-0.15*0.2/\ys)
      grid[xstep=0.5, ystep=0.03] (5+0.2/\xs,0.03+0.15*0.2/\ys);
    \draw[->, line width=1pt] (-3,-0.15) -- (5.25,-0.15)
      node[below] {$\log(\psi)$};
    \draw[->, line width=1pt] (-3,-0.15) -- (-3,0.05)
      node[left] {$U'(\psi)$};
    \draw[color=darkgreen, thick, smooth] plot[id=x, domain=-3:5]
      function{-(\ts-\tr)*\n*(1-1/\n)*\al**\n*exp(\n*x)*
        (1+(\al*exp(x))**\n)**(-1+1/\n-1)};
    \node[left] at (-3,0) {$0$};
    \draw[dashed] (\I,0.03) -- (\I,\S) -- (-3,\S) node[left] {$U'(I)$};
    \path[->, draw]
      (\I,\S) to[out=-2, in=180] ++(1.75,0.02)
      node[anchor=west, fill=white] {$S$};
    \node[above] at (1,0.03) {Derivada da CRA (DCRA)};
  \end{scope}

  % funcao densidade 
  \def\ys{1.75}
  \begin{scope}[yshift=-1.5cm,domain=-3:5, >=latex, yscale=\ys]
    \draw[very thin,color=gray!30] (-3-0.2/\xs,0-0.025/\ys)
      grid[xstep=0.5, ystep=0.05] (5+0.2/\xs,0.3+0.025/\ys);
    \draw[->, line width=1pt] (-3,0) -- (5.25,0)
      node[below] {$x=\log(\psi)$};
    \draw[->, line width=1pt] (-3,0) -- (-3,0.33) node[left] {$f(x)$};
    \draw[color=darkgreen, thick, smooth] plot[id=x, domain=-3:5]
      function{\n*(1-1/\n)*\al**\n*exp(\n*x)*
        (1+(\al*exp(x))**\n)**(-1+1/\n-1)};
    \node[left] at (-3,0) {$0$};
    \node[above] at (1,0.3) {Fun\c{c}\~ao densidade de probabilidade};
    \draw[dashed] (\I,0) -- (\I,-2*\S);
    \path[->, draw]
      (\I+1,0.21) to[out=0, in=180] ++(0.75,0.05)
      node[anchor=west, text ragged, text width=2.5cm, fill=white]
      {$f(x) = -\frac{U'(x)}{\Delta}$};
    \path[->, draw]
      (\I,-\S*2) to[out=175, in=0] ++(-1.75,0)
      node[anchor=east, fill=white] {$-S/\Delta$};
    \node[above] at (\I+1.5, 0)
      {$\displaystyle\int_{-\infty}^{\infty} f(x)\,\, dx=1$};
  \end{scope}

  % raios
  \begin{scope}[yshift=-1.65cm, xscale=8, yscale=1.33]
    \node[below right] at (\I-2.75cm/8,0) {$r$};
    \node[below, text centered, text width=12em] at (1/8,-0.07)
    {tamanho de poros ($r$)\\ $r = 2\gamma/\psi$};
    \foreach \r/\x in {
      10/\I-2.75cm, 7.5/\I-1.1cm, 5/\I, 3/\I+1.5cm,
      2/\I+2.75cm, 1.5/\I+4cm, 1/\I+5cm}{
      \draw (\x/8,0) circle (\r/150);
      \draw (\x/8,0) -- ++(\r/150,0);
    }
  \end{scope}
\end{tikzpicture}

\begin{tikzpicture}

\draw[draw, step = 0.5, dotted] (0, 0) grid (10, 6);
\draw [thick] (0, 0) rectangle (10, 6) node [below left] {C};
\draw [thick] (7, 0) .. controls +(2, 5) and +(0, -5) .. (6, 6) node [below left] {B};
\draw [thick] (2, 0) .. controls +(4, 4) and +(0, -3) .. (3, 6) node [below left] {A};
\node [draw, rectangle, minimum width = 1cm, minimum height = 1cm] (parc) at (11, 5) {};
\node [below] at (parc.south) {Parcela};
\draw [thick, ->, >=latex'] (1, -0.75) -- node [above] {Gradiente} +(8, 0);

\draw[draw = none] (-0.5, -1) rectangle (12, 6.5);

\end{tikzpicture}

\begin{tikzpicture}[%
  scale = 2,
  ->,
  thick,
  z = {(0.45, 0.25)},
  node distance = 2em,
  vertex/.style = {circle, minimum size = 5pt, inner sep = 0pt,
    draw = black, fill = black},
  axial/.style = {rectangle, minimum size = 20pt,
    inner sep = 0pt, fill = gray!30},
  edge/.style = {draw, thick, -, black},
  rotu/.style = {midway},
  sinal/.style = {inner sep = 1pt, thin, opacity = 0.4,
    fill = blue, circle, text opacity = 1},
  pointminus/.style = {draw = blue, fill = blue},
  pointplus/.style = {draw = orange, fill = orange},
  faceminus/.style = {blue, opacity = 0.4},
  faceplus/.style = {orange, opacity = 0.4}
  ]

  \def\dist{0.1}
  \def\cube{
    % Vertices.
    \coordinate (v0) at (0, 0, 0);
    \coordinate (v1) at (0, 1, 0);
    \coordinate (v2) at (1, 0, 0);
    \coordinate (v3) at (1, 1, 0);
    \coordinate (v4) at (0, 0, 1);
    \coordinate (v5) at (0, 1, 1);
    \coordinate (v6) at (1, 0, 1);
    \coordinate (v7) at (1, 1, 1);

    % Edges.
    \draw[edge] (v0) -- (v1) -- (v3) -- (v2) -- (v0);
    \draw[edge] (v0) -- (v4) -- (v5) -- (v1);
    \draw[edge] (v2) -- (v6) -- (v7) -- (v3);
    \draw[edge] (v4) -- (v6);
    \draw[edge] (v5) -- (v7);
  } % \cube

  % A effect.
  \begin{scope}[]
    \cube{};
    \foreach \i in {0,...,7}{ \draw[fill= black] (v\i) circle (1.5pt); }
    \node at (0.25, 1.25, 1) {$2^3 = 8$};

    % Axis text.
    \path (v0) -- node[midway, below=1.5em] {$A$} (v2);
    \path (v0) -- node[midway, left=1.5em] {$B$} (v1);
    \path (v2) -- node[midway, right=3em] {$C$} (v6);

    % Axis text.
    \node[below of=v0, sinal, fill = blue] {$-$};
    \node[below of=v2, sinal, fill = orange] {$+$};
    \node[left of=v0, sinal, fill = blue] {$-$};
    \node[left of=v1, sinal, fill = orange] {$+$};
    \node[right = 3em of v2, sinal, fill = blue] {$-$};
    \node[right = 3em of v6, sinal, fill = orange] {$+$};
  \end{scope}

  % A effect.
  \begin{scope}[xshift = -2.5cm, yshift = -2.5cm]
    \cube{};
    \fill[faceminus]
    (v0.center) -- (v1.center) -- (v5.center) -- (v4.center) -- cycle;
    \foreach \i in {0, 1, 5, 4}{
      \draw[pointminus] (v\i) circle (1.5pt); }
    \fill[faceplus]
    (v2.center) -- (v3.center) -- (v7.center) -- (v6.center) -- cycle;
    \foreach \i in {2, 3, 7, 6}{
      \draw[pointplus] (v\i) circle (1.5pt); }
    \node at (0.25, 1.25, 1) {A};
  \end{scope}

  % B effect.
  \begin{scope}[xshift = 0.0cm, yshift = -2.5cm]
    \cube{};
    \fill[faceminus]
    (v0.center) -- (v4.center) -- (v6.center) -- (v2.center) -- cycle;
    \foreach \i in {0, 4, 6, 2}{
      \draw[pointminus] (v\i) circle (1.5pt); }
    \fill[faceplus]
    (v1.center) -- (v5.center) -- (v7.center) -- (v3.center) -- cycle;
    \foreach \i in {1, 5, 7, 3}{
      \draw[pointplus] (v\i) circle (1.5pt); }
    \node at (0.25, 1.25, 1) {B};
  \end{scope}

  % C effect.
  \begin{scope}[xshift = 2.5cm, yshift = -2.5cm]
    \cube{};
    \fill[faceplus]
    (v4.center) -- (v5.center) -- (v7.center) -- (v6.center) -- cycle;
    \foreach \i in {4, 5, 7, 6}{
      \draw[pointplus] (v\i) circle (1.5pt); }
    \fill[faceminus]
    (v0.center) -- (v1.center) -- (v3.center) -- (v2.center) -- cycle;
    \foreach \i in {0, 1, 3, 2}{
      \draw[pointminus] (v\i) circle (1.5pt); }
    \node at (0.25, 1.25, 1) {C};
  \end{scope}

  % A:B effect.
  \begin{scope}[xshift = -2.5cm, yshift = -5cm]
    \cube{};
    \fill[faceplus]
    (v0.center) -- (v5.center) -- (v7.center) -- (v2.center) -- cycle;
    \foreach \i in {0, 5, 7, 2}{
      \draw[pointplus] (v\i) circle (1.5pt); }
    \fill[faceminus]
    (v1.center) -- (v4.center) -- (v6.center) -- (v3.center) -- cycle;
    \foreach \i in {1, 4, 6, 3}{
      \draw[pointminus] (v\i) circle (1.5pt); }
    \node at (0.25, 1.25, 1) {BC};
  \end{scope}

  % A:C effect.
  \begin{scope}[xshift = 0.0cm, yshift = -5cm]
    \cube{};
    \fill[faceminus]
    (v2.center) -- (v4.center) -- (v5.center) -- (v3.center) -- cycle;
    \foreach \i in {2, 4, 5, 3}{
      \draw[pointminus] (v\i) circle (1.5pt); }
    \fill[faceplus]
    (v0.center) -- (v6.center) -- (v7.center) -- (v1.center) -- cycle;
    \foreach \i in {0, 6, 7, 1}{
      \draw[pointplus] (v\i) circle (1.5pt); }
    \node at (0.25, 1.25, 1) {AC};
  \end{scope}

  % B:C effect.
  \begin{scope}[xshift = 2.5cm, yshift = -5cm]
    \cube{};
    \fill[faceplus]
    (v0.center) -- (v3.center) -- (v7.center) -- (v4.center) -- cycle;
    \foreach \i in {0, 3, 7, 4}{
      \draw[pointplus] (v\i) circle (1.5pt); }
    \fill[faceminus]
    (v1.center) -- (v5.center) -- (v6.center) -- (v2.center) -- cycle;
    \foreach \i in {1, 5, 6, 2}{
      \draw[pointminus] (v\i) circle (1.5pt); }
    \node at (0.25, 1.25, 1) {AB};
  \end{scope}

  \begin{scope}[xshift = 0.0cm, yshift = -7.5cm]
    \cube{};

    % \draw[blue]
    % (v0.center) -- (v5.center) -- (v6.center) -- cycle;
    % \draw[blue]
    % (v0.center) -- (v3.center) -- (v5.center) -- cycle;
    % \draw[blue]
    % (v3.center) -- (v5.center) -- (v6.center) -- cycle;
    % \draw[blue]
    % (v0.center) -- (v3.center) -- (v6.center) -- cycle;
    %
    % \draw[orange]
    % (v1.center) -- (v2.center) -- (v7.center) -- cycle;
    % \draw[orange]
    % (v1.center) -- (v2.center) -- (v4.center) -- cycle;
    % \draw[orange]
    % (v2.center) -- (v4.center) -- (v7.center) -- cycle;
    % \draw[orange]
    % (v1.center) -- (v4.center) -- (v7.center) -- cycle;

    \foreach \i in {1, 2, 7, 4}{
      \draw[pointplus] (v\i) circle (1.5pt); }
    \foreach \i in {0, 5, 6, 3}{
      \draw[pointminus] (v\i) circle (1.5pt); }
    \node at (0.25, 1.25, 1) {ABC};
  \end{scope}

\end{tikzpicture}%

\tikzset{
  vertex/.style={
    circle, minimum size=20pt, inner sep=0pt, fill=gray!10},
  axial/.style={
    rectangle, minimum size=20pt, inner sep=0pt, fill=gray!30},
  edge/.style={draw,thick,-,black},
  rotu/.style={midway},
  sinal/.style={draw, circle, inner sep=0pt, thin}
}

\def\dist{0.4}
\begin{tikzpicture}[
  scale=2, ->, thick, z={(0.45,0.35)}, node distance=0.65cm]
  \node[vertex] (v0) at (0,0,0) {$(1)$};
  \node[vertex] (v1) at (0,1,0) {$b$};
  \node[vertex] (v2) at (1,0,0) {$a$};
  \node[vertex] (v3) at (1,1,0) {$ab$};
  \node[vertex] (v4) at (0,0,1) {$c$};
  \node[vertex] (v5) at (0,1,1) {$bc$};
  \node[vertex] (v6) at (1,0,1) {$ac$};
  \node[vertex] (v7) at (1,1,1) {$abc$};
  \draw[edge] (v0) -- (v1) node[rotu, left=\dist] {$B$} -- 
    (v3) -- (v2) -- (v0) node[rotu, below=\dist] {$A$};
  \draw[edge] (v0) -- (v4) -- (v5) -- (v1);
  \draw[edge] (v2) -- (v6)
    node[rotu, below right=\dist] {$C$} -- (v7) -- (v3);
  \draw[edge] (v4) -- (v6); \draw[edge] (v5) -- (v7);
  \node[sinal, below of=v0] {$-$};
  \node[sinal, left of=v0] {$-$};
  \node[sinal, left of=v1] {$+$};
  \node[sinal, below of=v2] {$+$};
  \node[sinal, right of=v3] {$-$};
  \node[sinal, right of=v7] {$+$};
\end{tikzpicture}

\def\dist{0.4}
\def\ax{2}
\begin{tikzpicture}[
  scale=2, ->, thick, z={(0.55,0.3)}, node distance=0.65cm]
  \node[vertex, fill=yellow] (c0) at (0,0,0) {$0$};
  \node[vertex] (v0) at (-1,-1,-1) {$(1)$};
  \node[vertex] (v1) at (-1,1,-1) {$b$};
  \node[vertex] (v2) at (1,-1,-1) {$a$};
  \node[vertex] (v3) at (1,1,-1) {$ab$};
  \node[vertex] (v4) at (-1,-1,1) {$c$};
  \node[vertex] (v5) at (-1,1,1) {$bc$};
  \node[vertex] (v6) at (1,-1,1) {$ac$};
  \node[vertex] (v7) at (1,1,1) {$abc$};
  \node[axial] (a1) at (-\ax,0,0) {$W$};
  \node[axial] (a2) at (\ax,0,0) {$W$};
  \node[axial] (a3) at (0,-\ax,0) {$W$};
  \node[axial] (a4) at (0,\ax,0) {$W$};
  \node[axial] (a5) at (0,0,-\ax) {$W$};
  \node[axial] (a6) at (0,0,\ax) {$W$};
  \draw[edge] (v0) -- (v1) node[rotu, left=\dist] {$B$} -- 
    (v3) -- (v2) -- (v0) node[rotu, below=\dist] {$A$};
  \draw[edge] (v0) -- (v4) -- (v5) -- (v1);
  \draw[edge] (v2) -- (v6)
    node[rotu, below right=\dist] {$C$} -- (v7) -- (v3);
  \draw[edge] (v4) -- (v6); \draw[edge] (v5) -- (v7);
  \draw[edge] (a1) -- (c0) --(a2);
  \draw[edge] (a3) -- (c0) --(a4);
  \draw[edge] (a5) -- (c0) --(a6);
  \node[sinal, below of=v0] {$-$};
  \node[sinal, left of=v0] {$-$};
  \node[sinal, left of=v1] {$+$};
  \node[sinal, below of=v2] {$+$};
  \node[sinal, right of=v3] {$-$};
  \node[sinal, right of=v7] {$+$};
\end{tikzpicture}

\begin{tikzpicture}[
  scale=2, ->, thick, z={(0.45,0.35)}, node distance=0.65cm,
  vertex/.style={
    rectangle, minimum size=12pt, inner sep=1pt, fill=gray!10
  }]
  \node[text centered] (title) at (0.7,1.7,0)
    {Rendimento (\%) em um $2^3$};
  \node[vertex] (v0) at (0,0,0) {$54.8$};
  \node[vertex] (v1) at (0,1,0) {$48.0$};
  \node[vertex] (v2) at (1,0,0) {$86.5$};
  \node[vertex] (v3) at (1,1,0) {$63.0$};
  \node[vertex] (v4) at (0,0,1) {$63.0$};
  \node[vertex] (v5) at (0,1,1) {$58.5$};
  \node[vertex] (v6) at (1,0,1) {$93.5$};
  \node[vertex] (v7) at (1,1,1) {$72.0$};
  \draw[edge] (v0) -- (v1)
    node[rotu, rotate=90, yshift=1.2cm] {Catalizador} -- 
    (v3) -- (v2) -- (v0) node[rotu, below=0.9cm] {Temperatura};
  \draw[edge] (v0) -- (v4) -- (v5) -- (v1);
  \draw[edge] (v2) -- (v6)
    node[rotu, rotate=40, yshift=-1cm, xshift=0.5cm]
    {Concentra\c{c}\~ao} -- (v7) -- (v3);
  \draw[edge] (v4) -- (v6); \draw[edge] (v5) -- (v7);
  \node[sinal, below of=v0] {$-$};
  \node[sinal, left of=v0] {$-$};
  \node[sinal, left of=v1] {$+$};
  \node[sinal, below of=v2] {$+$};
  \node[sinal, right of=v3] {$-$};
  \node[sinal, right of=v7] {$+$};
\end{tikzpicture}

\begin{tikzpicture}[%
  node distance = 4ex,
  scale = 3,
  thick,
  > = latex,
  z = {(0.45, 0.25)},
  edge/.style = {
    draw, thick, -, black},
  textbox/.style = {
    fill = white, draw, rectangle, thin, rounded corners = 2pt},
  ]

  \def\cube{

    % Vertices.
    \coordinate (v0) at (0, 0, 0);
    \coordinate (v1) at (0, 1, 0);
    \coordinate (v2) at (1, 0, 0);
    \coordinate (v3) at (1, 1, 0);
    \coordinate (v4) at (0, 0, 1);
    \coordinate (v5) at (0, 1, 1);
    \coordinate (v6) at (1, 0, 1);
    \coordinate (v7) at (1, 1, 1);

    \coordinate (v8) at (0.5, 0.5, 0.5);

    % Edges.
    \draw[edge] (v0) -- (v1) -- (v3) -- (v2) -- (v0);
    \draw[edge, very thin] (v0) -- (v4) -- (v5);
    \draw[edge] (v2) -- (v6) -- (v7) -- (v3);
    \draw[edge, very thin] (v4) -- (v6);
    \draw[edge] (v1) -- (v5) -- (v7);

    % Points.
    \foreach \i in {0, 1, ..., 8}{
      \draw[fill = black] (v\i) circle (0.8pt);
    }

  } % \cube

  \begin{scope}[xshift = 2.2cm, ->]
    \draw (0, 0, 0) -- +(0.3, 0, 0) node[right] {A};
    \draw (0, 0, 0) -- +(0, 0.3, 0) node[above] {C};
    \draw (0, 0, 0) -- +(0, 0, 0.45) node[above, anchor = -150] {B};
  \end{scope}

  \begin{scope}[]
    \cube{};
    % Montgomery · Design and Analysis of Experiments (8th Edition), page 246, Example 6.1.
    \foreach \i/\y in {
      0/1154, 1/2089, 2/1319, 3/1617,
      4/1234, 5/2138, 6/1277, 7/1589}{
      \node[textbox] at (v\i) {\y};
    }
    \node[textbox, xshift = 3.5cm, align = left]
      (pc) at (v8) {1754\\ 1620\\ 1810\\ 1513};
    \draw[->, dashed] (v8) -- (pc);
  \end{scope}

\end{tikzpicture}%

\begin{tikzpicture}[%
  node distance = 4ex,
  scale = 3,
  thick,
  > = latex,
  z = {(0.45, 0.25)},
  edge/.style = {draw, thick, -, black},
  sinal/.style = {inner sep = 1pt, thin, opacity = 0.4,
    fill = blue, circle, text opacity = 1},
  mtx/.style = {
%     matrix of math nodes,
    matrix of nodes,
    every node/.style = {
      anchor = base,
      text width = 2em,
      text height = 1em,
      align = center,
    }
  },
  ]

  \def\dist{0.1}
  \def\cube{

    % Vertices.
    \coordinate (v0) at (0, 0, 0);
    \coordinate (v1) at (0, 1, 0);
    \coordinate (v2) at (1, 0, 0);
    \coordinate (v3) at (1, 1, 0);
    \coordinate (v4) at (0, 0, 1);
    \coordinate (v5) at (0, 1, 1);
    \coordinate (v6) at (1, 0, 1);
    \coordinate (v7) at (1, 1, 1);

    \coordinate (v8) at (0.5, 0.5, 0.5);

    % Edges.
    \draw[edge] (v0) -- (v1) -- (v3) -- (v2) -- (v0);
    \draw[edge] (v0) -- (v4) -- (v5) -- (v1);
    \draw[edge] (v2) -- (v6) -- (v7) -- (v3);
    \draw[edge] (v4) -- (v6);
    \draw[edge] (v5) -- (v7);

    % Points.
    \foreach \i in {0, 1, ..., 8}{ \draw[fill = black] (v\i) circle (0.8pt); }

  } % \cube

  \begin{scope}[xshift = 2.2cm, ->, > = latex]
    \draw (0, 0, 0) -- +(0.3, 0, 0) node[right] {A};
    \draw (0, 0, 0) -- +(0, 0.3, 0) node[above] {B};
    \draw (0, 0, 0) -- +(0, 0, 0.45) node[above, anchor = -150] {C};
  \end{scope}

  \begin{scope}[]
    \cube{};

    \coordinate (cube1top) at (0.25, 1.5, 1);

    \foreach \i/\y in {0/10, 1/10, 2/10, 3/10, 4/10, 5/10, 6/10, 7/10}{
      \node[fill = white, draw, rectangle] at (v\i) {\y}; 
    }

    \node[xshift = 3.5cm, align = left] (pc) at (v8) {10\\ 10\\ 10\\ 10};

   \draw[dashed] (pc) -- (v8);

  \end{scope}

\end{tikzpicture}%

\begin{tikzpicture}[%
  node distance = 4ex,
  scale = 3,
  thick,
  > = latex,
  z = {(0.45, 0.25)},
  edge/.style = {draw, thick, -, black},
  sinal/.style = {inner sep = 1pt, thin, opacity = 0.4,
    fill = blue, circle, text opacity = 1},
  mtx/.style = {
%     matrix of math nodes,
    matrix of nodes,
    every node/.style = {
      anchor = base,
      text width = 2em,
      text height = 1em,
      align = center,
    }
  },
  ]

  \def\dist{0.1}
  \def\cube{

    % Vertices.
    \coordinate (v0) at (0, 0, 0);
    \coordinate (v1) at (0, 1, 0);
    \coordinate (v2) at (1, 0, 0);
    \coordinate (v3) at (1, 1, 0);
    \coordinate (v4) at (0, 0, 1);
    \coordinate (v5) at (0, 1, 1);
    \coordinate (v6) at (1, 0, 1);
    \coordinate (v7) at (1, 1, 1);

    % Edges.
    \draw[edge] (v0) -- (v1) -- (v3) -- (v2) -- (v0);
    \draw[edge] (v0) -- (v4) -- (v5) -- (v1);
    \draw[edge] (v2) -- (v6) -- (v7) -- (v3);
    \draw[edge] (v4) -- (v6);
    \draw[edge] (v5) -- (v7);

    % Points.
    \foreach \i in {0, 1, ..., 7}{ \draw[fill = black] (v\i) circle (0.8pt); }

    % Axis text.
    \node[below of = v0, sinal, fill = blue] (Alow) {$-$};
    \node[below of = v2, sinal, fill = orange] (Ahig) {$+$};
    \path[draw, ->, shorten <= 1ex, shorten >= 1ex] (Alow) -- node[below] {A} (Ahig);

%     \node[left of = v0, sinal, fill = blue] (Blow) {$-$};
%     \node[left of = v1, sinal, fill = orange] (Bhig) {$+$};
%     \path[draw, ->, shorten <= 1ex, shorten >= 1ex] (Blow) -- node[left] {B} (Bhig);

    \node[right of = v6, sinal, fill = blue] (Blow) {$-$};
    \node[right of = v7, sinal, fill = orange] (Bhig) {$+$};
    \path[draw, ->, shorten <= 1ex, shorten >= 1ex] (Blow) -- node[right] {B} (Bhig);

%     \node[below right = of v2, sinal, fill = blue] (Clow) {$-$};
%     \node[below right = of v6, sinal, fill = orange] (Chig) {$+$};
%     \path[draw, ->, shorten <= 1ex, shorten >= 1ex] (Clow) -- node[below right] {C} (Chig);

    \node[above left = of v1, sinal, fill = blue] (Clow) {$-$};
    \node[above left = of v5, sinal, fill = orange] (Chig) {$+$};
    \path[draw, ->, shorten <= 1ex, shorten >= 1ex] (Clow) -- node[above left] {C} (Chig);

  } % \cube

  \begin{scope}[]
    \cube{};
    \coordinate (cube1top) at (0.25, 1.5, 1);
  \end{scope}

\end{tikzpicture}%

\begin{tikzpicture}[%
  node distance = 4ex,
  scale = 3,
  thick,
  > = latex,
  z = {(0.45, 0.25)},
  edge/.style = {draw, thick, -, black},
  sinal/.style = {inner sep = 1pt, thin, opacity = 0.4,
    fill = blue, circle, text opacity = 1},
  mtx/.style = {
%     matrix of math nodes,
    matrix of nodes,
    every node/.style = {
      anchor = base,
      text width = 2em,
      text height = 1em,
      align = center,
    }
  },
  ]

  \def\dist{0.1}
  \def\cube{

    % Vertices.
    \coordinate (v0) at (0, 0, 0);
    \coordinate (v1) at (0, 1, 0);
    \coordinate (v2) at (1, 0, 0);
    \coordinate (v3) at (1, 1, 0);
    \coordinate (v4) at (0, 0, 1);
    \coordinate (v5) at (0, 1, 1);
    \coordinate (v6) at (1, 0, 1);
    \coordinate (v7) at (1, 1, 1);

    % Edges.
    \draw[edge] (v0) -- (v1) -- (v3) -- (v2) -- (v0);
    \draw[edge] (v0) -- (v4) -- (v5) -- (v1);
    \draw[edge] (v2) -- (v6) -- (v7) -- (v3);
    \draw[edge] (v4) -- (v6);
    \draw[edge] (v5) -- (v7);

    % Points.
    \foreach \i in {0, 1, ..., 7}{ \draw[fill = black] (v\i) circle (0.8pt); }

    % Axis text.
    \node[below of = v0, sinal, fill = blue] (Alow) {$-$};
    \node[below of = v2, sinal, fill = orange] (Ahig) {$+$};
    \path[draw, ->, shorten <= 1ex, shorten >= 1ex] (Alow) -- node[below] {A} (Ahig);

%     \node[left of = v0, sinal, fill = blue] (Blow) {$-$};
%     \node[left of = v1, sinal, fill = orange] (Bhig) {$+$};
%     \path[draw, ->, shorten <= 1ex, shorten >= 1ex] (Blow) -- node[left] {B} (Bhig);

    \node[right of = v6, sinal, fill = blue] (Blow) {$-$};
    \node[right of = v7, sinal, fill = orange] (Bhig) {$+$};
    \path[draw, ->, shorten <= 1ex, shorten >= 1ex] (Blow) -- node[right] {B} (Bhig);

%     \node[below right = of v2, sinal, fill = blue] (Clow) {$-$};
%     \node[below right = of v6, sinal, fill = orange] (Chig) {$+$};
%     \path[draw, ->, shorten <= 1ex, shorten >= 1ex] (Clow) -- node[below right] {C} (Chig);

    \node[above left = of v1, sinal, fill = blue] (Clow) {$-$};
    \node[above left = of v5, sinal, fill = orange] (Chig) {$+$};
    \path[draw, ->, shorten <= 1ex, shorten >= 1ex] (Clow) -- node[above left] {C} (Chig);

  } % \cube

  \begin{scope}[]
    \cube{};
    \coordinate (cube1top) at (0.25, 1.5, 1);
    \coordinate (cube1lef) at (-0.5, 0.5, 0);
  \end{scope}

  \begin{scope}[xshift = 2.8cm]
    \cube{};
    \coordinate (cube2) at (0.25, 1.5, 1);
  \end{scope}

  \begin{scope}[node distance = 4ex]
    \draw[edge, color = gray] (cube1top) |- ++(0, 0.1) -| (cube2);
    \node[above = of cube1top, sinal, fill = blue] (Dlow) {$-$};
    \node[above = of cube2, sinal, fill = orange] (Dhig) {$+$};
    \path[draw, ->, shorten <= 10ex, shorten >= 10ex] (Dlow) -- node[above] {D} (Dhig);
  \end{scope}

\end{tikzpicture}%
ift = -2.5cm]
    \cube{};
    \coordinate (cube3) at (-0.5, 0.5, 0);
  \end{scope}

  \begin{scope}[xshift = 2.8cm, yshift = -2.5cm]
    \cube{};
  \end{scope}

  \begin{scope}[node distance = 4ex]
    \draw[edge, color = gray] (cube3) -| ++(-0.1, 0) |- (cube1lef);
    \node[left = of cube1lef, sinal, fill = orange] (Ehig) {$+$};
    \node[left = of cube3, sinal, fill = blue] (Elow) {$-$};
    \path[draw, ->, shorten <= 10ex, shorten >= 10ex] (Elow) -- node[left] {E} (Ehig);
  \end{scope}

\end{tikzpicture}%

\begin{tikzpicture}[%
  node distance = 4ex,
  scale = 3,
  thick,
  > = latex,
  z = {(0.45, 0.25)},
  edge/.style = {draw, thick, -, black},
  sinal/.style = {inner sep = 1pt, thin, opacity = 0.4,
    fill = blue, circle, text opacity = 1},
  mtx/.style = {
%     matrix of math nodes,
    matrix of nodes,
    every node/.style = {
      anchor = base,
      text width = 2em,
      text height = 1em,
      align = center,
    }
  },
  ]

  \def\dist{0.1}
  \def\cube{

    % Vertices.
    \coordinate (v0) at (0, 0, 0);
    \coordinate (v1) at (0, 1, 0);
    \coordinate (v2) at (1, 0, 0);
    \coordinate (v3) at (1, 1, 0);
    \coordinate (v4) at (0, 0, 1);
    \coordinate (v5) at (0, 1, 1);
    \coordinate (v6) at (1, 0, 1);
    \coordinate (v7) at (1, 1, 1);

    % Edges.
    \draw[edge] (v0) -- (v1) -- (v3) -- (v2) -- (v0);
    \draw[edge] (v0) -- (v4) -- (v5) -- (v1);
    \draw[edge] (v2) -- (v6) -- (v7) -- (v3);
    \draw[edge] (v4) -- (v6);
    \draw[edge] (v5) -- (v7);

    % Points.
    \foreach \i in {0, 1, ..., 7}{ \draw[fill = black] (v\i) circle (0.8pt); }

    % Axis text.
    \node[below of = v0, sinal, fill = blue] (Alow) {$-$};
    \node[below of = v2, sinal, fill = orange] (Ahig) {$+$};
    \path[draw, ->, shorten <= 1ex, shorten >= 1ex] (Alow) -- node[below] {A} (Ahig);

%     \node[left of = v0, sinal, fill = blue] (Blow) {$-$};
%     \node[left of = v1, sinal, fill = orange] (Bhig) {$+$};
%     \path[draw, ->, shorten <= 1ex, shorten >= 1ex] (Blow) -- node[left] {B} (Bhig);

    \node[right of = v6, sinal, fill = blue] (Blow) {$-$};
    \node[right of = v7, sinal, fill = orange] (Bhig) {$+$};
    \path[draw, ->, shorten <= 1ex, shorten >= 1ex] (Blow) -- node[right] {B} (Bhig);

%     \node[below right = of v2, sinal, fill = blue] (Clow) {$-$};
%     \node[below right = of v6, sinal, fill = orange] (Chig) {$+$};
%     \path[draw, ->, shorten <= 1ex, shorten >= 1ex] (Clow) -- node[below right] {C} (Chig);

    \node[above left = of v1, sinal, fill = blue] (Clow) {$-$};
    \node[above left = of v5, sinal, fill = orange] (Chig) {$+$};
    \path[draw, ->, shorten <= 1ex, shorten >= 1ex] (Clow) -- node[above left] {C} (Chig);

  } % \cube

  \begin{scope}[]
    \cube{};
    \coordinate (cube1top) at (0.25, 1.5, 1);
    \coordinate (cube1lef) at (-0.5, 0.5, 0);
  \end{scope}

  \begin{scope}[xshift = 2.8cm]
    \cube{};
    \coordinate (cube2) at (0.25, 1.5, 1);
  \end{scope}

  \begin{scope}[node distance = 4ex]
    \draw[edge, color = gray] (cube1top) |- ++(0, 0.1) -| (cube2);
    \node[above = of cube1top, sinal, fill = blue] (Dlow) {$-$};
    \node[above = of cube2, sinal, fill = orange] (Dhig) {$+$};
    \path[draw, ->, shorten <= 10ex, shorten >= 10ex] (Dlow) -- node[above] {D} (Dhig);
  \end{scope}

  \begin{scope}[yshift = -2.5cm]
    \cube{};
    \coordinate (cube3) at (-0.5, 0.5, 0);
  \end{scope}

  \begin{scope}[xshift = 2.8cm, yshift = -2.5cm]
    \cube{};
  \end{scope}

  \begin{scope}[node distance = 4ex]
    \draw[edge, color = gray] (cube3) -| ++(-0.1, 0) |- (cube1lef);
    \node[left = of cube1lef, sinal, fill = orange] (Ehig) {$+$};
    \node[left = of cube3, sinal, fill = blue] (Elow) {$-$};
    \path[draw, ->, shorten <= 10ex, shorten >= 10ex] (Elow) -- node[left] {E} (Ehig);
  \end{scope}

\end{tikzpicture}%

\begin{tikzpicture}[%
  node distance = 4ex,
  scale = 3,
  thick,
  > = latex,
  z = {(0.45, 0.25)},
  edge/.style = {draw, thick, -, black},
  axispath/.style = {draw, ->, shorten <= 1ex, shorten >= 1ex},
  sinal/.style = {inner sep = 1pt, thin, opacity = 0.4,
    fill = blue, circle, text opacity = 1},
  ]

  \def\cube{

    \foreach \x in {0, 1, 2} {
      \foreach \y in {0, 1, 2} {
        \coordinate (v\x\y) at (\x, \y);
        % \draw[fill = black] (v\x\y\z) circle (0.8pt);
        \node[draw, circle, inner sep = 0.2ex,
          fill = white, font = \footnotesize] at (v\x\y) {\x\y};
      }
    }

    \begin{scope}[on background layer]
      \foreach \u in {0, 1, 2} {
        \draw[edge] (v0\u) -- (v2\u);
        \draw[edge] (v\u0) -- (v\u2);
      }
    \end{scope}

    % Axis text.
    \node[below of = v00, sinal, fill = blue] (Alow) {$0$};
    \node[below of = v10, sinal, fill = green, label = {[below = 1ex]-90:A}] (Amid) {$1$};
    \node[below of = v20, sinal, fill = orange] (Ahig) {$2$};
    \path[axispath] (Alow) edge (Amid) (Amid) edge (Ahig);

    \node[right of = v20, sinal, fill = blue] (Blow) {$0$};
    \node[right of = v21, sinal, fill = green, label = {[right = 1ex]0:B}] (Bmid) {$1$};
    \node[right of = v22, sinal, fill = orange] (Bhig) {$2$};
    \path[axispath] (Blow) edge (Bmid) (Bmid) edge (Bhig);

  } % \cube

  \begin{scope}[]
    \cube{};
  \end{scope}

\end{tikzpicture}%

\begin{tikzpicture}[%
  node distance = 4ex,
  scale = 3,
  thick,
  > = latex,
  z = {(0.4, 0.25)},
  edge/.style = {draw, thick, -, black},
  axispath/.style = {draw, ->, shorten <= 1ex, shorten >= 1ex},
  sinal/.style = {inner sep = 1pt, thin, opacity = 0.4,
    fill = blue, circle, text opacity = 1},
  ]

  \def\cube{

    \foreach \x in {0, 1, 2} {
      \foreach \y in {0, 1, 2} {
        \foreach \z in {0, 1, 2} {
          \coordinate (v\x\y\z) at (\x, \y, \z);
          % \draw[fill = black] (v\x\y\z) circle (0.8pt);
          \node[draw, circle, inner sep = 0.2ex,
            fill = white, font = \footnotesize] at (v\x\y\z) {\x\y\z};
        }
      }
    }

    \begin{scope}[on background layer]
      \foreach \y in {0, 1, 2} {
        \draw[edge] (v0\y0) -- (v0\y2) -- (v2\y2) -- (v2\y0) -- cycle;
        \draw[edge] (v1\y0) -- (v1\y2);
        \draw[edge] (v0\y1) -- (v2\y1);
      }
      \foreach \x in {0, 1, 2} {
        \foreach \z in {0, 1, 2} {
          \draw[edge] (v\x0\z) -- (v\x2\z);
        }
      }
    \end{scope}

    % Axis text.
    \node[below of = v000, sinal, fill = blue] (Alow) {$0$};
    \node[below of = v100, sinal, fill = green, label = {[below = 1ex]-90:A}] (Amid) {$1$};
    \node[below of = v200, sinal, fill = orange] (Ahig) {$2$};
    \path[axispath] (Alow) edge (Amid) (Amid) edge (Ahig);

    \node[right of = v202, sinal, fill = blue] (Blow) {$0$};
    \node[right of = v212, sinal, fill = green, label = {[right = 1ex]0:B}] (Bmid) {$1$};
    \node[right of = v222, sinal, fill = orange] (Bhig) {$2$};
    \path[axispath] (Blow) edge (Bmid) (Bmid) edge (Bhig);

    \node[above left of = v020, sinal, fill = blue] (Clow) {$0$};
    \node[above left of = v021, sinal, fill = green, label = {[above left = 1ex]105:C}] (Cmid) {$1$};
    \node[above left of = v022, sinal, fill = orange] (Chig) {$2$};
    \path[axispath] (Clow) edge (Cmid) (Cmid) edge (Chig);

  } % \cube

  \begin{scope}[]
    \cube{};
  \end{scope}

  \begin{scope}[]
    \cube{};
  \end{scope}

\end{tikzpicture}%

\begin{tikzpicture}[%
  node distance = 4ex,
  scale = 3,
  thick,
  > = latex,
  z = {(0.4, 0.25)},
  edge/.style = {draw, thick, -, black},
  axispath/.style = {draw, ->, shorten <= 1ex, shorten >= 1ex},
  sinal/.style = {inner sep = 1pt, thin, opacity = 0.4,
    fill = blue, circle, text opacity = 1},
  ]

  \newcommand{\cube}[1]{

    \foreach \x in {0, 1, 2} {
      \foreach \y in {0, 1, 2} {
        \foreach \z in {0, 1, 2} {
          \coordinate (v\x\y\z) at (\x, \y, \z);
%             \draw[fill = black] (v\x\y\z) circle (0.8pt);
          \node[draw, circle, inner sep = 0.2ex,
            fill = white, font = \footnotesize] at (v\x\y\z) {\x\y\z#1};
        }
      }
    }

    \begin{scope}[on background layer]
      \foreach \y in {0, 1, 2} {
        \draw[edge] (v0\y0) -- (v0\y2) -- (v2\y2) -- (v2\y0) -- cycle;
        \draw[edge] (v1\y0) -- (v1\y2);
        \draw[edge] (v0\y1) -- (v2\y1);
      }
      \foreach \x in {0, 1, 2} {
        \foreach \z in {0, 1, 2} {
          \draw[edge] (v\x0\z) -- (v\x2\z);
        }
      }
    \end{scope}

    % Axis text.
    \node[below of = v000, sinal, fill = blue] (Alow) {$0$};
    \node[below of = v100, sinal, fill = green, label = {[below = 1ex]-90:A}] (Amid) {$1$};
    \node[below of = v200, sinal, fill = orange] (Ahig) {$2$};
    \path[axispath] (Alow) edge (Amid) (Amid) edge (Ahig);

    \node[right of = v202, sinal, fill = blue] (Blow) {$0$};
    \node[right of = v212, sinal, fill = green, label = {[right = 1ex]0:B}] (Bmid) {$1$};
    \node[right of = v222, sinal, fill = orange] (Bhig) {$2$};
    \path[axispath] (Blow) edge (Bmid) (Bmid) edge (Bhig);

    \node[above left of = v020, sinal, fill = blue] (Clow) {$0$};
    \node[above left of = v021, sinal, fill = green, label = {[above left = 1ex]105:C}] (Cmid) {$1$};
    \node[above left of = v022, sinal, fill = orange] (Chig) {$2$};
    \path[axispath] (Clow) edge (Cmid) (Cmid) edge (Chig);

  } % \cube

  \begin{scope}[]
    \cube{0};
    \coordinate (cube0) at (1, 2.7, 1);
  \end{scope}

  \begin{scope}[xshift = 3.75cm]
    \cube{1};
    \coordinate (cube1) at (1, 2.7, 1);
  \end{scope}

  \begin{scope}[xshift = 7.50cm]
    \cube{2};
    \coordinate (cube2) at (1, 2.7, 1);
  \end{scope}

  \begin{scope}[node distance = 4ex]
    \draw[edge, color = gray] (cube0) |- ++(0, 0.1) -| (cube1);
    \draw[edge, color = gray] (cube1) |- ++(0, 0.1) -| (cube2);
    \node[above = of cube0, sinal, fill = blue] (Dlow) {$0$};
    \node[above = of cube1, sinal, fill = green, label = {[above = 1ex]90:D}] (Dmid) {$1$};
    \node[above = of cube2, sinal, fill = orange] (Dhig) {$2$};
    \path[axispath] (Dlow) edge (Dmid) (Dmid) edge (Dhig);
  \end{scope}

\end{tikzpicture}%

\begin{tikzpicture}[%
  scale = 3,
  thick,
  z = {(0.45, 0.25)},
  edge/.style = {draw, thick, -, black},
  mtx/.style = {
%     matrix of math nodes,
    matrix of nodes,
    every node/.style = {
      anchor = base,
      text width = 2em,
      text height = 1em,
      align = center,
    }
  },
  ]

  \def\dist{0.1}
  \def\cube{
    % Vertices.
    \coordinate (v0) at (0, 0, 0);
    \coordinate (v1) at (0, 1, 0);
    \coordinate (v2) at (1, 0, 0);
    \coordinate (v3) at (1, 1, 0);
    \coordinate (v4) at (0, 0, 1);
    \coordinate (v5) at (0, 1, 1);
    \coordinate (v6) at (1, 0, 1);
    \coordinate (v7) at (1, 1, 1);

    % Edges.
    \draw[edge] (v0) -- (v1) -- (v3) -- (v2) -- (v0);
    \draw[edge] (v0) -- (v4) -- (v5) -- (v1);
    \draw[edge] (v2) -- (v6) -- (v7) -- (v3);
    \draw[edge] (v4) -- (v6);
    \draw[edge] (v5) -- (v7);

  } % \cube

  \begin{scope}[xshift = 1.7cm, ->, > = latex]
    \draw (0, 0, 0) -- +(0.3, 0, 0) node[right] {A};
    \draw (0, 0, 0) -- +(0, 0.3, 0) node[above] {B};
    \draw (0, 0, 0) -- +(0, 0, 0.45) node[above, anchor = -150] {C};
  \end{scope}

  \begin{scope}[]
    \cube{};
    \foreach \i in {0, 3, 5, 6}{ \draw[fill = blue] (v\i) circle (1.5pt); }
    \foreach \i in {1, 2, 4, 7}{ \draw[fill = orange] (v\i) circle (1.5pt); }
    \node at (0.25, 1.25, 1) {$2^3 = 8$ em $2^1$ blocos};
  \end{scope}

  \begin{scope}[xshift = 2cm, yshift = 1cm]
    \coordinate (b1) at (0, 0);
    \coordinate (b2) at (0, -0.5em);
    \draw[fill = blue] (b1) circle (1.5pt) node[right = 0.7ex] {Bloco I};
    \draw[fill = orange] (b2) circle (1.5pt) node[right = 0.7ex] {Bloco II};
  \end{scope}

  \begin{scope}[xshift = 3cm, yshift= 1.3cm]
    \matrix (B1) at (0, 0) [mtx] {
      (1) \\ ab \\ ac \\ bc \\
    };
    \matrix (B2) [mtx, below = 1em of B1] {
      a \\ b \\ c \\ abc \\
    };
    \node[draw, color = blue, fit = (B1-1-1)(B1-4-1)] {};
    \node[draw, color = orange, fit = (B2-1-1)(B2-4-1)] {};
  \end{scope}

\end{tikzpicture}%

\begin{tikzpicture}[%
  scale = 3,
  thick,
  z = {(0.45, 0.25)},
  edge/.style = {draw, thick, -, black},
  mtx/.style = {
%     matrix of math nodes,
    matrix of nodes,
    every node/.style = {
      anchor = base,
      text width = 2em,
      text height = 1em,
      align = center,
    }
  },
  ]

  \def\dist{0.1}
  \def\cube{
    % Vertices.
    \coordinate (v0) at (0, 0, 0);
    \coordinate (v1) at (0, 1, 0);
    \coordinate (v2) at (1, 0, 0);
    \coordinate (v3) at (1, 1, 0);
    \coordinate (v4) at (0, 0, 1);
    \coordinate (v5) at (0, 1, 1);
    \coordinate (v6) at (1, 0, 1);
    \coordinate (v7) at (1, 1, 1);

    % Edges.
    \draw[edge] (v0) -- (v1) -- (v3) -- (v2) -- (v0);
    \draw[edge] (v0) -- (v4) -- (v5) -- (v1);
    \draw[edge] (v2) -- (v6) -- (v7) -- (v3);
    \draw[edge] (v4) -- (v6);
    \draw[edge] (v5) -- (v7);

  } % \cube

  \begin{scope}[xshift = 1.7cm, ->, > = latex]
    \draw (0, 0, 0) -- +(0.3, 0, 0) node[right] {A};
    \draw (0, 0, 0) -- +(0, 0.3, 0) node[above] {B};
    \draw (0, 0, 0) -- +(0, 0, 0.45) node[above, anchor = -150] {C};
  \end{scope}

  \begin{scope}[]
    \cube{};
    \foreach \i in {0, 3, 5, 6}{ \draw[fill = blue] (v\i) circle (1.5pt); }
    \node at (0.25, 1.25, 1) {$2^{3 - 1} = 4$, fra{\c c}{\~a}o $1/2$};
  \end{scope}

  \begin{scope}[xshift = 2cm, yshift = 1.25cm]
    \coordinate (b1) at (0, 0);
    \draw[fill = blue] (b1) circle (1.5pt) node[right = 0.7ex] {Fra{\c c}{\~a}o principal};
  \end{scope}

  \begin{scope}[xshift = 2.5cm, yshift= 0.5cm]
    \matrix (B1) at (0, 0) [mtx] {
      (1) \\ ab \\ ac \\ bc \\
    };
    \node[draw, color = blue, fit = (B1-1-1)(B1-4-1)] {};
  \end{scope}

\end{tikzpicture}%
(B1) at (0, 0) [mtx] {
      (1) \\ ab \\ ac \\ bc \\
    };
    \matrix (B2) [mtx, below = 1em of B1] {
      a \\ b \\ c \\ abc \\
    };
    \node[draw, color = blue, fit = (B1-1-1)(B1-4-1)] {};
    \node[draw, color = orange, fit = (B2-1-1)(B2-4-1)] {};
  \end{scope}

\end{tikzpicture}%

% References:
% https://www.oreilly.com/library/view/python-data-science/9781491912126/assets/pyds_00in01.png
% https://i.pinimg.com/originals/ca/4d/02/ca4d0248ae5831b0e9b0a2da9f7ba4e3.png
% https://www.altius.co.uk/app/uploads/2018/07/data-science-venn-diagram.jpg
% https://i.pinimg.com/originals/fc/61/40/fc61405983965a5ce1bea0e8a353d6f2.png
% https://4.bp.blogspot.com/-G6EgWv_i9ns/V-FxPixL_tI/AAAAAAAAMHk/LQN1JN8lc9MnKuD-G_2PY6a9c0MEcyeDwCLcB/s1600/datascience_skills_venn_diagram2.png
% https://www.researchgate.net/publication/313020352/figure/fig7/AS:455507778510851@1485612925120/The-Venn-diagram-for-data-science-graphic-by-author-based-on-Conway-2010_W640.jpg
%
% TODO: https://www.researchgate.net/publication/313020352_Think_big_learning_contexts_algorithms_and_data_science/figures?lo=1
\begin{tikzpicture}[%
  every path/.style = {
   ->,
   > = stealth, 
   rounded corners},
  state/.style = {
    fill = white,
    text centered
  },
  node distance=1.25cm]

  \definecolor{color1}{HTML}{E7AD00}
  \definecolor{color2}{HTML}{A5CC19}
  \definecolor{color3}{HTML}{33B29A}
  \definecolor{color4}{HTML}{3380FF}
  \definecolor{color5}{HTML}{9033FF}
  \definecolor{color6}{HTML}{E5003D}

\begin{scope}[
  opacity = 1,
  fill opacity = 0.25,
  text opacity = 1,
  text width = 6em,
  text centered]

  \def\firstcircle{(90:2.75cm) circle (3.5cm)}
  \def\secondcircle{(210:2.75cm) circle (3.5cm)}
  \def\thirdcircle{(330:2.75cm) circle (3.5cm)}
  \draw [fill = color6] \firstcircle;
  \draw [fill = color4] \secondcircle;
  \draw [fill = color2] \thirdcircle;

\end{scope}

\begin{scope}[minimum width = 1em, text width = 5.0em, text centered]

  \node[state] (int) at ( 90:5.5) {\emph{Intui{\c c}{\~ a}o e viabilidade}};
  \node[state] (val) at (210:5.0) {\emph{Solu{\c c}{\~ a}o e valida{\c c}{\~ a}o}};
  \node[state] (aut) at (-30:5.0) {\emph{Automa{\c c}{\~ a}o e escala}};

  \node (con) at (90:3) {Dom{\' i}nio de\\ conhecimento};
  \node (est) at (210:3) {Matem{\' a}tica \& Estat{\' i}stica};
  \node[text width = 7em] (hac) at (-30:3) {Habilidades de\\ computa{\c c}{\~ a}o};

  \node[color = red] (sof) at (30:2) {Processamento tradicional};
  \node[color = red] (pes) at (150:2) {Pesquisa tradicional};
  \node[color = red] (mac) at (-90:2) {Zona perigosa};

  \node (ds) at (0:0) {\large Data Science};

\end{scope}

\begin{scope}[
  every node/.style = {
    text centered,
    font = \footnotesize,
    text width = 5em
  }]

  \node at ( 50:3.50) {Engenharia};
  \node at (130:3.50) {Direito};
  \node at ( 70:5.00) {Biologia};
  \node at (110:5.00) {Marketing};
  \node at ( 60:4.25) {Economia};
  \node at (120:4.25) {Comunica{\c c}{\~a}o};
  \node at ( 90:4.25) {Gest{\~a}o};

  \node at ( 05:4.0) {Programa{\c c}{\~a}o};
  \node at (-05:4.5) {Algor{\'\i}tmos};
  \node at (-15:5.0) {Bancos de dados};
  \node at (-50:3.5) {Computa{\c c}{\~a}o em n{\'u}vem};
  \node at (-60:4.5) {Machine learning};

  \node at (175:4.0) {Visualiza{\c c}{\~a}o};
  \node at (185:4.5) {Otimiza{\c c}{\~a}o};
  \node at (195:5.0) {Infer{\^e}ncia estat{\'\i}stica};
  \node at (230:3.5) {An{\'a}lise multivariada};
  \node at (240:4.5) {Modelagem estat{\'\i}stica};

\end{scope}

\end{tikzpicture}%

\begin{tikzpicture}[
  every path/.style = {
   ->,
   > = stealth, 
   rounded corners},
  state/.style = {
    fill = white,
    text centered
  },
  node distance=1.25cm]

  \definecolor{color1}{HTML}{E7AD00}
  \definecolor{color2}{HTML}{A5CC19}
  \definecolor{color3}{HTML}{33B29A}
  \definecolor{color4}{HTML}{3380FF}
  \definecolor{color5}{HTML}{9033FF}
  \definecolor{color6}{HTML}{E5003D}

\begin{scope}[
  opacity = 1,
  fill opacity = 0.25,
  text opacity = 1,
  text width = 6em,
  text centered]

  \def\firstcircle{(90:2.75cm) circle (3.5cm)}
  \def\secondcircle{(210:2.75cm) circle (3.5cm)}
  \def\thirdcircle{(330:2.75cm) circle (3.5cm)}
  \draw [fill = color6] \firstcircle
    node [above = 10em] {Conhecimento de neg{\' o}cios};
  \draw [fill = color4] \secondcircle
    node [below left = 10em] {Matem{\' a}tica \& Estat{\' i}stica};
  \draw [fill = color2] \thirdcircle
    node [below right = 10em] {Computa{\c c}{\~a}o};

\end{scope}

\begin{scope}

  \node[state] (intuir) at (90:4.5) {Intuir};
  \node[state] (formular) at (60:3.5) {Formular};
  \node[state] (desenhar) at (30:2) {Desenhar};
  \node[state] (coletar)  at (-10:4)  {Coletar};
  \node[state] (armazenar) at (-30:5) {Armazenar};
  \node[state] (importar) at (-55:4.5) {Importar};
  \node[state] (manipular) at (-70:2.75) {Arrumar};
  \node[state] (transformar) at (-90:1.5) {Transformar};
  \node[state] (visualizar) at (-140:4.5) {Visualizar};
  \node[state] (modelar) at (-170:4) {Modelar};
  \node[state] (comunicar) at (150:2) {Compreender};
  \node[state] (agir) at (120:3.5) {Agir};

  \path[draw] (formular) edge[out=-90, in=90] (desenhar);
  \path[draw] (desenhar) edge[out=-90, in=90] (coletar);
  \path[draw] (coletar) edge[out=-70, in=90] (armazenar);
  \path[draw] (armazenar) edge[out=-90, in=0] (importar);
  \path[draw] (importar) edge[out=180, in=-90] (manipular);
  \path[draw] (manipular) edge[out=90, in=-90] (transformar);
  \path[draw] (transformar) edge[out=-120, in=0] (visualizar);
  \path[draw] (visualizar) edge[out=160, in=210] (modelar);
  \path[draw] (modelar) edge[out=0, in=140] (transformar);
  \path[draw] (modelar) edge[out=90, in=-90] (comunicar);
  \path[draw] (comunicar) edge[out=90, in=-90] (agir);
  \path[draw] (agir) edge[out=90, in=180] (intuir);
  \path[draw] (intuir) edge[out=0, in=90] (formular);

\end{scope}

\end{tikzpicture}%

\tikzset{
  every path/.style = {
   ->,
   > = stealth, 
   rounded corners},
  state/.style = {
    fill = white,
    text centered
  },
  node distance=1.25cm,
  hlt/.style = {opacity = 0.7, line cap = round}
}%

\begin{tikzpicture}

  \node[state] (formular) {Formular};
  \node[state, right = 0.5cm of formular] (desenhar) {Desenhar};
  \node[state, below right of = desenhar] (coletar) {Coletar};
  \node[state, below right of = coletar] (armazenar) {Armazenar};
  \node[state, below right of = armazenar] (importar) {Importar};
  \node[state, above right of = importar] (manipular) {Arrumar};
  \node[state, above right of = manipular] (transformar) {Transformar};
  \node[state, above right = 0.3cm of transformar] (visualizar) {Visualizar};
  \node[state, below right = 0.3cm of transformar] (modelar) {Modelar};
  \node[state, right = 0.5cm of modelar] (comunicar) {Compreender};
  \node[state, below of = comunicar] (agir) {Agir};

  \path[draw] (formular) -- (desenhar);
  \path[draw] (desenhar) -- (coletar);
  \path[draw] (coletar) -- (armazenar);
  \path[draw] (armazenar) -- (importar);
  \path[draw] (importar) -- (manipular);
  \path[draw] (manipular) -- (transformar);

%   \path[draw] (transformar) edge[out=90, in=180] (visualizar);
%   \path[draw] (visualizar) edge[out=0, in=90] (modelar);
%   \path[draw] (modelar) edge[out=270, in=270] (transformar);

  \path[draw] (transformar) edge[bend left=30] (visualizar);
  \path[draw] (visualizar) edge[bend left=30] (modelar);
  \path[draw] (modelar) edge[bend left=30] (transformar);

  \path[draw] (modelar) -- (comunicar);
  \path[draw] (comunicar) -- (agir);

  \begin{pgfonlayer}{background}
  \node[hlt, 
    draw = blue,
%     fill = blue,
    fit = (desenhar)(importar),
    label = {[blue!70]below:Cientista da Computa{\c c}{\~a}o}] {};
  \node[hlt, 
    draw = red,
%     fill = red,
    fit = (importar)(visualizar),
    label = {[red!70]below:Estat{\'i}stico}] {};
  \node[hlt, 
    inner sep = 2em,
    draw = black, 
    fill = none,
    fit = (formular)(importar)(comunicar), 
    label = above:Cientista de Dados] {};
  \end{pgfonlayer}

\end{tikzpicture}%

\tikzset{
  mtx/.style={
    matrix of math nodes,
    left delimiter={[}, right delimiter={]}
  },
  hlt/.style={opacity=0.1, line width=4 mm, line cap=round},
  hltr/.style={opacity=0.5, rounded corners=2pt, inner sep=-1pt}
}

\begin{tikzpicture}

  \matrix[mtx] (X) at (2,2) {
    1 & 0 & 0 & 0 & 0 & 0 \\ 
    1 & 0 & 0 & 1 & 0 & 0 \\ 
    1 & 0 & 0 & 0 & 1 & 0 \\ 
    1 & 0 & 0 & 0 & 0 & 1 \\ 
    1 & 1 & 0 & 0 & 0 & 0 \\ 
    1 & 1 & 0 & 1 & 0 & 0 \\ 
    1 & 1 & 0 & 0 & 1 & 0 \\ 
    1 & 1 & 0 & 0 & 0 & 1 \\ 
    1 & 0 & 1 & 0 & 0 & 0 \\ 
    1 & 0 & 1 & 1 & 0 & 0 \\ 
    1 & 0 & 1 & 0 & 1 & 0 \\ 
    1 & 0 & 1 & 0 & 0 & 1 \\ 
  };

  \matrix[mtx, left=of X] (E) {
    \mu_{11} \\ \mu_{12} \\ \mu_{13} \\ \mu_{14} \\
    \mu_{21} \\ \mu_{22} \\ \mu_{23} \\ \mu_{24} \\
    \mu_{31} \\ \mu_{32} \\ \mu_{33} \\ \mu_{34} \\
  };

  \matrix[mtx, nodes={minimum width=4ex}, right=3ex of X] (beta) { 
    \mu \\ \alpha_2 \\ \alpha_3 \\ \tau_2 \\ \tau_3 \\ \tau_4 \\
  };

  \matrix[mtx, nodes={anchor=west}, right=of beta] (mu) {
    \mu \\
    \mu+\tau_2 \\
    \mu+\tau_3 \\
    \mu+\tau_4 \\
    \mu+\alpha_2 \\
    \mu+\alpha_2+\tau_2 \\
    \mu+\alpha_2+\tau_3 \\
    \mu+\alpha_2+\tau_4 \\
    \mu+\alpha_3 \\
    \mu+\alpha_3+\tau_2 \\
    \mu+\alpha_3+\tau_3 \\
    \mu+\alpha_3+\tau_4 \\
  };

  \draw[-stealth, color=red] (X-1-1.south west) -| (beta-6-1.south west);

  \node at ($(E.east)!0.5!(X.west)$) {$=$};%
  \node at ($(beta.east)!0.5!(mu.west)$) {$=$};%

  \node[above=of X, text width=5cm] {% <- importante!
    $\begin{aligned}
      \mu_{ij} &= \mu+\alpha_i+\tau_j,\\
      &\qquad i=1,2;\quad j=1,2,3;\\
      &\qquad \alpha_1 = \tau_1 = 0\\
      \mu &= X\beta
    \end{aligned}$
  };

  \begin{scope}[on background layer]
    \node[hltr, fill=gray, fit=(beta-1-1)] {};
    \node[hltr, fill=red, fit=(beta-2-1)(beta-3-1)] {};
    \node[hltr, fill=green, fit=(beta-4-1)(beta-6-1)] {};
    \node[hltr, fill=gray, fit=(X-1-1)(X-12-1)] {};
    \node[hltr, fill=red, fit=(X-1-2)(X-12-3)] {};
    \node[hltr, fill=green, fit=(X-1-4)(X-12-6)] {};
  \end{scope}

\end{tikzpicture}

\begin{tikzpicture}[
  decision/.style = {
    diamond,
    aspect = 1.5,
    draw,
    fill = gray!20!black,
    text = white,
    text width = 6em,
    text centered,
    inner sep = 1pt},
  block/.style = {
    rectangle,
    draw,
    fill = gray!30!white,
    minimum height = 2em,
    text height = 1.5ex,
    % text depth = 0.25ex,
    text width = 12em,
    text centered,
    rounded corners},
  line/.style = {
    draw,
    -latex',
    line width = 1pt,
    rounded corners}]

  \renewcommand{\baselinestretch}{0.75}

  \node (box1) [block] {Planejamento fatorial $2^k$ com pontos centrais};
  \node (box2) [block, below = 2em of box1] {Testar $H_0: \text{curvatura} = 0$};
  \node (dec1) [decision, below = 2em of box2] {Rejeitou $H_0$?};
  \node (ace) [block, fill = cyan!90!white, below left = 3em of dec1] {Planejar novo experimento};
  \node (rej) [block, fill = orange!90!white, below right = 3em of dec1] {Aumentar planejamento $2^k$};

  \path [line] (box1) -- (box2);
  \path [line] (box2) -- (dec1);
  \path [line] (dec1) -| node [above, pos = 0.25] {n{\~a}o} (ace);
  \path [line] (dec1) -| node [above, pos = 0.25 ] {sim} (rej);

  \node[below = 1ex of ace, align = left] {
    \begin{minipage}{12.5em}
      \begin{flushleft}
        \begin{enumerate}
        \itemsep0em
        \item O modelo linear em $x_i\,\, (i = 1, \ldots, k)$ {\'e} apropriado na regi{\~a}o experimental.
        \item Determinar os termos e fatores relevantes.
        \item Simplificar o modelo se poss{\'\i}vel.
        \item Interpretar o fen{\^o}meno com o modelo obtido.
        \item Obter dire{\c c}{\~a}o para um novo experimento.
        \item Realizar o novo experimento e repetir.
        \end{enumerate}
      \end{flushleft}
    \end{minipage}
  };

  \node[below = 1ex of rej, align = left] {
    \begin{minipage}{12.5em}
      \begin{flushleft}
        \begin{enumerate}
        \itemsep0em
        \item Resultados baseados no modelo linear $x_i\,\, (i = 1, \ldots, k)$ s{\~a}o equivocados.
        \item Aumentar o planejamento com novos pontos de suporte.
        \item Assumir um modelo com termos n{\~a}o lineares em $x_i$, $i = 1, \ldots, k$.
        \item Obter dados e ajustar o modelo.
        \item Interpretar o fen{\^o}meno com o modelo obtido.
        \item Determinar e caracterizar o ponto estacion{\'a}rio.
        \end{enumerate}
      \end{flushleft}
    \end{minipage}
  };

\end{tikzpicture}%

%-----------------------------------------------------------------------
%
% Logo do departamento de Estatística da UFLA · DES. O DES tem o
% programa de pós graduação em Estatística e Experimentação
% Agropecuária.
%
% O logo foi elaborado em parceria com o Prof. Daniel F. Ferreira que
% começou os esboços.  A ideia da normal bivariada é do Prof. Daniel. A
% ideia de adicionar o grafo é minha. A lógica foi de usar a normal
% bivariada para representar a Estatística e o grafo para representar a
% Experimentação Agropecuária.
%
% O grafo é ligação entre os tratamentos do mesmo bloco em um
% delineamento látice reticulado 3 x 3. Neste delineamento são 4
% repetições dos tratamentos (r = 4), cada uma delas com 3 blocos (b =
% 3) de tamanho 3 (v = 3) para acomodar os 9 tratamentos (t = 9). Cada
% par de tratamento ocorre junto uma vez no experimento.
%
%-----------------------------------------------------------------------

%-----------------------------------------------------------------------
%
% library(tidyverse)
%
% # x <- scan()
% # dput(x)
%
% # Os dados do delineamento.
% trt <- c(1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 4, 7, 2, 5, 8, 3, 6, 9, 1, 5, 9,
%          7, 2, 6, 4, 8, 3, 1, 8, 6, 4, 2, 9, 7, 5, 3)
% da <- data.frame(rpt = gl(4, 9),
%                  blc = gl(12, 3),
%                  trt = trt)
% da
%
% # Quebra nas rpt/blc para criar as conex�µes.
% da <- da %>%
%     group_by(rpt, blc) %>%
%     do(con = {
%         x <- t(combn(x = sort(.$trt), m = 2))
%         colnames(x) <- c("from", "to")
%         as.data.frame(x)
%     }) %>%
%     unnest()
%
% # Interpola o verde a azul da criar cores intermedi�¡rias.
% ufla_cols <- colorRampPalette(colors = c("#00793C", "#224271"))(4)
% col_defs <- sprintf("\\definecolor{ufla_color%s}{HTML}{%s}",
%                     LETTERS[seq_along(ufla_cols)],
%                     gsub("#", "", my_cols))
% cat(col_defs, sep = "\n")
%
% # Cria as conex�µes em Tikz.
% txt <- with(da,
%             sprintf("\\path (u%d) edge[bend %s = \\bend, color = %s] (u%d);",
%                     from,
%                     ifelse((to - from) > 4, "left", "right"),
%                     sprintf("ufla_color%s", LETTERS[rpt]),
%                     to))
% cat(txt, sep = "\n")
%
%-----------------------------------------------------------------------
\begin{tikzpicture}%

  % 00793C �© o verde UFLA.
  % 224271 �© o azul UFLA.
  \definecolor{ufla_green}{HTML}{00793C}
  \definecolor{ufla_blue}{HTML}{224271}

  \begin{scope}[
    scale = .5,
    auto = left,
    every node/.style = {circle, fill = black!20}
    ]

    \def\treatments{9}
    \def\theangle{360/\treatments}

    \begin{scope}[rotate = 0.25 * \theangle]

      \foreach \x in {1, ..., \treatments} {
        \coordinate (u\x) at (\x * \theangle:7.5);
        \draw[color = ufla_blue, fill = ufla_green]
        (u\x) circle [radius = 0.9em];
      }

    \end{scope}

    % Reticulado quadrado 3 x 3. Definido no c�³digo R.
    \def\bend{15}

    \definecolor{ufla_colorA}{HTML}{00793C}
    \definecolor{ufla_colorB}{HTML}{0B664D}
    \definecolor{ufla_colorC}{HTML}{16545F}
    \definecolor{ufla_colorD}{HTML}{224271}

    \begin{scope}[
      draw = ufla_blue,
      shorten <= 0.6em,
      shorten >= 0.6em
      ]

      \path (u1) edge[bend right = \bend, color = ufla_colorA] (u2);
      \path (u1) edge[bend right = \bend, color = ufla_colorA] (u3);
      \path (u2) edge[bend right = \bend, color = ufla_colorA] (u3);
      \path (u4) edge[bend right = \bend, color = ufla_colorA] (u5);
      \path (u4) edge[bend right = \bend, color = ufla_colorA] (u6);
      \path (u5) edge[bend right = \bend, color = ufla_colorA] (u6);
      \path (u7) edge[bend right = \bend, color = ufla_colorA] (u8);
      \path (u7) edge[bend right = \bend, color = ufla_colorA] (u9);
      \path (u8) edge[bend right = \bend, color = ufla_colorA] (u9);
      \path (u1) edge[bend right = \bend, color = ufla_colorB] (u4);
      \path (u1) edge[bend left = \bend, color = ufla_colorB] (u7);
      \path (u4) edge[bend right = \bend, color = ufla_colorB] (u7);
      \path (u2) edge[bend right = \bend, color = ufla_colorB] (u5);
      \path (u2) edge[bend left = \bend, color = ufla_colorB] (u8);
      \path (u5) edge[bend right = \bend, color = ufla_colorB] (u8);
      \path (u3) edge[bend right = \bend, color = ufla_colorB] (u6);
      \path (u3) edge[bend left = \bend, color = ufla_colorB] (u9);
      \path (u6) edge[bend right = \bend, color = ufla_colorB] (u9);
      \path (u1) edge[bend right = \bend, color = ufla_colorC] (u5);
      \path (u1) edge[bend left = \bend, color = ufla_colorC] (u9);
      \path (u5) edge[bend right = \bend, color = ufla_colorC] (u9);
      \path (u2) edge[bend right = \bend, color = ufla_colorC] (u6);
      \path (u2) edge[bend left = \bend, color = ufla_colorC] (u7);
      \path (u6) edge[bend right = \bend, color = ufla_colorC] (u7);
      \path (u3) edge[bend right = \bend, color = ufla_colorC] (u4);
      \path (u3) edge[bend left = \bend, color = ufla_colorC] (u8);
      \path (u4) edge[bend right = \bend, color = ufla_colorC] (u8);
      \path (u1) edge[bend left = \bend, color = ufla_colorD] (u6);
      \path (u1) edge[bend left = \bend, color = ufla_colorD] (u8);
      \path (u6) edge[bend right = \bend, color = ufla_colorD] (u8);
      \path (u2) edge[bend right = \bend, color = ufla_colorD] (u4);
      \path (u2) edge[bend left = \bend, color = ufla_colorD] (u9);
      \path (u4) edge[bend left = \bend, color = ufla_colorD] (u9);
      \path (u3) edge[bend right = \bend, color = ufla_colorD] (u5);
      \path (u3) edge[bend right = \bend, color = ufla_colorD] (u7);
      \path (u5) edge[bend right = \bend, color = ufla_colorD] (u7);

    \end{scope}

    % Refer�ªncias.
    % \draw circle [radius = 7.5cm];
    % \draw (-4, 0) -- (4, 0);
    % \draw (0, -4) -- (0, 4);

  \end{scope}

  \begin{scope}[
    xshift = -3.43cm,
    yshift = -2.0cm
    ]

    \begin{axis}[
      domain   = -2.3:2.3,
      domain y = -2.3:2.3,
      view = {-45}{12},
      % xlabel=$\beta_0$,
      % ylabel=$\beta_1$,
      % zlabel={$SSE(\beta_0, \beta_1)$},
      zmin = -0,
      xticklabels = \empty,
      yticklabels = \empty,
      zticklabels = \empty,
      axis lines = none,
      declare function = {mu1 = 0;},
      declare function = {mu2 = 0;},
      declare function = {sigma1 = 1.0;},
      declare function = {sigma2 = 1.0;},
      declare function = {
        bivar(\ma,\sa,\mb,\sb)=
        1/(2*pi*\sa*\sb)*exp(-((x-\ma)^2/\sa^2+(y-\mb)^2/\sb^2))/2;
      }
      ]

      \addplot3 [
      surf,
      % samples = 10,
      samples = 60,
      % opacity = 0.75,
      faceted color = ufla_blue,
      colormap = {blueblack}{
       color = (ufla_blue!80!white)
       color = (ufla_green!80!blue)
       color = (ufla_green!90!blue!10!white)},
      ] {bivar(mu1, sigma1, mu2, sigma2)};

      % Linhas de referencia.
      % \draw (axis cs:-3,  0, 0) -- (axis cs: 3, 0, 0);
      % \draw (axis cs: 0, -3, 0) -- (axis cs: 0, 3, 0);

    \end{axis}

  \end{scope}

  \def\radius{4.25}

  % Contornos de referencia.
  % \draw[gray] circle (\radius);
  % \draw[gray] circle (4.65);

 \path [
  postaction = {
    decorate,
    decoration = {
      raise = -0ex,
      text along path,
      reverse path,
      text align = center,
      text color = ufla_blue,
      text={|\Huge|Departamento de Estat{\'i}stica}
    }
  }] (0:\radius cm) arc (0:180:\radius cm);

  \path [
  postaction = {
    decorate,
    decoration = {
      raise = -2ex,
      text along path,
      reverse path,
      text align = center,
      text color = ufla_blue,
      text={|\Huge|Universidade Federal de Lavras}
    }
  }] (-0:1.02*\radius cm) arc (-0:-180:1.02*\radius cm);

  \node[
  font = \Huge\scshape\bfseries,
  color = ufla_blue,
  text opacity = 1,
  fill opacity = 0.75,
  fill = white,
  rectangle,
  rounded corners = 3pt] at (0.06, -2.72) {DES};

  \draw[white] circle (5);

\end{tikzpicture}%

\begin{tikzpicture}%

  % 00793c % Verde UFLA.
  % 224271 % Azul UFLA.
  \definecolor{ufla_green}{HTML}{00793C}
  \definecolor{ufla_blue}{HTML}{224271}

  \begin{scope}[
    xshift = 3.43cm,
    yshift = 2.0cm,
    scale = .5,
    auto = left,
    every node/.style = {circle, fill = black!20}
    ]

    \def\theangle{60}

    % \foreach \x in {1, ..., 6} {
    % \node[fill = ufla_green] (n\x) at (\x * \theangle:7.5) {};
    % }

    \foreach \x in {1, ..., 6} {
      \coordinate (n\x) at (\x * \theangle:7.5);
      \draw[color = ufla_blue, fill = ufla_green]
      (n\x) circle [radius = 0.9em];
    }

    \foreach \a/\b in {
      n1/n2,
      n1/n3,
      n1/n4,
      n5/n1,
      n6/n1,
      n2/n3,
      n2/n4,
      n2/n5,
      n6/n2,
      n3/n4,
      n3/n5,
      n3/n6,
      n4/n5,
      n4/n6,
      n5/n6} {
      \path[
      draw = ufla_blue,
      shorten <= 0.6em,
      shorten >= 0.6em] (\a) edge[bend right= 15] (\b);
    }

    % \draw circle [radius = 7.5cm];
    % \draw (-4, 0) -- (4, 0);
    % \draw (0, -4) -- (0, 4);

  \end{scope}

  \begin{scope}

    \begin{axis}[
      domain   = -3:3,
      domain y = -3:3,
      view = {-40}{12},
      % xlabel=$\beta_0$,
      % ylabel=$\beta_1$,
      % zlabel={$SSE(\beta_0, \beta_1)$},
      zmin = -0,
      xticklabels = \empty,
      yticklabels = \empty,
      zticklabels = \empty,
      axis lines = none,
      declare function = {mu1 = 0;},
      declare function = {mu2 = 0;},
      declare function = {sigma1 = 0.5;},
      declare function = {sigma2 = 1;},
      declare function = {
        bivar(\ma,\sa,\mb,\sb)=
        1/(2*pi*\sa*\sb)*exp(-((x-\ma)^2/\sa^2+(y-\mb)^2/\sb^2))/2;
      }
      ]

      \addplot3 [
      surf,
      samples = 50,
      % z buffer = sort,
      % z buffer=auto,
      % opacity = 0.75,
      faceted color = ufla_blue,
      colormap = {blueblack}{
        color = (ufla_blue)
        color = (ufla_green!50!white)
        color = (ufla_green)},
      % miter limit = 1,
      ] {bivar(mu1, sigma1, mu2, sigma2)};

      % \addplot3[
      % contour gnuplot = {number = 9, labels = false, draw color = ufla_blue, contour dir=z}
      % ] {bivar(mu1, sigma1, mu2, sigma2)};

      % \draw (axis cs:-3,  0, 0) -- (axis cs: 3, 0, 0);
      % \draw (axis cs: 0, -3, 0) -- (axis cs: 0, 3, 0);

    \end{axis}

  \end{scope}

\end{tikzpicture}%

\def\textangle{3.3}%

\begin{tikzpicture}[
  % scale = 0.5,
  shape1/.style = {
    draw = none, xshift = 0cm,    yshift = 0cm,    scale = 1},
  shape2/.style = {
    draw = none, xshift = 0.44cm, yshift = -0.1cm, scale = 1.26},
  shape3/.style = {
    draw = none, xshift = 0.88cm, yshift = -0.2cm, scale = 1.52}
  ]

  \def\arcs{%
    (0, 0) arc (-21:76:1.8cm and 2.05cm) --
    +(-0.97, -0.78) arc (83:4:2.52cm and 2.1cm)
  }

  % Colors.
  \definecolor{col1}{HTML}{BFB9D1}%
  \definecolor{col2}{HTML}{8072A3}%
  \definecolor{col3}{HTML}{2A0E72}%

  % \node {\includegraphics[width=7cm]{labestData.png}};

  % Help circles and axes.
  % \foreach \a in {0, 120, 240}{
  % \draw [blue, rotate = \a] (0, 0) -- (-0.14, 0.85);
  % \draw [red, rotate = \a] (0, 0) -- (2.06, -1.1);
  % };
  % \draw [red] (0, 0) circle (2.33cm);
  % \draw [blue] (0, 0) circle (0.86cm);

  \begin{scope}[
    xshift = 2.06cm, yshift = -1.1cm
    ]
    \draw [fill = col3, shape3] \arcs;
    \draw [fill = col1, shape2] \arcs;
    \draw [fill = col2, shape1] \arcs;
  \end{scope}

  \begin{scope}[
    rotate around = {120:(0, 0)},
    xshift = 2.06cm, yshift = -1.1cm
    ]
    \draw [fill = col3, shape3] \arcs;
    \draw [fill = col2, shape2] \arcs;
    \draw [fill = col1, shape1] \arcs;
  \end{scope}

  \begin{scope}[
    rotate around = {240:(0, 0)},
    xshift = 2.06cm, yshift = -1.1cm
    ]
    \draw [fill = col1, shape3] \arcs;
    \draw [fill = col2, shape2] \arcs;
    \draw [fill = col3, shape1] \arcs;
  \end{scope}

%   \node at (0,-3.8) {\huge \textcolor{col3}{DEST/UFPR}};

% \draw[
%   draw = none, very thick,
%   postaction = {decorate},
%   decoration = {text along path,
%     text = {|\large|Departamento de Estat{\'i}stica {$\boldsymbol{\cdot}$} UFPR},
%   text align = center,
%   text color = col3}]
%   (180:\textangle) arc [start angle = 180, end angle = 0, radius = \textangle];

\draw[
  draw = none, very thick,
  postaction = {decorate},
  decoration = {text along path,
    text = {|\large|Departamento de Estat{\'i}stica {$\boldsymbol{\cdot}$} UFPR},
  text align = center,
  text color = col3}]
  (180:\textangle+0.3) arc [start angle = -180, end angle = 0, radius = \textangle+0.3];

% \draw[draw = gray] circle (\textangle+0.5);

\end{tikzpicture}%

\begin{tikzpicture}
  % \draw[thick] (0,0) -- (0,5) -- (8,5) -- (8,0) -- (0,0);
  \draw[thick] (0,0) rectangle (8,5);
  \draw[thick, color=darkgreen, fill] (4,2.5) ellipse (2.7cm and 1.7cm);
  \draw[thick] (3,0) .. controls (6,2) and (2,4) .. (4,5);
  \node (n1) at (6,4) {\textcolor{darkgreen}{$A$}};
  \node (n2) at (0.7,2) {$B$};
  \node (n2) at (3,2.5) {$A\cap B$};
  \node (n2) at (5,2.5) {$A\cap B^c$};
  \node (n3) at (7.5,2) {$B^c$};
\end{tikzpicture}

\begin{tikzpicture}
  \draw[thick] (0,0) rectangle (8,5);
  \draw[thick, color=darkgreen, fill] (4,2.5) ellipse (2.7cm and 1.7cm);
  \draw[thick] (0,0) .. controls (1,1) and (3,1) .. (2,5);
  \draw[thick] (0,5) .. controls (1,1) and (3,1) .. (2,0);
  \draw[thick] (3,0) .. controls (2,1) and (4,1) .. (2,5);
  \draw[thick] (4,5) .. controls (2,4) and (4,1) .. (5,0);
  \draw[thick] (4,0) .. controls (3,4) and (4,4) .. (8,0);
  \draw[thick] (5,5) .. controls (3,4) and (4,3) .. (6,0);
  \draw[thick] (7,5) .. controls (7,4) and (8,3) .. (6,0);
  \node (n1) at (6,4) {\textcolor{darkgreen}{$A$}};
  \node (n2) at (0.7,2) {$B_1$};
  \node (n3) at (1,4) {$B_2$};
  \node (n2) at (2.5,2) {$B_3$};
  \node (n3) at (1.5,0.5) {$B_4$};
  \node (n2) at (3.3,0.3) {$B_5$};
  \node (n3) at (4.2,2) {$\cdots$};
  \node (n2) at (7,0.3) {$B_{n-1}$};
  \node (n3) at (7.5,2) {$B_n$};
\end{tikzpicture}

\begin{tikzpicture}[
  scale=0.5,
  mycircle/.style={
    draw, circle, fill=darkgreen, fill opacity=0.5, minimum width=2cm
  }]
  % \draw[help lines] (0,0) grid (8,6);
  \draw (0,0) rectangle (8,6.5);
  \node[mycircle, label={[anchor=north]above right:$A$}] at (5,3) {};
  \node[mycircle, label={[anchor=north]below left:$B$}] at (3,3) {};
  \fill[darkgreen] (2.5,4) circle (3pt) node [above, color=black] {$1$};
  \fill[darkgreen] (2.5,2) circle (3pt) node [above, color=black] {$3$};
  \fill[darkgreen] (5.5,3) circle (3pt) node [above, color=black] {$6$};
  \fill[darkgreen] (4,2.5) circle (3pt) node [above, color=black] {$4$};
  \fill[darkgreen] (4,3.5) circle (3pt) node [above, color=black] {$2$};
  \fill[darkgreen] (3,5.5) circle (3pt) node [above, color=black] {$5$};
\end{tikzpicture}

\def\first{(4,2.5) ellipse (2.7cm and 1.7cm)}
\def\second{
  (0,0) .. controls (1,2) and (3.5,1) .. (2,5) -- (0,5) -- (0,0)}
\begin{tikzpicture}
  \fill[fill=darkgreen!20] \first;
  \begin{scope}
    \clip \first;
    \fill[fill=darkgreen!70] \second;
  \end{scope}
  \node (e1) at (1.85,2.5) {$A_1\cap B$};
  \draw (0,0) rectangle (8,5);
  \draw[color=darkgreen] \first;
  \draw \second;
  \draw (0,5) .. controls (1,1) and (3,1) .. (2,0);
  \draw (3,0) .. controls (2,1) and (4,1) .. (2,5);
  \draw (4,5) .. controls (2,4) and (4,1) .. (5,0);
  \draw (4,0) .. controls (3,4) and (4,4) .. (8,0);
  \draw (5,5) .. controls (3,4) and (4,3) .. (6,0);
  \draw (7,5) .. controls (7,4) and (8,3) .. (6,0);
  \node (n1) at (6,4) {\textcolor{darkgreen}{$B$}};
  \node (n2) at (0.7,2) {$A_2$}; \node (n3) at (1,4) {$A_1$};
  \node (n2) at (2.5,2) {$A_3$}; \node (n3) at (1.5,0.5) {$A_4$};
  \node (n2) at (3.3,0.3) {$A_5$}; \node (n3) at (4.2,2) {$\cdots$};
  \node (n2) at (7,0.3) {$A_{n-1}$}; \node (n3) at (7.5,2) {$A_n$};
\end{tikzpicture}

\begin{tikzpicture}[node distance=0.8cm, scale=0.9]
  \def\evA{(1.8,0) -- (3,5) -- (0,5) -- (0,0)}
  \def\evB{(2,2.5) ellipse (0.7cm and 0.3cm)}
  \draw (0,0) -- (0,5) -- (8,5) -- (8,0) -- (0,0);
  \draw[color=darkgreen, fill=darkgreen!25] \evB;
  \draw \evA;
  \begin{scope}
    \clip \evA;
    \fill[fill=darkgreen!75] \evB;
  \end{scope}
  \node (n1) at (2,3) {\textcolor{darkgreen}{$F$}};
  \node (n2) at (1,4) {$H$} node[below of=n2,
  label={\tiny$P(H)=0.2$}]{};
  \node (n3) at (7,4) {$H^c$} node[below of=n3,
  label={\tiny$P(H^c)=0.8$}]{};
  \node (q1) at (3,1) {$F\cap H$} node[below of=q1,
  label={\tiny$P(F\cap H)=0.02$}]{};
  \node (q2) at (4,2) {$F\cap H^c$} node[below of=q2,
  label={\tiny$P(F\cap H^c)=0.004$}]{};
  \path[->,>=stealth'] (1.4,2.5) edge[bend right] node [left] {}
  (q1.west) (2.4,2.5) edge[bend right] node [left] {} (q2.west);
\end{tikzpicture}

\begin{filecontents*}{temp.dat}
  1   1   100
  2   2   200
  3   3   300
  4   4   400
  5   5   500
  6   6   600
  7   7   700
  8   8   800
  9   9   900
  10  10  1000
\end{filecontents*}

\begin{tikzpicture}
  \begin{axis}[%
    width=4.5in,
    height=3.5in,
    scale only axis,
    xmin=0,
    xmax=10,
    ymin=0,
    ymax=10,
    axis x line*=bottom,
    axis y line*=left]
    \addplot[%
    scatter=true,
    only marks,
    mark=*,
    color=blue,
    point meta=explicit symbolic,
    scatter/@pre marker code/.style={
      /tikz/mark size=\pgfplotspointmeta/50},
    scatter/@post marker code/.style={}
    ] table [meta index=2] {temp.dat};
  \end{axis}
\end{tikzpicture}%

\begin{tikzpicture}[
  declare function = {
    gamma(\z) =
    (2.506628274631*sqrt(1/\z)+0.20888568*(1/\z)^(1.5)+
    0.00870357*(1/\z)^(2.5)-(174.2106599*(1/\z)^(3.5))/25920-
    (715.6423511*(1/\z)^(4.5))/1244160)*exp((-ln(1/\z)-1)*\z);
  },
  declare function = {
    beta(\a,\b) = gamma(\a)*gamma(\b)/gamma(\a+\b);
  },
  declare function = {
    betapdf(\x,\a,\b) = \x^(\a-1)*(1-\x)^(\b-1)/beta(\a,\b);
  }]

  \def\parA{\alpha}
  \def\parB{\beta}
  \def\va{y}

  \begin{axis}[
    width = 9cm, height = 6cm,
    samples = 150,
    xlabel = $\va$, ylabel = $f(\va)$,
    % xlabel style = {at = {(1,0)}, anchor = north west},
    % ylabel style = {rotate = -90, at = {(0,1)}, anchor = south east},
    legend style = {draw = none, fill = none},
    domain = 0.01:0.99,
    % legend pos = outer east,
    legend style = {at = {(0.5,-0.3)}, anchor = north},
    legend cell align = left,
    clip = false]

    \addplot[smooth, thick, black] {betapdf(x, 5, 5)};
    \addlegendentry{$\parA = 5.0$, $\parB = 5.0$};

    \addplot[smooth, thick, cyan] {betapdf(x, .7, .7)};
    \addlegendentry{$\parA = 0.7$, $\parB = 0.7$};

    \addplot[smooth, thick, orange] {betapdf(x, .7, 1.2)};
    \addlegendentry{$\parA = 0.7$, $\parB = 1.2$};

    \addplot[smooth, thick, green] {betapdf(x, 5, 2)};
    \addlegendentry{$\parA = 5.0$, $\parB = 2.0$};

    \node[anchor = south] at (axis description cs: 0.5, 1.05)
    {$f(\va) = \dfrac{\va^{\parA - 1}\cdot(1 - \va)^{\parB - 1}}{
        \mathrm{B}(\parA, \parB)}$};

  \end{axis}
\end{tikzpicture}

\begin{tikzpicture}[
  declare function={
    binompf(\k,\n,\p)=\n!/(\k!*(\n-\k)!)*\p^\k*(1-\p)^(\n-\k);
  },
  hplot/.style={ycomb, mark=o}]

  \begin{axis}[
    width=10cm, height=6cm,
    xlabel=$x$, ylabel=$p(x)$,
    xlabel style={at={(1,0)}, anchor=north west},
    ylabel style={rotate=-90, at={(0,1)}, anchor=south east},
    legend style={draw=none, fill=none, font=\footnotesize},
    legend cell align=left,
    ymax=0.45,
    samples at={0,1,...,30},
    yticklabel style={
      /pgf/number format/fixed,
      /pgf/number format/fixed zerofill,
      /pgf/number format/precision=1
    }]

    \addplot[hplot] {binompf(x, 30, 0.3)};
    \addlegendentry{$n=30$, $p=0.3$}

    \addplot[hplot, red] {binompf(x, 30, 0.7)};
    \addlegendentry{$n=30$, $p=0.7$}

    \addplot[hplot, green] {binompf(x, 30, 0.9)};
    \addlegendentry{$n=30$, $p=0.9$}

    \addplot[hplot, blue, samples at={0,1,...,10}]
    {binompf(x, 10, 0.3)};
    \addlegendentry{$n=10$, $p=0.3$}

    \node at (axis description cs: 0.33, 0.8)
    {$p(x) = \binom{n}{p}\cdot p^x \cdot (1-p)^{n-x} $};

  \end{axis}
\end{tikzpicture}

\begin{tikzpicture}[
  declare function={
    binom(\n,\x)=(\n!)/(\x!*(\n-\x)!);
  },
  declare function={
    bnegpf(\k,\p,\r)=(binom(\k-1, \r-1))*\p^(\r)*(1-\p)^(\k-\r);
  },
  hplot/.style={ycomb, mark=o}]

  \begin{axis}[
    width=10cm, height=6cm,
    xlabel=$x$, ylabel=$p(x)$,
    xlabel style={at={(1,0)}, anchor=north west},
    ylabel style={rotate=-90, at={(0,1)}, anchor=south east},
    legend style={draw=none, fill=none, font=\footnotesize},
    legend cell align=left]

    \addplot[hplot, samples at={1,2,...,21}]
    {bnegpf(x, 0.5, 1)};
    \addlegendentry{$p=0.5$, $r=1$}

    \addplot[hplot, samples at={5,6,...,21}, red]
    {bnegpf(x, 0.5, 5)};
    \addlegendentry{$p=0.5$, $r=5$}

    \addplot[hplot, samples at={5,6,...,21}, blue]
    {bnegpf(x, 0.8, 5)};
    \addlegendentry{$p=0.8$, $r=5$}

    \node at (axis description cs: 0.65, 0.5)
    {$p(x) = \binom{x-1}{r-1} \cdot p^r \cdot (1-p)^{x-r}$};

  \end{axis}
\end{tikzpicture}

\begin{tikzpicture}[
  declare function={
    normalpdf(\x,\mu,\sigma)=
    (2*3.1415*\sigma^2)^(-0.5)*exp(-(\x-\mu)^2/(2*\sigma^2));
  }]

  \def\muA{3}
  \def\muB{6}
  \def\sA{1}
  \def\sB{1}
  \def\k{4.1}
  \def\xmin{-1}
  \def\xmax{10}
  \def\ymin{-0.01}
  \def\ymax{0.43}

  \begin{axis}[
    width=10cm, height=5cm,
    samples=50,
    domain=\xmin:\xmax,
    xlabel=$x$, ylabel=$f(x)$,
    xlabel style={at={(1,0)}, anchor=north west},
    ylabel style={rotate=-90, at={(0,1)}, anchor=south east},
    xticklabels=\empty,
    yticklabels=\empty,
    extra x ticks={\k,\muA,\muB},
    extra x tick labels={\k,\muA,\muB},
    extra tick style={grid=major, color=black, dashed, thick},
    legend style={draw=none, fill=none},
    every axis legend/.append style={at={(0.5,1.03)}, anchor=south}]

    \addplot [smooth] {normalpdf(x,\muA,\sA)};
    \addlegendentry{$\mu_f=\muA$, $\sigma_f=\sA$};
    \addplot [smooth, thick] {normalpdf(x,\muB,\sB)};
    \addlegendentry{$\mu_m=\muB$, $\sigma_m=\sB$};
    \addplot [ycomb, mark=o, samples at={\muA}, dotted]
      {normalpdf(x,\muA,\sA)};
    \addplot [ycomb, mark=o, samples at={\muB}, dotted, blue]
      {normalpdf(x,\muB,\sB)};
  \end{axis}
\end{tikzpicture}

\pgfplotsset{
  myplot/.style={
    width=7cm, height=3.5cm,
    samples=50, domain=0:5, smooth, no marks,
    xlabel=$y$,
    xlabel style={at={(1,0)}, anchor=north west},
    ylabel style={rotate=-90, at={(0,1)}, anchor=south east},
    legend style={draw=none, fill=none},
  }
}

\begin{tikzpicture}[
  >=stealth',
  mypath/.style = {
    draw, shorten <=3pt, shorten >=2pt,
  },
  hplot/.style = {ycomb, mark = o, dashed},
  declare function={
    exppdf(\x,\lambda) = \lambda*exp(-\lambda*\x);
  },
  declare function={
    expcdf(\x,\lambda) = 1-exp(-\lambda*\x);
  }]

  \begin{axis}[myplot, ylabel = $f(y)$, title={\scriptsize Fun{\c c}{\~a}o de densidade de probabilidade}]
    \addplot[domain = 0.35:5, draw=none, fill=blue!40] {exppdf(x,2)} \closedcycle;
    \addplot[color=orange, thick] {exppdf(x,2)};
%     \addlegendentry{$\lambda = 2$};
    \addplot[red, mark = *, only marks] coordinates {(0.35, {exppdf(0.35, 2)})};

    \draw[dotted] (axis cs: 0, {exppdf(0.35,2)}) -- (axis cs: 0.35, {exppdf(0.35,2)});
    \draw[dotted] (axis cs: 0.35, 0) -- (axis cs: 0.35, {exppdf(0.35,2)});
    \path[->, mypath] (axis cs: 0.35, {exppdf(0.35,2)}) to[out = 90, in = 180]
      ++(axis cs: 1, 0.5) node[right] {$f(y)$};
    \path[->, mypath] (axis cs: 0.5, 0.2) to[out = 90, in = 180]
      ++(axis cs: 1, 0.5) node[right] {$1 - F(y)$};
  \end{axis}

  \begin{axis}[myplot, yshift=-3.2cm, ylabel=$F(y)$, legend pos=south east,
    title={\scriptsize Fun{\c c}{\~a}o de distribui{\c c}{\~a}o}]
    \addplot[color=cyan, thick] {expcdf(x,2)};
%     \addlegendentry{$\lambda=2$};
    \addplot[blue, mark = *, only marks] coordinates {(0.35, {expcdf(0.35, 2)})};

    \draw[dotted] (axis cs: 0, {expcdf(0.35,2)}) -- (axis cs: 0.35, {expcdf(0.35,2)});
    \draw[dotted] (axis cs: 0.35, 0) -- (axis cs: 0.35, {expcdf(0.35,2)});
    \path[->, mypath] (axis cs: 0.35, {expcdf(0.35,2)}) to[out = 0, in = 180]
      ++(axis cs: 1, 0) node[right] {$F(y)$};
  \end{axis}

  \begin{axis}[myplot, yshift=-6.4cm, ylabel=$h(y)$, legend pos=south east,
%     ytick distance = 0.1,
%     ytick = {0.45, 0.50, 0.55},
    ymin = 0.35, ymax = 0.65,
    title={\scriptsize Fun{\c c}{\~a}o de risco}]
    \addplot[color=magenta, thick] {1/2};
%     \addlegendentry{$\lambda=2$};
  \end{axis}

\end{tikzpicture}

\pgfplotsset{
  myplot/.style={
    width=7cm, height=6cm,
    samples=50, domain=0:5, smooth, no marks,
    xlabel=$x$,
    xlabel style={at={(1,0)}, anchor=north west},
    ylabel style={rotate=-90, at={(0,1)}, anchor=south east},
    legend style={draw=none, fill=none},
    % title={Distribui\c{c}\~{a}o Exponencial}
  }
}

\begin{tikzpicture}[
  declare function={
    exppdf(\x,\lambda) = \lambda*exp(-\lambda*\x);
  },
  declare function={
    expcdf(\x,\lambda) = 1-exp(-\lambda*\x);
  }]

  \begin{axis}[myplot, ylabel=$f(x)$]
    \addplot[color=black] {exppdf(x,2)};
    \addlegendentry{$\lambda=2$};
    \addplot[color=red] {exppdf(x,1)};
    \addlegendentry{$\lambda=1$};
    \addplot[color=blue] {exppdf(x,0.5)};
    \addlegendentry{$\lambda=\frac{1}{2}$};
    \node[rotate=0] at (axis cs: 3,  0.85)
    {$f(x) = \displaystyle \lambda \text{e}^{-\lambda x}$};
  \end{axis}

  \begin{axis}[myplot, xshift=7cm, ylabel=$F(x)$, legend pos=south east]
    \addplot[color=black] {expcdf(x,2)};
    \addlegendentry{$\lambda=2$};
    \addplot[color=red] {expcdf(x,1)};
    \addlegendentry{$\lambda=1$};
    \addplot[color=blue] {expcdf(x,0.5)};
    \addlegendentry{$\lambda=\frac{1}{2}$};
    \node at (axis cs: 2,  0.1)
    {$F(x) = \displaystyle \lambda \text{e}^{-\lambda x}$};
  \end{axis}

\end{tikzpicture}

\begin{tikzpicture}[
  declare function = {
    gamma(\z) =
    (2.506628274631*sqrt(1/\z)+0.20888568*(1/\z)^(1.5)+
    0.00870357*(1/\z)^(2.5)-(174.2106599*(1/\z)^(3.5))/25920-
    (715.6423511*(1/\z)^(4.5))/1244160)*exp((-ln(1/\z)-1)*\z);
  },
  declare function = {
    gammapdf(\x,\a,\b) = (\b^\a)*\x^(\a-1)*exp(-\b*\x)/gamma(\a);
  }]

  \def\parA{r}
  \def\parB{\lambda}
  \def\va{y}

  \begin{axis}[
    width = 9cm, height = 6cm,
    samples = 150, no marks, smooth,
    xlabel = $y$, ylabel = $f(y)$,
    % xlabel style = {at = {(1,0)}, anchor = north west},
    % ylabel style = {rotate = -90, at = {(0,1)}, anchor = south east},
    legend style = {draw = none, fill = none},
    domain = 0:22,
    clip = false]

    \addplot[black, thick] {gammapdf(x,3,1)};
    \addlegendentry{$\parA = 3, \parB = 1$}

    \addplot[orange, thick] {gammapdf(x,8,1)};
    \addlegendentry{$\parA = 8, \parB = 1$}

    \addplot[cyan, thick] {gammapdf(x,8,2)};
    \addlegendentry{$\parA = 8, \parB = 2$}

    % \node[anchor = east] at (axis description cs: 1,  0.5)
    %   {$f(\va) = \dfrac{\parB^{\parA}}{\Gamma(\parA)}\cdot
    %   \va^{\parA-1} \cdot \exp\{-\parB \va\}$};

    \node[anchor = south] at (axis description cs: 0.5,  1.05)
    {$f(\va) = \dfrac{\parB^{\parA}}{\Gamma(\parA)}\cdot
      \va^{\parA-1} \cdot \exp\{-\parB \va\}$};

  \end{axis}
\end{tikzpicture}

\begin{tikzpicture}[
  declare function={
    binom(\n,\x) = (\n!)/(\x!*(\n-\x)!);
  },
  declare function={
    hiperpf(\x,\N,\n,\K) = binom(\K, \x)*binom(\N-\K, \n-\x)/binom(\N, \n);
  },
  hplot/.style={ycomb, mark=o}]

  \begin{axis}[
    width=10cm, height=6cm,
    xlabel=$x$, ylabel=$p(x)$,
    xlabel style={at={(1,0)}, anchor=north west},
    ylabel style={rotate=-90, at={(0,1)}, anchor=south east},
    legend style={draw=none, fill=none, font=\footnotesize},
    legend cell align=left,
    xtick={0,1,...,10},
    ymax=0.75]

    \addplot[hplot, samples at={0,1,...,10}]
    (x, {hiperpf(x, 20, 10, 10)});
    \addlegendentry{$N=20$, $n=10$, $K=10$}

    \addplot[hplot, samples at={0,1,...,10}, red]
    (x-0.1, {hiperpf(x, 50, 10, 25)});
    \addlegendentry{$N=50$, $n=10$, $K=25$}

    \addplot[hplot, samples at={0,1,...,5}, blue]
    (x+0.1, {hiperpf(x, 50, 10, 5)});
    \addlegendentry{$N=50$, $n=10$, $K=5$}

    \node[anchor=north] at (axis description cs: 0.25, 0.95)
    {$p(x) = \dfrac{\binom{K}{x} \binom{N-k}{n-x}}{\binom{N}{n}}$};

  \end{axis}
\end{tikzpicture}

\begin{tikzpicture}[
  declare function = {
    lognormal(\x,\theta,\omega)=
    exp(-(ln(x)-\theta)^2/(2*\omega^2))/(x*\omega*(2*3.1415)^(-0.5));
  }]

  \def\parA{\theta}
  \def\parB{\omega}
  \def\va{y}

  \begin{axis}[
    width = 9cm, height = 6cm,
    samples = 250, smooth, domain = -0.2:10,
    xlabel = $\va$, ylabel = $f(\va)$,
%     xlabel style = {at = {(1,0)}, anchor = north west},
%     ylabel style = {rotate = -90, at = {(0,1)}, anchor = south east},
    legend style = {draw = none, fill = none},
    clip = false]

    \addplot[black, thick] {lognormal(x, 0, 1)};
    \addlegendentry{$\parA = 0.00, \parB = 1.00$};

    \addplot[cyan, thick] {lognormal(x, 1.25, 0.5)};
    \addlegendentry{$\parA = 1.25, \parB = 0.50$};

    \addplot[orange, thick] {lognormal(x, 0.75, 0.25)};
    \addlegendentry{$\parA = 0.75, \parB = 0.25$};

    \node[anchor = south] at  (axis description cs: 0.5,  1.05)
    {$f(\va) = \displaystyle\frac{1}{\va \parB \sqrt{2 \pi}}
      \exp\left\{-\frac{\left(\ln(\va) - \parA\right)^2}{2 \parB^2}
      \right\}$};
  \end{axis}
\end{tikzpicture}

\begin{tikzpicture}[
  declare function={
    normalpdf(\x,\mu,\sigma)=
    (2*3.1415*\sigma^2)^(-0.5)*exp(-(\x-\mu)^2/(2*\sigma^2));
  },
  hplot/.style={ycomb, mark=o, dashed}]

  \begin{axis}[
    width=8cm,
    height=6cm,
    samples=50,
    xlabel=$y$, ylabel=$f(y)$,
    legend style={draw=none, fill=none},
    domain=-5:5,
    legend cell align=left,
%     xmin=-7, xmax=11
    clip=false]

    \addplot [smooth, thick, fill = cyan, fill opacity=0.3] {normalpdf(x,0,1)}
    node[pos=0.57, pin={[text opacity=1, text width=5em]right:$\mu=0$\\ $\sigma^2=1$}] {};
    \addplot [ycomb, samples at={0}] {normalpdf(x,0,1)};

    \node[anchor=north] at (axis description cs: 0.5,  1.30)
    {$f(y) = \dfrac{1}{\sqrt{2\pi\sigma^2}}\cdot 
      \exp\left\{-\displaystyle\frac{(y-\mu)^2}{2\sigma^2}\right\}$};

  \end{axis}
\end{tikzpicture}\addplot [hplot, samples at={0}] {normalpdf(x,0,1)};
    \addplot [hplot, samples at={0}, blue] {normalpdf(x,0,2)};
    \addplot [hplot, samples at={-2}, red] {normalpdf(x,-2,1)};

    \node[anchor=north east] at (axis description cs: 0.975,  0.95)
    {$f(x) = \dfrac{1}{\sqrt{2\pi\sigma^2}}\cdot 
      \exp\left\{-\frac{(x-\mu)^2}{2\sigma^2}\right\}$};

  \end{axis}
\end{tikzpicture}

\pgfplotsset{
  myplot/.style={
    width=12cm, height=6cm,
    samples=50, smooth, no marks,
    xlabel=$x$, ylabel=$f(x)$,
    xlabel style={at={(1,0)}, anchor=north west},
    ylabel style={rotate=-90, at={(0,1)}, anchor=south east},
    legend style={draw=none, fill=none}
  }
}

\begin{tikzpicture}[
  >=stealth,
  every node/.style={rounded corners},
  declare function={
    normalpdf(\x,\mu,\sigma)=
    (2*pi*\sigma^2)^(-0.5)*exp(-(\x-\mu)^2/(2*\sigma^2));
  },
  hplot/.style={ycomb, mark=o, dashed}]

  \begin{axis}[myplot, xmin=1.1, xmax=2.3]

    \addplot[domain=1.7:1.8, draw=none, fill=darkgreen]
    {normalpdf(x,1.7,0.1)} \closedcycle;
    \addplot[smooth, thick, domain=1.2:2.2]
    {normalpdf(x,1.7,0.1)}
    node[pos=0.35, pin={left:$\mu=1.7$, $\sigma^2=0.1^2$}] {};
    \addplot[hplot, samples at={1.7}] {normalpdf(x,1.7,0.1)};
    
    \node[anchor=north west] at (axis description cs: 0.02, 0.95)
    {$X$: altura de pessoas (m)};

    \coordinate (p0) at (axis cs: 1.75, 1);
    \node[fill=darkgreen, draw=none] (p1)
    at (axis description cs: 0.78, 0.75)
    {\footnotesize $\displaystyle \Pr\left(\frac{1.7-\mu}{\sigma}<
        Z<\frac{1.8-\mu}{\sigma}\right)$};
    \path[o->] (p0) edge[out=45, in=-90] (p1);

  \end{axis}

  \begin{scope}[yshift=-1cm]
    \begin{axis}[
      myplot,
      hide y axis,
      axis x line*=bottom,
      xlabel=$z{\,=\,}\dfrac{x-\mu}{\sigma}$,
      xlabel style={at={(1,0)}, anchor=west},
      domain=-4:4,
      xmin=-6, xmax=6]
      \addplot[draw=none] {x};
    \end{axis}
  \end{scope}

\end{tikzpicture}

\tikzset{
  >=stealth,
  table/.style={
    matrix of nodes,
    nodes={align=center},
    minimum height=1.5em,
    minimum width=1em,
    text depth=0.1ex,
    text height=1.2ex,
    nodes in empty cells,
    column 4/.style={
      nodes={text width=3.5em, fill=gray!20, rounded corners=false}
    },
    row 4/.style={
      nodes={fill=gray!20, rounded corners=false}
    }
  }
}

\pgfplotsset{
  myplot/.style={
    width=9cm, height=5.8cm,
    samples=50, smooth, no marks,
    xlabel style={at={(1,0)}, anchor=north west},
    ylabel style={rotate=-90, at={(0,1)}, anchor=south east},
    legend style={draw=none, fill=none},
    legend pos={north west}
  }
}

\begin{tikzpicture}[
  declare function={
    normalpdf(\x,\mu,\sigma)=
    (2*3.1415*\sigma^2)^(-0.5)*exp(-(\x-\mu)^2/(2*\sigma^2));
  }]

  \begin{scope}[xshift = -1cm, yshift = 0.5cm]
    \begin{axis}[
      myplot,
      domain=-4:4,
      xlabel=$z$, ylabel=$f(z)$,
      ]

      \addplot[domain=0:1.64, draw=none, fill=cyan!50] {normalpdf(x,0,1)} \closedcycle;
      \addplot[thick] {normalpdf(x,0,1)};
      \coordinate (p0) at (axis cs: 0.82, 0.1);
      \node (zval) at (axis cs: 3.2, 0.25) {$z =1.64$};
      \draw[<->] (axis cs: 1.64,  0) |- (zval);
    \end{axis}
  \end{scope}

  \begin{scope}[
    xshift=11cm, yshift=2.9cm,
    every node/.style={rounded corners}
  ]

    \matrix[table, text width=1.5em] (first) {
                   & $\cdots$ & $0.03$ & $0.04$                                   & $\cdots$ \\
      $\vdots$     &          &        &                                          &          \\
      $1.5$        &          &        &                                          &          \\
      $1.6$        &          &        & \node[black, fill = cyan!50]{$0.44950$};   &          \\
      $\vdots$     &          &        &                                          &          \\
    };

   \node (decimal) at (-2, 2) {$1.64 = 1.60 + 0.04$};
   \path[draw, ->] (-2, 1.8) to[out = -120, in = 180] (first-4-1.west);
   \path[draw, ->] (-0.95, 1.8) to[out = -60, in = 90] (first-1-4.north);
   \path[draw, ->] (-3.5, 2) to[out = 180, in = 0] (zval);

    \draw (first-1-2.north west) -- (first-5-2.south west);
    \draw (first-1-1.south west) -- (first-1-5.south east);
    \path[->] (first-1-2.north west) -- (p0);

    \draw[->] (first-1-4) -- (first-3-4.south);
    \draw[->] (first-4-1) -- (first-4-3.east);

    \path[o->] (p0) edge[bend right=25]
     node[below=1pt, fill=cyan!50,
    draw=none, anchor=north west] {$\text{P}(0 < Z < 1.64)$} (first-5-4.120);

  \end{scope}

\end{tikzpicture}%

\begin{tikzpicture}[
  declare function={
    normalpdf(\x,\mu,\sigma)=
    (2*3.1415*\sigma^2)^(-0.5)*exp(-(\x-\mu)^2/(2*\sigma^2));
  },
  hplot/.style={ycomb, mark=o, dashed}]

  \begin{axis}[
    width=12cm, height=6cm,
    samples=50,
    xlabel=$x$, ylabel=$f(x)$,
    xlabel style={at={(1,0)}, anchor=north west},
    ylabel style={rotate=-90, at={(0,1)}, anchor=south east},
    legend style={draw=none, fill=none},
    domain=-6:9,
    legend cell align=left,
    xmin=-7, xmax=11]

    \addplot [smooth, thick] {normalpdf(x,0,1)}
    node[pos=0.47, pin={right:$\mu=0,\sigma^2=1$}] {};
    \addplot [smooth, blue] {normalpdf(x,0,2)}
    node[pos=0.6, pin={45:$\mu=0,\sigma^2=2$}] {};
    \addplot [smooth, red] {normalpdf(x,-2,1)}
    node[pos=0.25, pin={[text centered, text width=8ex]
      200:$\mu=-1$, $\sigma^2=1$}] {};

    \addplot [hplot, samples at={0}] {normalpdf(x,0,1)};
    \addplot [hplot, samples at={0}, blue] {normalpdf(x,0,2)};
    \addplot [hplot, samples at={-2}, red] {normalpdf(x,-2,1)};

    \node[anchor=north east] at (axis description cs: 0.975,  0.95)
    {$f(x) = \dfrac{1}{\sqrt{2\pi\sigma^2}}\cdot 
      \exp\left\{-\frac{(x-\mu)^2}{2\sigma^2}\right\}$};

  \end{axis}
\end{tikzpicture}

\begin{tikzpicture}[
  declare function={
    poispf(\k,\l) = exp(-\l)*(\l^\k)/(\k!);
  },
  hplot/.style={ycomb, mark=o}]

  \begin{axis}[
    width=10cm, height=6cm,
    xlabel=$x$, ylabel=$p(x)$,
    xlabel style={at={(1,0)}, anchor=north west},
    ylabel style={rotate=-90, at={(0,1)}, anchor=south east},
    legend style={draw=none, fill=none, font=\footnotesize},
    legend cell align=left,
    samples at={0,1,...,50},
    yticklabel style={
      /pgf/number format/fixed,
      /pgf/number format/fixed zerofill,
      % /pgf/number format/precision=2
    }]

    \addplot[hplot, black] {poispf(x, 5)};
    \addlegendentry{$\lambda=5$}
    \addplot[hplot, red] {poispf(x, 10)};
    \addlegendentry{$\lambda=10$}
    \addplot[hplot, blue] {poispf(x, 20)};
    \addlegendentry{$\lambda=20$}
    \addplot[hplot, green] {poispf(x, 30)};
    \addlegendentry{$\lambda=30$}

    \node at (axis description cs: 0.5, 0.8)
    {$p(x) = \dfrac{\text{e}^{-\lambda}\cdot \lambda^x}{x!}$};

  \end{axis}
\end{tikzpicture}

% No R:
% x <- c(0,50,100,250,500,1000);
% num <- c(27,9,18,3,6,1);
% den <- 64; px <- num/den
% data.frame(x=x, px=px, PX=cumsum(px),
% f=sprintf("%i/%i", num, den),
% F=sprintf("%i/%i", cumsum(num), den))

\pgfplotsset{
  myplot/.style={
    xlabel=$X$: pr\^emio (\$),
    ylabel=Probabilidade,
    width=10cm, height=7cm,
    mark=*,
    nodes near coords,
    point meta=explicit symbolic, % permite usar a 3 coluna como label.
    every node near coord/.append style={font=\footnotesize},
    nodes near coords align={vertical}
  }
}

\pgfplotstableread{
  i    x       px       PX     f     F
  1    0 0.421875 0.421875 27/64 27/64
  2   50 0.140625 0.562500  9/64 36/64
  3  100 0.281250 0.843750 18/64 54/64
  4  250 0.046875 0.890625  3/64 57/64
  5  500 0.093750 0.984375  6/64 63/64
  6 1000 0.015625 1.000000  1/64 64/64
}\distrprob

\begin{tikzpicture}
  \begin{axis}[
    myplot,
    ymin=-0.03,
    enlarge x limits=0.1,
    enlarge y limits={upper, value=0.2},
    ylabel={Probabilidade, $\Pr(X=x)$},
    title={Distribui\c{c}\~{a}o de probabilidades}]

    \addplot[thick, black, ycomb] table[x=x, y=px, meta=f] \distrprob;
  \end{axis}

  \begin{scope}[xshift=10.5cm]
    \begin{axis}[
      myplot,
      ymin=-0.1,
      enlarge x limits=0.1,
      enlarge y limits={upper, value=0.15},
      ylabel={Probabilidade, $\Pr(X\leq x)$},
      title={Distribui\c{c}\~{a}o de probabilidades acumulada}]

      \addplot[thick, black, const plot, jump mark left]
      table[x=x, y=PX, meta=F] \distrprob;
      \draw[gray] (axis cs: -100, 0) -- (axis cs: 0, 0);
      \draw[gray] (axis cs: 1000, 1) -- (axis cs: 1100, 1);
    \end{axis}
  \end{scope}
\end{tikzpicture}

% http://tex.stackexchange.com/questions/80345/student-t-distribution-with-tikz

\begin{tikzpicture}[
  >=stealth,
  declare function={
    gamma(\z)=
    (2.506628274631*sqrt(1/\z)+0.20888568*(1/\z)^(1.5)+
    0.00870357*(1/\z)^(2.5)-(174.2106599*(1/\z)^(3.5))/25920-
    (715.6423511*(1/\z)^(4.5))/1244160)*exp((-ln(1/\z)-1)*\z);
  },
  declare function={
    student(\x,\n)=
    gamma((\n+1)/2)/(sqrt(\n*pi)*
    gamma(\n/2))*((1+(\x*\x)/\n)^(-(\n+1)/2));
  },
  declare function={
    normalpdf(\x,\mu,\sigma)=
    (2*3.1415*\sigma^2)^(-0.5)*exp(-(\x-\mu)^2/(2*\sigma^2));
  }]

  \begin{axis}[
    width=8cm, height=5cm,
    samples=30,
    xlabel=$t$, ylabel=$f(t)$,
    xlabel style={at={(1,0)}, anchor=north west},
    ylabel style={rotate=-90, at={(0,1)}, anchor=south east},
    legend style={draw=none, fill=none},
    domain=-5:5, xmin=-5.5, xmax=5.5]

    %% Quantil para \nu=5 e \alpha=0.05
    \addplot[domain=2.015:5, draw=none, fill=darkgreen, samples=30]
    {student(x,5)} \closedcycle;

    \addplot[smooth, thick, samples=100] {student(x,5)}
    node[pos=0.55, anchor=mid west, xshift=2em,
    append after command={
      (\tikzlastnode.west) edge [thin, gray] +(-2em,0)}]
    {$\nu=5$};

    \path[<->, draw] (axis cs: 2.015, 0.0) to[out=90, in=-90]
    (axis description cs: 0.82, 0.3) node[above] {$t_{\alpha}=2.0150$};

  \end{axis}
\end{tikzpicture}

% http://tex.stackexchange.com/questions/80345/student-t-distribution-with-tikz

\begin{tikzpicture}[
  declare function={
    gamma(\z)=
    (2.506628274631*sqrt(1/\z)+0.20888568*(1/\z)^(1.5)+
    0.00870357*(1/\z)^(2.5)-(174.2106599*(1/\z)^(3.5))/25920-
    (715.6423511*(1/\z)^(4.5))/1244160)*exp((-ln(1/\z)-1)*\z);
  },
  declare function={
    student(\x,\n)=
    gamma((\n+1)/2)/(sqrt(\n*pi)*
    gamma(\n/2))*((1+(\x*\x)/\n)^(-(\n+1)/2));
  },
  declare function={
    normalpdf(\x,\mu,\sigma)=
    (2*3.1415*\sigma^2)^(-0.5)*exp(-(\x-\mu)^2/(2*\sigma^2));
  }]

  \begin{axis}[
    width=12cm, height=6cm,
    samples=30,
    xlabel=$t$, ylabel=$f(t)$,
    xlabel style={at={(1,0)}, anchor=north west},
    ylabel style={rotate=-90, at={(0,1)}, anchor=south east},
    legend style={draw=none, fill=none},
    domain=-5:5,
    xmin=-5.5, xmax=5.5]

    \addplot[very thick, color=darkgreen, samples=200]
    {normalpdf(x,0,1)} node [pos=0.50, anchor=mid west, xshift=2em,
    append after command={
      (\tikzlastnode.west) edge [thin, gray] +(-2em,0)}]
    {$\text{Normal}(0,1)$};

    \pgfplotsinvokeforeach{1,5,50}{
      \addplot[thin, samples=200] {student(x,#1)}
      node [pos=0.55, anchor=mid west, xshift=2em,
      append after command={
        (\tikzlastnode.west) edge [thin, gray] +(-2em,0)}]
      {$\nu=#1$};
    }

    \pgfplotsinvokeforeach{2,30}{
      \addplot[thin, samples=200] {student(x,#1)}
      node [pos=0.45, anchor=mid east, xshift=-2em,
      append after command={
        (\tikzlastnode.east) edge [thin, gray] +(2em,0)}]
      {$\nu=#1$};
    }
    
  \end{axis}
\end{tikzpicture}

\pgfplotsset{
  myplot/.style={
    width=7cm, height=6cm,
    samples=10, domain=0:5, no marks,
    xlabel=$x$,
    xlabel style={at={(1,0)}, anchor=north west},
    ylabel style={rotate=-90, at={(0,1)}, anchor=south east},
    legend style={draw=none, fill=none},
    % title={Distribui\c{c}\~{a}o Exponencial}
  }
}

\begin{tikzpicture}[
  declare function={
    unifpdf(\x,\a,\b) = 1/(\b-\a);
  },
  declare function={
    unifcdf(\x,\a,\b) =
    0+(\x>=\a)*(\x<=\b)*(\x-\a)/(\b-\a)+1*(\x>\b);
  }]

  \begin{axis}[
    myplot,
    ymax=1.1, ymin=-0.1,
    ylabel=$f(x)$]

    \addplot[smooth, domain=0:3]
    {unifpdf(x,0,3)};
    \addlegendentry{$a=0$, $\hphantom{-}b=2$};

    \addplot[smooth, domain=-1:1, color=red]
    {unifpdf(x,-1,1)};
    \addlegendentry{$a=-1$, $b=1$};

    \addplot[ycomb, mark=o, samples at={0,3}, dashed]
    {unifpdf(x,0,3)};
    \addplot[ycomb, mark=o, samples at={-1,1}, dashed, color=red]
    {unifpdf(x,-1,1)};

    \node at (axis cs: -0.15,  0.65)
    {$f(x) = \displaystyle \frac{1}{b-a}$};

  \end{axis}

  \begin{axis}[
    myplot, xshift=7cm,
    samples=10,
    ylabel=$F(x)$]

    \addplot [samples at={-1.5,0,3,3.2}]
    {unifcdf(x,0,3)};
    \addplot [samples at={-1.5,-1,1,3.2}, color=red]
    {unifcdf(x,-1,1)};

    \node at (axis cs: 2,  0.15)
    {$F(x) = \displaystyle \frac{x-a}{b-a}$};

  \end{axis}
\end{tikzpicture}

\begin{tikzpicture}[
  declare function={
    unifdispf(\k,\n)=1/\n;
  },
  hplot/.style={ycomb, mark=o}]

  \begin{axis}[
    width=8cm, height=6cm,
    xlabel=$x$, ylabel=$p(x)$,
    xlabel style={at={(1,0)}, anchor=north west},
    ylabel style={rotate=-90, at={(0,1)}, anchor=south east},
    legend style={draw=none, fill=none, font=\footnotesize},
    legend cell align=left,
    ymin=-0.02, ymax=0.25,
    xtick={1,2,...,10},
    ytick={0, 0.1, 0.166},
    yticklabels={0,$\frac{1}{10}$,$\frac{1}{6}$}]

    \addplot[hplot, samples at={1,2,...,6}]
      (x-0.07, {unifdispf(x, 6)});
    \addlegendentry{$n=6$};
    \addplot[hplot, samples at={1,2,...,10}, red]
      (x+0.07, {unifdispf(x, 10)});
    \addlegendentry{$n=10$};
    \node at (axis description cs: 0.5, 0.85) {$p(x) = \frac{1}{n}$};
  \end{axis}
\end{tikzpicture}

\begin{tikzpicture}[
  declare function = {
    weibullpdf(\x,\a,\b) = (\b/\a)*(\x/\a)^(\b-1)*exp(-(\x/\a)^(\b));
  }]

  \def\parA{\delta}
  \def\parB{\beta}
  \def\va{y}

  \begin{axis}[
    width = 9cm, height = 6cm,
    samples = 50, smooth, domain = 0:5,
    xlabel = $\va$, ylabel = $f(\va)$,
    % xlabel style = {at = {(1,0)}, anchor = north west},
    % ylabel style = {rotate = -90, at = {(0,1)}, anchor = south east},
    legend style = {draw = none, fill = none},
    clip = false]

    \addplot[black, thick] {weibullpdf(x, 1, 1)};
    \addlegendentry{$\parA = 1, \parB = 1$};

    \addplot[cyan, thick] {weibullpdf(x, 3, 6)};
    \addlegendentry{$\parA = 3, \parB = 6$};

    \addplot[orange, thick] {weibullpdf(x, 2, 3)};
    \addlegendentry{$\parA = 2, \parB = 3$};

    \node[anchor = south] at (axis description cs: 0.5, 1.05)
      {$f(\va) = \displaystyle\frac{\parB}{\parA}\left(
          \frac{\va}{\parA} \right)^{\parB - 1}
      \exp\left\{-\left(\frac{\va}{\parA} \right)^{\parB} \right\}$};
  \end{axis}
\end{tikzpicture}

\pgfplotsset{
  myplot/.style={
    width=12cm, height=6cm,
    xlabel=$x$, ylabel=$f(x)$,
    samples=50,
    xlabel style={at={(1,0)}, anchor=north west},
    ylabel style={rotate=-90, at={(0,1)}, anchor=south east},
    legend style={draw=none, fill=none},
  }
}

\begin{tikzpicture}[>=stealth,
  every node/.style={rounded corners},
  declare function={
    normalpdf(\x,\mu,\sigma)=
    (2*3.1415*\sigma^2)^(-0.5)*exp(-(\x-\mu)^2/(2*\sigma^2));
  }]

  \begin{axis}[myplot]
    % `forget plot` evita que seja feita legenda.
    % \addplot[domain=1.6:1.8, draw=none, fill=gray!10!darkgreen, fill
    % opacity=0.5, forget plot]
    % {normalpdf(x,1.7,0.0276)} \closedcycle;

    \addplot[smooth, thick, domain=1.3:2.1]
    {normalpdf(x,1.7,0.1)};
    \addlegendentry[align=center]{$\sigma^2=0.1^2$}

    \addplot[smooth, thick, domain=1.3:2.1, color=darkgreen]
    {normalpdf(x,1.7,0.0276)};
    \addlegendentry[align=center]{$\sigma^2_{\bar{X}}=\frac{0.1^2}{10}$}

    \node[anchor=north west] at (axis description cs: 0.02, 0.95)
    {$X$: altura (m), $\mu=1.7$.};
    \node[anchor=north west, text width=3.5cm]
    at (axis description cs: 0.02, 0.83)
    {$\bar{X}$: altura m\'{e}dia (m), $n=10$.};
  \end{axis}

  % z-axis.
  \begin{scope}[yshift=-1cm, xshift=3.75cm]
    \begin{axis}[myplot,
      width=4.5cm, height=2cm,
      hide y axis,
      axis x line*=bottom,
      xlabel=$z{\,=\,}\dfrac{\bar{x}-\mu}{\sigma/\sqrt{n}}$,
      domain=-4:4]
      \addplot[draw=none] {x};
    \end{axis}
  \end{scope}
\end{tikzpicture}

\pgfplotsset{
  myplot/.style={
    width=12cm, height=6cm,
    xlabel=$z$, ylabel=$f(z)$,
    samples=50,
    xlabel style={at={(1,0)}, anchor=west},
    ylabel style={rotate=-90, at={(0,1)}, anchor=south west},
    legend style={draw=none, fill=none},
    xmin=-4.5, xmax=4.5
  }
}

\begin{tikzpicture}[>=stealth,
  every node/.style={rounded corners},
  declare function={
    normalpdf(\x,\mu,\sigma)=
    (2*3.1415*\sigma^2)^(-0.5)*exp(-(\x-\mu)^2/(2*\sigma^2));
  }]

  \begin{axis}[myplot]

    \addplot[smooth, domain=-4:-1.65, draw=none, fill=darkgreen]
    {normalpdf(x,0,1)} \closedcycle;
    \addplot[smooth, domain=-4:-1.88, draw=none, fill=red!70!blue]
    {normalpdf(x,0,1)} \closedcycle;
    \addplot[smooth, domain=4:1.28, draw=none, fill=darkgreen!30!yellow]
    {normalpdf(x,0,1)} \closedcycle;
    \addplot[smooth, domain=4:1.47, draw=none, fill=red!70!blue]
    {normalpdf(x,0,1)} \closedcycle;
    \addplot[smooth, domain=4:1.65, draw=none, fill=darkgreen]
    {normalpdf(x,0,1)} \closedcycle;

    \addplot[smooth, thick, domain=-4:4] {normalpdf(x,0,1)};

    \path[<->, draw] (axis cs: -1.65,0) to[out=90, in=0]
    (axis description cs: 0.25,0.4) node[left] {$-z_{5\%}$};
    \path[<->, draw] (axis cs: 1.65,0) to[out=90, in=180]
    (axis description cs: 0.75,0.3) node[right] {$z_{5\%}$};

    \path[<->, draw] (axis cs: -1.88,0) to[out=90, in=0]
    (axis description cs: 0.25,0.3) node[left] {$-z_{3\%}$};
    \path[<->, draw] (axis cs: 1.47,0) to[out=90, in=180]
    (axis description cs: 0.75,0.4) node[right] {$z_{7\%}$};
    \path[<->, draw] (axis cs: 1.28,0) to[out=90, in=180]
    (axis description cs: 0.75,0.5) node[right] {$z_{10\%}$};

    \node at (axis description cs: 0.5,0.3) {$90\%$};

  \end{axis}
\end{tikzpicture}

\pgfplotsset{
  myplot/.style={
    width=15cm, height=6cm,
    xlabel=$z$, ylabel=$f(z)$,
    samples=50,
    xlabel style={at={(1,0)}, anchor=west},
    ylabel style={rotate=-90, at={(0,1)}, anchor=south west},
    legend style={draw=none, fill=none},
    xmin=-4.5, xmax=4.5
  }
}%

\begin{tikzpicture}[>=stealth,
  every node/.style={rounded corners},
  declare function={
    normalpdf(\x,\mu,\sigma)=
    (2*3.1415*\sigma^2)^(-0.5)*exp(-(\x-\mu)^2/(2*\sigma^2));
  }]

  \begin{axis}[myplot, height=5cm]

    \addplot[smooth, domain=-3:3, draw=none, fill=cyan!40] {normalpdf(x, 0, 1)} \closedcycle;
    \addplot[smooth, domain=-2:2, draw=none, fill=cyan!25] {normalpdf(x, 0, 1)} \closedcycle;
    \addplot[smooth, domain=-1:1, draw=none, fill=cyan!10] {normalpdf(x, 0, 1)} \closedcycle;
    \addplot[smooth, thick, domain=-4:4] {normalpdf(x, 0, 1)};
    \addplot [ycomb, samples at={0}, color = cyan, thick] {normalpdf(x,0,1)};

  \end{axis}

  \begin{scope}[yshift=-3.5cm]
    \begin{axis}[
      myplot,
      hide y axis,
      height=4.5cm,
      axis x line*=bottom,
      xlabel = ,
      xtick = {-3, -2, -1, 0, 1, 2, 3},
      xticklabels = {$\mu -3\sigma$, $\mu - 2\sigma$, $\mu -1\sigma$, $\mu$, $\mu + 1\sigma$, $\mu + 2\sigma$, $\mu + 3\sigma$},
      domain=-4:4, ymin = -0.05, ymax = 0.3]

      \addplot[draw=none] {x};
    \draw[|<->|] (axis cs: -1, 0.20) -- (axis cs: 1, 0.20) node [above, midway] {$\text{P}(-1 < Z < 1) \approx 0.6826$};
    \draw[|<->|] (axis cs: -2, 0.10) -- (axis cs: 2, 0.10) node [above, midway] {$\text{P}(-2 < Z < 2) \approx 0.9546$};
    \draw[|<->|] (axis cs: -3, 0.00) -- (axis cs: 3, 0.00) node [above, midway] {$\text{P}(-3 < Z < 3) \approx 0.9973$};

    \end{axis}
  \end{scope}

\end{tikzpicture}%

\def\zright{1.645}%
\def\muzero{0}%
\def\muone{-1.95}%
\pgfplotsset{%
  myplot/.style={
    width=12cm,
    height=6cm,
%     xlabel=$z$, ylabel=$f(z)$,
    samples=50,
    legend style={draw=none, fill=none},
  }%
}%
\begin{tikzpicture}[%
  >=stealth,
  every node/.style={rounded corners},
  Red/.style={
    draw=none, text opacity=1, fill=red!70!blue, fill opacity=0.75
  },
  declare function={
    normalpdf(\x,\mu,\sigma)=
    (2*3.1415*\sigma^2)^(-0.5)*exp(-(\x-\mu)^2/(2*\sigma^2));
  }]

  \begin{axis}[myplot, hide axis]
    \addplot[Red, draw, smooth, thick, domain=-4:4]
      {normalpdf(x,0,1)};
  \end{axis}
\end{tikzpicture}%

\begin{tikzpicture}[
  declare function = {
    weibullpdf(\x,\a,\b) = (\b/\a)*(\x/\a)^(\b-1)*exp(-(\x/\a)^(\b));
  },
  declare function = {
    normalpdf(\x,\mu,\sigma)=
    (2*3.1415*\sigma^2)^(-0.5)*exp(-(\x-\mu)^2/(2*\sigma^2));
  }]

  \def\va{y}

  \begin{axis}[
    width = 9cm, height = 6cm,
    samples = 50, smooth, domain = 0:14,
    xmin = -3, xmax = 15,
    ymax = 0.45, ymin = -0.1,
    ticks = none,
    % xlabel = $\va$, ylabel = $f(\va)$,
    % xlabel style = {at = {(1,0)}, anchor = north west},
    % ylabel style = {rotate = -90, at = {(0,1)}, anchor = south east},
    legend style = {draw = none, fill = none}, clip = false]

    \addplot +[mark = none, color = black] coordinates {(6, 0) (6, 0.35)} node[above] {$\theta$};

    \addplot[cyan, thick] {weibullpdf(x, 7, 6)};
    \addplot[domain = 0:4, fill = cyan, fill opacity = 0.5, draw = none, thick] {weibullpdf(x, 7, 6)} \closedcycle;
    \addplot[domain = 8.5:15, fill = cyan, fill opacity = 0.5, draw = none, thick] {weibullpdf(x, 7, 6)} \closedcycle;
    \addplot [ycomb, samples at={6.5}, cyan] {weibullpdf(x, 7, 6)};
    \draw[|-|, cyan] (axis cs: 4, -0.02) -- (axis cs: 8.5, -0.02);

    \addplot[orange, thick] {weibullpdf(x, 5, 3)};
    \addplot[domain = 0:1.5, fill = orange, fill opacity = 0.5, draw = none, thick] {weibullpdf(x, 5, 3)} \closedcycle;
    \addplot[domain = 7.5:15, fill = orange, fill opacity = 0.5, draw = none, thick] {weibullpdf(x, 5, 3)} \closedcycle;
    \addplot [ycomb, samples at={4.25}, orange] {weibullpdf(x, 5, 3)};
    \draw[|-|, orange] (axis cs: 1.5, -0.04) -- (axis cs: 7.5, -0.04);

    \addplot [smooth, thick, color = magenta, domain = -2:14] {normalpdf(x, 6, 2)};
    \addplot[domain = -2:2, fill = magenta, fill opacity = 0.5, draw = none, thick] {normalpdf(x, 6, 2)} \closedcycle;
    \addplot[domain = 10:15, fill = magenta, fill opacity = 0.5, draw = none, thick] {normalpdf(x, 6, 2)} \closedcycle;
    \addplot [ycomb, samples at={6}, magenta] {normalpdf(x, 6, 2)};
    \draw[|-|, magenta] (axis cs: 2, -0.06) -- (axis cs: 10, -0.06);

  \end{axis}
\end{tikzpicture}%------------------------------------------------------

\def\xs{1}
\def\ys{10}

\begin{tikzpicture}[xscale=\xs, yscale=\ys, >=latex]
  % definicoes dos valores dos parametros e outras quantidades
  \def\al{1.3}
  \def\all{0.5}
  \def\n{1.6}
  \def\nn{1.9}

  % grid, eixos e anotacoes
  \draw[very thin,color=gray!30] (-3-0.2/\xs,0-0.2/\ys)
    grid[xstep=0.5, ystep=0.05] (5+0.2/\xs,0.4+0.2/\ys);
  \draw[->, line width=1pt] (-3,0) -- (5.25,0) node[below] {$r$};
  \draw[->, line width=1pt] (-3,0) -- (-3,0.43) node[left] {$f(r)$};
  \node[left] at (-3,0) {$0$};

  % funcoes
  \draw[color=darkgreen, thick, smooth] plot[id=x, domain=-3:5]
    function{\n*(1-1/\n)*\al**\n*exp(\n*x)*
      (1+(\al*exp(x))**\n)**(-1+1/\n-1)};
  \draw[color=red!30!black, thick, smooth] plot[id=x, domain=-3:5]
    function{\nn*(1-1/\nn)*\all**\nn*exp(\nn*x)*
      (1+(\all*exp(x))**\nn)**(-1+1/\nn-1)};

  % textos
  \path[->, draw] (-0.5,0.2) to[out=180, in=0] ++(-0.75,0.05)
    node[anchor=east, text ragged left, text width=9ex,
    fill=white, inner sep=0pt]
    {antes do manejo};
  \path[->, draw] (2,0.25) to[out=0, in=180] ++(0.75,0.05)
    node[anchor=west, text ragged, text width=8ex,
    fill=white, inner sep=0pt]
    {ap\'os o manejo};
\end{tikzpicture}  

\definecolor{emacsroxo}{HTML}{5854A8}
\definecolor{emacsazul}{HTML}{00003D}

\fontfamily{iwonalc} %% iwona ligth condensed
\changefontsizes[11pt]{8pt}
\renewcommand{\baselinestretch}{0.85}
\newcommand{\cc}{\cellcolor[gray]{0.9}}
\newcommand{\mc}[3]{\multicolumn{#1}{#2}{\cc #3}}
\newcommand{\md}[3]{\multicolumn{#1}{#2}{#3}}

\tikzset{
  mybox/.style={
    draw=emacsroxo, thick, rectangle,
    fill=gray!40,
    rounded corners=3pt, inner sep=0pt, inner ysep=1pt,
    anchor=north west
  },
  fancytitle/.style={
    fill=emacsroxo, text=white,
    %% text width=0.5*\d,
    minimum width=1.2cm, minimum height=1.5em,
    rounded corners=3pt, left=5pt
  },
  bx/.style={draw}
}

\begin{tikzpicture}[node distance=0.3cm, scale=1]
  \def\d{3.5cm}
  \def\cred{%
    \begin{minipage}{\d}
      \begin{center}
        \includegraphics[width=2.2cm]{/home/walmes/Dropbox/tikz/mugs/carbon-emacs-icon.png}\\
        {\Large \textbf{Caneca Emacs}}\\
        por \textit{Walmes Zeviani}\\
        \textcolor{emacsazul}{\texttt{github.com/walmes/emacs}}
      \end{center}
    \end{minipage}
  }
  \def\ajuda{%
    \begin{minipage}{\d}
      \begin{tabular}{ll}\vspace{-6pt}            \\
        % {\tt F1}     & Ajuda                    \\
        {\tt M-x} help & Ajuda                    \\
        {\tt F1 a}     & \`{A} prop\'{o}sito      \\
        {\tt F1 b}     & Atalhos                  \\
        {\tt F1 c}     & A\c{c}\~{a}o do atalho   \\
        {\tt F1 f}     & Descrever fun\c{c}\~{a}o \\
      \end{tabular}
    \end{minipage}
  }
  \def\arquivo{%
    \begin{minipage}{\d}
      \begin{tabular}{ll}\vspace{-6pt}                 \\
        % {\tt C-x C-f} & Abrir                        \\
        % {\tt C-x C-s} & Salvar                       \\
        % {\tt C-x C-w} & Salvar como                  \\
        \md{2}{l}{\tt C-x C-<fsw>}                     \\
        \md{2}{l}{Abrir, salvar, salvar como}          \\
        \md{2}{l}{{\tt M-x} dired ~ Abrir diret\'orio} \\
      \end{tabular}
    \end{minipage}
  }
  \def\book{
    \begin{minipage}{\d}
      \begin{tabular}{ll}\vspace{-3pt}                \\
        % {\tt C-x r m} & Definir                     \\
        % {\tt C-x r b} & Ir para                     \\
        % {\tt C-x r l} & Listar                      \\
        \md{2}{l}{\tt M-x r <mbl>}                    \\
        \md{2}{l}{Definir, ir para, listar}           \\
        \md{2}{l}{{\tt M-x} bookmark-delete~~Deletar} \\
      \end{tabular}
    \end{minipage}
  }
  \def\area{%
    \begin{minipage}{\d}
      \begin{tabular}{ll}\vspace{-3pt}                  \\
        {\tt S-delete}    & Recortar                    \\
        {\tt C-insert}    & Copiar                      \\
        {\tt S-insert}    & Colar                       \\
        \md{2}{l}{{\tt C-S-backspace}  ~Recortar linha} \\
        \md{2}{l}{{\tt C-</\_>} ~~ Desfazer, Refazer}   \\
        {\tt C-x r s <c>} & Armazenar em                \\
        {\tt C-x r i <c>} & Inserir                     \\
      \end{tabular}
    \end{minipage}
  }
  \def\retangulos{
    \begin{minipage}{\d}
      \begin{tabular}{ll}\vspace{-3pt}   \\
        {\tt C-x r k}     & Recortar     \\
        % {\tt C-x r M-w} & Copiar       \\ %% nao existe copiar retangulo
        {\tt C-x r y}     & Colar        \\
        {\tt C-x r r <c>} & Armazenar em \\
        {\tt C-x r i <c>} & Inserir      \\
        \md{2}{l}{\tt C-x r <ocdt>}      \\
        \md{2}{l}{Abrir, limpar, deletar, preceder}
      \end{tabular}
    \end{minipage}
  }
  \def\formatacao{
    \begin{minipage}{\d}
      \begin{tabular}{ll}\vspace{-3pt}         \\
        {\tt M-q}              & Acomodar      \\
        {\tt C-M-$\backslash$} & Indentar      \\
        {\tt C-77 -}           & 77 tra\c{c}os \\
        {\tt M-;}              & Comentar      \\
        {\tt M-x align}        & Alinhar       \\
      \end{tabular}
    \end{minipage}
  }
  \def\orto{
    \begin{minipage}{\d}
      \begin{tabular}{ll}\vspace{-3pt}\\
        {\tt M-\$}              & Palavra             \\
        {\tt M-x} ispell-region & Regi\~ao              \\
        {\tt M-x} ispell-buffer & Buffer              \\
        \md{2}{l}{{\tt M-x} ispell-change-dictionary} \\
        \md{2}{l}{{\tt M-x} flyspell-mode}            \\
      \end{tabular}
    \end{minipage}
  }
  \def\movi{
    \begin{minipage}{\d}
      \begin{tabular}{ll}\vspace{-3pt}                                                 \\
        {\tt M-g g}                       & Ir linha                                   \\
        % \md{2}{l}{{\tt M-x} goto-char ~~Ir coluna}                                   \\
        \md{2}{l}{{\tt C-l} ~~Cursor ao centro/bordas}                                 \\
        \md{2}{l}{{\tt C-<ae>} ~~Ir paragr\'afo $\blacktriangle$ $\blacktriangledown$} \\
        {\tt C-x C-$\blacktriangleright$} & Pr\'oximo buffer                           \\
        {\tt C-x C-$\blacktriangleleft$}  & Buffer anterior                            \\
        {\tt C-x o}                       & Passar o cursor                            \\
        {\tt C-x C-b}                     & Listar buffers                             \\
        {\tt C-x k}                       & Fechar buffer                              \\
      \end{tabular}
    \end{minipage}
  }
  \def\busca{
    \begin{minipage}{\d}
      \begin{tabular}{ll}\vspace{-3pt}                                           \\
        {\tt M-s o}    & Listar ocorr\^encias                                    \\
        \md{2}{l}{~~~\tt C-c C-f, M-<pn>  $\blacktriangle$ $\blacktriangledown$} \\ 
        {\tt C-<rs>}   & Para $\blacktriangle$ $\blacktriangledown$              \\
        {\tt C-M-<rs>} & Regex $\blacktriangle$ $\blacktriangledown$             \\
        % \md{2}{l}{{\tt M-x} (un)highlight-regexp}                              \\
        \md{2}{l}{{\tt M-x} delete-(non-)matching-lines}                         \\
      \end{tabular}
    \end{minipage}
  }
  \def\subist{
    \begin{minipage}{\d}
      \begin{tabular}{ll}\vspace{-3pt}     \\
        {\tt M-\%}   & Buscar e substituir \\
        {\tt C-M-\%} & Com regex           \\ %\hline
      \end{tabular}
    \end{minipage}
  }
  \def\janelas{
    \begin{minipage}{\d}
      \begin{tabular}{ll}\vspace{-3pt}       \\
        {\tt C-x 1}   & Manter a atual       \\
        {\tt C-x 2}   & Divis\~ao horizontal \\
        {\tt C-x 3}   & Divis\~ao vertical   \\
        {\tt C-x 0}   & Remover divis\~ao    \\
        {\tt C-x 5 2} & Janela flutuante     \\
      \end{tabular}
    \end{minipage}
  }
  \def\sessaor{
    \begin{minipage}{\d}
      \begin{tabular}{ll}\vspace{-3pt}             \\
        \md{2}{l}{{\tt C-c C-<jnprfb>} ~~ Avaliar} \\
        \md{2}{p{3.5cm}}{Linha, linha e descer, par\'agrafo, regi\~ao, fun\c{c}\~ao,
        buffer}                                    \\
      % {\tt C-c C-j} & Linha                      \\
      % {\tt C-c C-n} & Linha e descer             \\
      % {\tt C-c C-p} & Par\'agrafo                \\
      % {\tt C-c C-r} & Regi\~ao                   \\
      % {\tt C-c C-f} & Fun\c{c}\~ao               \\
      \end{tabular}
    \end{minipage}
  }
  \def\sessaornw{
    \begin{minipage}{\d}
      \begin{tabular}{lp{2cm}}\vspace{-3pt}                                  \\
        % {\tt M-n C-p}  & Chunk acima                                       \\
        % {\tt M-n C-n}  & Chunk abaixo                                      \\
        {\tt M-n C-<pn>} & Ir ao chunk $\blacktriangle$ $\blacktriangledown$ \\
        {\tt M-n g}      & Ir para chunk                                     \\
        {\tt M-n C-M-x}  & Avaliar chunk                                     \\
        {\tt M-n C-c}    & Chunk e descer                                    \\
        {\tt M-n <sTP>}  & Sweave, Tangle, \newline pdflatex                 \\
        % {\tt M-n <ru>} & knit, purl \newline (*ess-knitr.el)               \\
      \end{tabular}
    \end{minipage}
  }
  \def\sessaolatex{
    \begin{minipage}{\d}
      \begin{tabular}{ll}\vspace{-3pt}                                           \\
        % {\tt C-c C-m}   & Inserir macro                                        \\
        % {\tt C-c C-e}   & Inserir ambiente                                     \\
        % {\tt C-c C-j}   & Inserir \verb|\item|                                 \\
        \md{2}{l}{{\tt C-c C-<mesi>} ~~Inserir}                                  \\
        \md{2}{l}{Macro, ambiente, sess\~ao, $\backslash{}$\texttt{item}}        \\
        {\tt C-c ]}       & Fechar ambiente                                      \\
        {\tt C-c C-c}     & Compilar                                             \\
        {\tt M-g <pn>}    & Ir para o erro $\blacktriangle$ $\blacktriangledown$ \\
      \end{tabular}
      \begin{tabular}{ll}
        \md{2}{l}{{\tt C-c C-f C-<bit>} ~~Fonte}                                 \\
        \md{2}{l}{\textbf{negrito}, \textit{it\'alico}, \texttt{monoespa\c{c}o}} \\
        \md{2}{l}{{\tt C-c C-q C-<rep>} ~~Formatar}                              \\
        \md{2}{l}{Regi\~ao, ambiente, par\'agrafo}                               \\
        {\tt C-c C-o C-f} & Modo esconder                                        \\
        \md{2}{l}{{\tt C-c C-o C-<repo>} ~~Esconder}                             \\
        \md{2}{l}{Regi\~ao, ambiente, par\'agrafo, item}                         \\
        \md{2}{l}{{\tt C-c C-o <repi>} ~~Mostrar}                                \\
        \md{2}{l}{Regi\~ao, ambiente, par\'agrafo, item}                         \\
      \end{tabular}
    \end{minipage}
  }
  \def\reftex{
    \begin{minipage}{\d}
      \begin{tabular}{ll}\vspace{-3pt}       \\
        {\tt C-c =}  & Navegar no sum\'ario  \\
        {\tt C-c (}  & Criar r\'otulo        \\
        {\tt C-c )}  & Inserir refer\^encia  \\
        {\tt C-c [}  & Inserir cita\c{c}\~ao \\
        {\tt C-c \&} & Ver refer\^encias     \\
      \end{tabular}
    \end{minipage}
  }
  \def\trans{
    \begin{minipage}{\d}
      \begin{tabular}{ll}\vspace{-3pt}                       \\
        \md{2}{l}{{\tt C-t} Caracteres ~ {\tt M-t} Palavras} \\
        {\tt C-x C-t} & Linhas                               \\
        \md{2}{l}{{\tt M-x} reverse-region}                  \\
      \end{tabular}
    \end{minipage}
  }
  \def\extra{
    \begin{minipage}{\d}
      \begin{tabular}{ll}\vspace{-3pt}    \\
        {\tt M-x tetris}   & Tetris       \\
        {\tt M-x calendar} & Calend\'ario \\
      \end{tabular}
    \end{minipage}
  }

  \def\misc{
    \begin{minipage}{\d}
      \begin{tabular}{ll}\vspace{-3pt}               \\
        {\tt M-x} shell          & Terminal          \\
        {\tt M-x} re-builder     & Regex             \\
        {\tt M-x} orgstruct-mode & Listas            \\
        {\tt M-x} orgtbl-mode    & Tabelas           \\
        % {\tt M-x z}            & Repete a\c{c}\~ao \\
        {\tt M-x} artist-mode    & Desenhar          \\
        \md{2}{l}{{\tt M-x} highlight-changes-mode}  \\
      \end{tabular}
    \end{minipage}
  }

  % \draw[fill=gray] rectangle (20,-9);
  % \draw[help lines, gray] (-0.1, -0.1) grid (20.1, 9.1);

  %% Simbolo Emacs com creditos.
  \node[draw=none, anchor=north west] (cred) at (0,9) {\cred};
  \node[mybox, below=of cred] (ajuda) {\ajuda};
  \node[mybox, below=of ajuda] (arquivo) {\arquivo};
  \node[mybox, below=of arquivo] (book) {\book};

  \renewcommand{\baselinestretch}{0.815}
  \def\d{3.8cm}
  \node[mybox, right=6pt of cred.39, anchor=north west] (area) {\area};
  \node[mybox, below=of area] (retangulos) {\retangulos};
  \node[mybox, below=of retangulos] (busca) {\busca};
  \node[mybox, below=of busca] (subist) {\subist};

  \renewcommand{\baselinestretch}{0.815}
  \def\d{3.6cm}
  \node[mybox, right=of area.north east, anchor=north west]
    (movi) {\movi};
  \node [mybox, below=of movi] (janela) {\janelas};
  \node [mybox, below=of janela] (orto) {\orto};
  \node [mybox, below=of orto] (extra) {\extra};

  \renewcommand{\baselinestretch}{0.81}
  \def\d{3.9cm}
  \node[mybox, right=of movi.north east, anchor=north west]
    (formatacao) {\formatacao};
  \node[mybox, below=of formatacao] (trans) {\trans};
  \node[mybox, below=of trans] (latex) {\sessaolatex};

  \renewcommand{\baselinestretch}{0.815}
  \def\d{3.9cm}
  \node[mybox, right=of formatacao.north east, anchor=north west]
    (reftex) {\reftex};
  \node[mybox, below=of reftex] (R) {\sessaor};
  \node[mybox, below=of R] (Rnw) {\sessaornw};
  \node[mybox, below=of Rnw] (misc) {\misc};

  \node[fancytitle] at (ajuda.north east) {Ajuda};
  \node[fancytitle] at (arquivo.north east) {Arquivo};
  \node[fancytitle] at (area.north east)
    {\'{A}rea de transfer{\^e}ncia};
  \node[fancytitle] at (retangulos.north east) {Ret{\^a}ngulos};
  \node[fancytitle] at (formatacao.north east) {Formata\c{c}\~{a}o};
  \node[fancytitle] at (orto.north east) {Ortografia};
  \node[fancytitle] at (book.north east) {Bookmarks};
  \node[fancytitle] at (movi.north east) {Movimenta\c{c}\~{a}o};
  \node[fancytitle] at (busca.north east) {Busca};
  \node[fancytitle] at (subist.north east) {Substitui\c{c}\~{a}o};
  \node[fancytitle] at (janela.north east) {Janelas};
  \node[fancytitle] at (R.north east) {Sess\~{a}o R - ESS};
  \node[fancytitle] at (Rnw.north east) {Sess\~{a}o Rnw - ESS};
  \node[fancytitle] at (latex.north east)
    {Sess\~ao \LaTeX{} - AUC\TeX{}};
  \node[fancytitle] at (reftex.north east) {Reftex};
  \node[fancytitle] at (trans.north east) {Transposi\c{c}\~{a}o};
  \node[fancytitle] at (extra.north east) {Extras};
  \node[fancytitle] at (misc.north east) {Miscel{\^a}nia};

\end{tikzpicture}

\def\hd{0.7}
\def\vd{0.7}
\newcommand{\tm}[1]{\tikz[overlay, anchor=base] \node[red] (#1) {};}

\tikzstyle{every picture}+=[remember picture]

\begin{tikzpicture}[
  >=stealth,
  every path/.style={->, color=darkgreen, thin, rounded corners},
  every node/.style={color=black},
  bx/.style={
    % text width=2.5cm,
    font=\footnotesize,
    minimum height=4ex},
  bxl/.append style={bx,
    left,
    align=flush right},
  bxr/.append style={bx,
    right,
    align=flush left}]

  \node {$\tm{Z}t = \dfrac{\tm{bX}\bar{X}-\mu}{\sqrt{\tm{S}S^2/n}}
    \sim t_{n-1},$};
  \draw (Z)+(0.5ex,2.5ex) |- +(-\vd,\hd)
  node[bxl] {$\sim \text{t de Student}$};
  \draw (bX)+(0.5ex,2.5ex) |- +(\vd,\hd)
  node[bxr] {$\frac{\bar{X}-\mu}{\sigma/\sqrt{n}}\sim
    \text{Normal}(0,1)$};
  \draw (S)+(0.5ex,-1ex) |- +(\vd,-\hd)
  node[bxr] {$(n-1)\frac{S^2}{\sigma^2}\sim \chi^2_{n-1}$};
\end{tikzpicture}

\tikzstyle{every picture}+=[remember picture]
\newcommand{\nann}[2]{%
  \tikz[baseline] {%
    \node[%
    anchor=base,%
    inner sep=0pt,%
    outer sep=0pt,%
    % fill=green%
    ] (#1) {#2};%
  }%
}

\begin{tikzpicture}[
  every path/.style={rounded corners, shorten <=3pt, >=stealth},
  every node/.style={rounded corners=false},
  ann/.style={font=\footnotesize, color=darkgreen}]

  \node (fat) {
    $\mu+
    \nann{a}{$\alpha$}_{i}+
    \nann{t}{$\tau$}_{j}+
    \nann{g}{$\gamma$}_{ij},
    \qquad \text{se cela fatorial}$
  };
  \path[->, draw] (a.north) |- ++(0.5,1)
    node[ann,right] {fator 1};
  \path[->, draw] (t.north) |- ++(0.5,0.7)
    node[ann,right] {fator 2};
  \path[->, draw] (g.north) |- ++(0.5,0.4)
    node[ann,right] {intera\c{c}\~ao};

  \node[below=of fat] (adi) {
    $\mu+
    \nann{th}{$\theta$}_{k},
    \qquad \text{se cela adicional}$
  };
  \path[->, draw] (th.south) |- ++(0.5,-0.5)
    node[ann,right] {testemunhas};

\end{tikzpicture}

\tikzstyle{every picture}+=[remember picture]%
\newcommand{\nann}[2]{%
  \tikz[baseline] {%
    \node[anchor=base, inner sep=0pt, outer sep=0pt] (#1) {#2};%
  }%
}%

\begin{tikzpicture}[
  every path/.style = {rounded corners, shorten <=3pt, >=stealth},
  every node/.style = {rounded corners = false},
  ann/.style = {font = \scriptsize, text width = 15em}
  ]

  \def\m{\textcolor{orange}{m}}%
  \def\n{\textcolor{orange}{n}}%
  \def\r{\textcolor{orange}{r}}%
  \def\y{\textcolor{cyan}{y}}%
  \def\p{\textcolor{purple}{p}}%

  \node {
    $
    \overset{\nann{p}{}}{\p}(\y; \m, \n, \r) =
    \displaystyle
    \binom{\overset{\nann{m}{}}{\m}}{\underset{\nann{y}{}}{\y}}\cdot
    \binom{\overset{\nann{n}{}}{\n}}{\underset{\nann{ry}{}}{\r - \y}}\bigg/
    \binom{\overset{\nann{mn}{}}{\m + \n}}{\underset{\nann{r}{}}{\r}}\cdot
    $
  };
  \path[->, draw] (p) -- ++(0, 0.70) node[ann, above, text width = 10em] {
    Fun{\c c}{\~a}o de probabilidade ou de densidade de probabilidade.};
  \path[->, draw] (m) |- ++(0.5, 1.25) node[ann, right] {
    Par{\^a}metro $\m$.\\ Espaço param{\'e}trico: $\m \geq 1$.};
  \path[->, draw] (n) |- ++(0.5, 0.5) node[ann, right] {
    Par{\^a}metro $\n$.\\ Espaço param{\'e}trico: $\n \geq 1$.};
  \path[->, draw] (y.north) |- ++(0.5, -1.25) node[ann, right, text width = 20em] {
    Vari{\'a}vel aleat{\'o}ria $\textcolor{cyan}{Y}$.\\ Suporte: $R_{\y} = \{\y \in \mathbb{N}: \max(0, \r - \n) \leq \y \leq \min(\r, \m)\}$.};
  \path[->, draw] (r.north) |- ++(0.5, -0.5) node[ann, right] {
    Par{\^a}metro $\r$.\\ Espaço param{\'e}trico: $\r \geq 1$.};

\end{tikzpicture}%

\tikzstyle{every picture}+=[remember picture]%
\newcommand{\nann}[2]{%
  \tikz[baseline] {%
    \node[anchor=base, inner sep=0pt, outer sep=0pt] (#1) {#2};%
  }%
}%

\begin{tikzpicture}[
  every path/.style = {rounded corners, shorten <=3pt, >=stealth},
  every node/.style = {rounded corners = false},
  ann/.style = {font = \footnotesize, text width = 6em}
  ]

  \node {
    $
    p(y) = 
    \displaystyle
    \underset{\nann{a1}{$\phantom{0}$}}{\binom{m}{\textcolor{cyan}{y}}}\cdot
    \overset{\nann{a2}{$\phantom{0}$}}{\binom{n}{\textcolor{orange}{r - y}}}\bigg/
    \underset{\nann{a3}{$\phantom{0}$}}{\binom{m + n}{r}}
    $
  };
  \path[->, draw] (a1.north) |- ++(0.5, -1) node[ann, right] {Arranjos com bolas brancas};
  \path[->, draw] (a2.south) |- ++(0.5, 0.5) node[ann,right] {Arranjos com bolas pretas};
  \path[->, draw] (a3.north) |- ++(0.5, -0.5) node[ann,right] {Arranjos com todas as bolas};
\end{tikzpicture}%

ann,right] {testemunhas};

\end{tikzpicture}

\newcommand{\tm}[1]{\tikz[overlay, anchor=base] \node[red] (#1) {};}
\tikzstyle{every picture}+=[remember picture]
\tikzset{ 
  >=stealth,
  every path/.style={->, color=darkgreen, thin},
  every node/.style={color=black},
  node distance=0.5cm
}

\begin{tikzpicture}
  \node at (0.9,-0.3)
  {$\tm{l}\underset{p\times p}{L}
    \tm{u}\underset{p\times p}{L^\top} =
    \tm{xx}\underset{p\times p}{X^\top X}$};
  \begin{scope}[yshift=-1.25cm]
    \node (a) at (0,0) {};
    \node[right=of a] (b) {};
    \node[below=of b] (c) {};
    \node[below=of a] (d) {};
    \draw[-, darkgreen]
    (a.north west) -| (c.south east);
    \fill[darkgreen]
    (a.north) -| (d.south west) -| (c.east) -- cycle;
    \path[draw] (l)+(1.8ex,-2ex)
    to[out=-90, in=90] ($(a.north)!0.5!(b.north)$);
    \node (a) at (1.1,0) {};
    \node[right=of a] (b) {};
    \node[below=of b] (c) {};
    \node[below=of a] (d) {};
    \fill[darkgreen]
    (a.west) |- (b.north east) |- (c.south) -- cycle;
    \draw[-, darkgreen]
    (a.north west) |- (c.south east);
    \path[draw] (u)+(1.7ex,-2ex)
    to[out=-90, in=90] ($(a.north)!0.5!(b.north)$);
  \end{scope}
\end{tikzpicture}

\newcommand{\tm}[1]{\tikz[overlay, anchor=base] \node[red] (#1) {};}
\tikzstyle{every picture}+=[remember picture]
\tikzset{ 
  >=stealth,
  every path/.style={->, color=darkgreen, thin},
  every node/.style={color=black},
  node distance=0.5cm
}

\begin{tikzpicture}
  \node at (0.5,-0)
  {$\tm{x}\underset{n\times p}{X} =
    \tm{q}\underset{n\times p}{Q}
    \tm{r}\underset{p\times p}{R}$};
  \begin{scope}[xshift=0mm, yshift=-1cm]
    \node (a) at (0,0) {};
    \node[right=1mm of a] (b) {};
    \node[below=1cm of b] (c) {};
    \node[below=1cm of a] (d) {};
    \fill[darkgreen]
    (a.north west) -| (c.south east) -| (a.north west);
    \path[draw] (q)+(1.8ex,-2ex)
    to[out=-90, in=90] ($(a.north)!0.5!(b.north)$);
    \node (a) at (0.7,0) {};
    \node[right=1mm of a] (b) {};
    \node[below=1mm of b] (c) {};
    \node[below=of a] (d) {};
    \fill[darkgreen]
    (a.west) |- (b.north east) |- (c.south) -- cycle;
    \draw[-, darkgreen]
    (a.north west) |- (c.south east);
    \path[draw] (r)+(1.7ex,-2ex)
    to[out=-90, in=90] ($(a.north)!0.5!(b.north)$);
  \end{scope}
\end{tikzpicture}

\def\hd{0.5}
\def\vd{0.5}
\newcommand{\tm}[1]{\tikz[overlay, anchor=base] \node[red] (#1) {};}
\tikzstyle{every picture}+=[remember picture]

\begin{tikzpicture}[
  >=stealth,
  every path/.style={->, color=darkgreen, thin, rounded corners},
  every node/.style={color=black},
  bx/.style={text width=3cm, font=\footnotesize, minimum height=4ex},
  bxl/.append style={bx, left, align=flush right},
  bxr/.append style={bx, right, align=flush left}]

  \node {
    $\tm{y}y =
    \tm{b0}\beta_0+
    \tm{b1}\beta_1
    \tm{x1}x_1+
    \tm{b2}\beta_2
    \tm{x2}x_2+\cdots+
    \tm{bk}\beta_k
    \tm{xk}x_k+
    \tm{er}\epsilon$
  };

  \node[bx, align=center] (preds) at (0.4,1.5)
  {Preditoras ou vari\'aveis\\ independentes};
  \node[bx, align=center] (tx) at (0.4,-1.5) {Taxas};

  \path[draw] (y)+(0.5ex,2ex) to[out=90, in=0] +(-\vd,\hd)
  node[bxl] {resposta ou vari\'avel dependente};
  \path[draw] (x1)+(0.5ex,2ex) to[out=90, in=-90] (preds);
  \path[draw] (x2)+(0.5ex,2ex) to[out=90, in=-90] (preds);
  \path[draw] (xk)+(0.5ex,2ex) to[out=90, in=-90] (preds);
  \path[draw] (b1)+(1ex,-1ex) to[out=-90, in=90] (tx);
  \path[draw] (b2)+(1ex,-1ex) to[out=-90, in=90] (tx);
  \path[draw] (bk)+(1ex,-1ex) to[out=-90, in=90] (tx);
  \path[draw] (b0)+(1ex,-1ex) to[out=-90, in=0] +(-\vd,-\hd)
  node[bxl] {Intercepto};
  \path[draw] (er)+(0.5ex,-1ex) to[out=-90, in=180] +(\vd,-\hd)
  node[bxr] {Erro aleat\'orio $E(\epsilon) = 0$,\\
    $V(\epsilon) = \sigma^ 2$};

\end{tikzpicture}

\def\hd{0.7}
\def\vd{0.7}
\newcommand{\tm}[1]{\tikz[overlay, anchor=base] \node[red] (#1) {};}
\tikzstyle{every picture}+=[remember picture]

\begin{tikzpicture}[
  >=stealth,
  every path/.style={->, color=darkgreen, thin, rounded corners},
  every node/.style={color=black},
  bx/.style={text width=3cm, font=\footnotesize, minimum height=4ex},
  bxl/.append style={bx, left, align=flush right},
  bxr/.append style={bx, right, align=flush left}]

  \node {
    $\tm{y}y =
    \tm{b0}\beta_0+
    \tm{b1}\beta_1
    \tm{x}x+
    \tm{er}\epsilon$
  };

  \draw (y)+(0.5ex,2ex) |- +(-\vd,\hd) node[bxl]
  {Resposta ou vari\'avel dependente}; 
  \draw (x)+(0.5ex,2ex) |- +(\vd,\hd) node[bxr]
  {Preditora ou vari\'avel independente};
  \draw (b0)+(1ex,-1ex) |- +(-\vd,-\hd) node[bxl]
  {Intercepto};
  \draw (b1)+(1ex,-1ex) -- +(1ex,-1.5*\hd)
  node[bxr, below, align=center]
  {Taxa};
  \draw (er)+(0.5ex,-1ex) |- +(\vd,-\hd) node[bxr]
  {Erro aleat\'orio $E(\epsilon) = 0$,\\ $V(\epsilon) = \sigma^2$};

\end{tikzpicture}

\tikzstyle{every picture}+=[remember picture]%
\newcommand{\nann}[2]{%
  \tikz[baseline] {%
    \node[anchor=base, inner sep=0pt, outer sep=0pt] (#1) {#2};%
  }%
}%

\begin{tikzpicture}[
  every path/.style = {rounded corners, shorten <=4pt, >=stealth},
  every node/.style = {rounded corners = false},
  ann/.style = {font = \footnotesize}
  ]

\begin{scope}

  \node {$\text{A}_{\text{IC}(\mu)} = \displaystyle 2 \cdot
     \nann{z}{$z$}_{\alpha/2} \cdot \frac{\nann{s}{$\sigma$}}{\sqrt{\nann{n}{$n$}}}$};

   \path[->, draw] (z.north) |- ++(-0.5, 0.5) node[ann, left] {
     $\uparrow 1 - \alpha \Rightarrow
     \uparrow z_{\alpha/2} \Rightarrow
     \uparrow \textcolor{orange}{\text{A}_{\text{IC}(\mu)}}$};

   \path[->, draw] (s.north) |- ++(0.5, 0.5) node[ann, right] {
     $\uparrow \sigma \Rightarrow
     \uparrow \textcolor{orange}{\text{A}_{\text{IC}(\mu)}}$};

   \path[->, draw] (n.south) |- ++(0.5, -0.5) node[ann, right] {
     $\uparrow n \Rightarrow
     \downarrow \textcolor{cyan}{\text{A}_{\text{IC}(\mu)}}$};

\end{scope}

\begin{scope}[yshift = -3cm]

  \node {$n = \displaystyle \left(\frac{\nann{z}{$z$}_{\alpha/2} \cdot \nann{s}{$\sigma$}}{\nann{e}{$e$}} \right)^2$};

   \path[->, draw] (z.north) |- ++(-0.5, 0.5) node[ann, left] {
     $\uparrow 1 - \alpha \Rightarrow
     \uparrow z_{\alpha/2} \Rightarrow
     \uparrow \textcolor{orange}{n}$};

   \path[->, draw] (s.north) |- ++(0.5, 0.5) node[ann, right] {
     $\uparrow \sigma \Rightarrow
     \uparrow \textcolor{orange}{n}$};

   \path[->, draw] (e.south) |- ++(0.5, -0.5) node[ann, right] {
     $\uparrow e \Rightarrow
     \downarrow \textcolor{cyan}{n}$};

\end{scope}

\end{tikzpicture}%

\pgfplotsset{
  myplot/.style={
    width=10cm, height=7cm,
    mark=*,
    nodes near coords,
    point meta=explicit symbolic, % permite usar a 3 coluna como label.
    every node near coord/.append style={font=\footnotesize},
    nodes near coords align={vertical}
  }
}

\pgfplotstableset{
  create on use/new/.style={
    create col/expr={\thisrow{px}*30}
  }
}

\begin{filecontents*}{distrprob.dat}
  i    x       px       PX     f     F
  1    0 0.421875 0.421875 27/64 27/64
  2   50 0.140625 0.562500  9/64 36/64
  3  100 0.281250 0.843750 18/64 54/64
  4  250 0.046875 0.890625  3/64 57/64
  5  500 0.093750 0.984375  6/64 63/64
  6 1000 0.015625 1.000000  1/64 64/64
\end{filecontents*}

\begin{tikzpicture}[>=stealth]
  \begin{axis}[
    myplot,
    hide y axis,
    axis x line*=bottom,
    xmin=0, xmax=1000,
    domain=0:1000,
    height=2.0cm,
    enlarge x limits=0.05,
    clip=false]

    \addplot[
      scatter, only marks, ycomb,
      visualization depends on=\thisrow{px} \as\wtwo,
      scatter/@pre marker code/.append style={
        /tikz/mark size=\wtwo*20}
    ] table [x=x, y=px] {distrprob.dat};

    \draw[<-, very thick, darkgreen] (axis cs: 109.375, 0) --
    (axis cs: 109.375, -0.5) node[below] {$E(X) = 109.375$};

  \end{axis}
\end{tikzpicture}

\begin{tikzpicture}[%
  >=stealth',
  edge from parent/.style = {
    ->, draw},
  basic/.style = {
    draw, rectangle, fill = orange!60},
  boxtitle/.style = {
    minimum height = 3em, fill = gray!60},
  description/.style = {
    minimum height = 6em, text width = 4cm, fill = gray!20},
  item/.style={
    fill = cyan, minimum height = 1.8em,
    text width = 3.7cm, minimum width = 3.7cm},
  subject/.style = {
    grow = down, xshift = -1.7cm, solid, anchor = west,
    edge from parent path = {
      ($(\tikzparentnode.south west)+(0.2,0)$) |- (\tikzchildnode.west)
    }
  },
  level 1/.append style = {
    sibling distance = 5cm},
  level 2/.style = {
    basic, rounded corners = 3pt, align = center,
    minimum width = 4.5cm, level distance = 2cm}
  ]

  \node[level 2, minimum width = 6cm, minimum height = 2em] {Estat{\'i}stica}
  child {
    node[level 2, boxtitle] (EstDes) {Estat{\'i}stica Descritiva}
    child {
      node[level 2, description] (EstDesObj) {
        Coleta, organiza{\c c}{\~a}o, tratamento, an{\'a}lise, apresenta{\c c}{\~a}o e interpreta{\c c}{\~a}o de dados.
      }
      child [subject, level distance=1.75cm] {node[item] {An{\'a}lise gr{\'a}fica}}
      child [subject, level distance=2.75cm] {node[item] {Medidas resumo}}
    }
  }
  child {
    node[level 2, boxtitle] (Prob) {Probabilidades}
    child {
      node[level 2, description] (PrbObj) {
        An{\'a}lise de situa{\c c}{\~o}es que lidam com o acaso para determina{\c c}{\~a}o de probabilidades.
      }
      child [subject, level distance=1.75cm] {node[item] {Probabilidades}}
      child [subject, level distance=2.75cm] {node[item] {Vari{\'a}veis aleat{\'o}rias}}
      child [subject, level distance=3.75cm] {node[item] {Distribui{\c c}{\~o}es de probabilidade}}
    }
  }
  child {
    node[level 2, boxtitle] (InfEst) {Infer{\^e}ncia Estat{\'i}stica}
    child {
      node[level 2, description] (InfEstObj) {
        M{\'e}todos para realiza{\c c}{\~a}o de infer{\^e}ncia estat{\'\i}stica a partir de dados observados.
      }
      child [subject, level distance=1.75cm] {node[item] {M{\'e}todos de amostragem}}
      child [subject, level distance=2.75cm] {node[item] {Estima{\c c}{\~a}o}}
      child [subject, level distance=3.75cm] {node[item] {Testes de hip{\'o}tese}}
    }
  };

\end{tikzpicture}%

\tikzstyle{every picture}+=[remember picture]
\newcommand{\nann}[2]{%
  \tikz[baseline] {%
    \node[%
    anchor=base,%
    inner sep=0pt,%
    outer sep=0pt,%
    % fill=green%
    ] (#1) {#2};%
  }%
}

\begin{tikzpicture}[
  every path/.style={rounded corners, shorten <=3pt, >=stealth},
  every node/.style={rounded corners=false}]

  \node {
    \begin{minipage}{10cm}
      {\tt sed s/\nann{regex}{regex}/\nann{repl}{replacement}/g \nann{txt}{text.txt}}
    \end{minipage}
  };
  \path[->, draw] (regex.south) |- ++(1,-1) node[right] {REGEX};
  \path[->, draw] (repl.north) |- ++(1,1) node[right] {REPL};
  \path[->, draw] (txt.east) -| ++(1,1) node[above] {FILE};
\end{tikzpicture}

% set.seed(123)
% y <- round(cumsum(rexp(30, 1.25)), digits = 2)
% cat(y[y <= 10], sep = ", ")
\begin{tikzpicture}[>=stealth']

  \begin{scope}
    \coordinate (arrowstart) at (-0.5, 0);
    \node (arrowend) at (11.25, 0) {Tempo};
    \draw[->] (arrowstart) -- (arrowend);

    \foreach \x in {0, 2, ..., 10}{
      \draw (\x, -0.10) -- (\x, 0.10);
    }

    \foreach \x in {0.67, 1.84, 2.2, 2.22, 2.27, 2.52, 2.77, 2.89, 5.07, 5.09, 5.9, 6.28, 6.51, 6.81, 6.96, 7.64, 8.89, 9.27, 9.75}{
      \draw[fill = cyan, fill opacity = 0.5] (\x, 0.2) circle [radius = 3pt];
    }

  \draw[|<->|, color = magenta] (0.67, 0.75) -- (1.84, 0.75) node[right, text = black]
    {Intervalo entre eventos: $Y_1 \sim \textcolor{magenta}{\text{Exp}(\lambda)}$};

  \coordinate (A) at (4, -0.3);
  \coordinate (B) at (6, -0.3);

  \draw [decorate, decoration = {brace, amplitude = 5pt}] (B) -- (A) 
    node [black, midway, yshift = -1.5em] {N{\'u}mero de eventos por intervalo: $Y_2 \sim \textcolor{cyan}{\text{Pois}(\lambda)}$};

  \end{scope}

\end{tikzpicture}%

\usetikzlibrary{decorations.pathreplacing}%
\begin{tikzpicture}
  \begin{axis}[
    samples = 10,
    view = {-25}{30},
    xtick = {-1, 0, 1},
    ytick = {-1, 0, 1},
    % ztick = {0},
    xlabel = A,
    ylabel = B,
    zlabel = y,
    zlabel style = {rotate = -90}]

    \addplot3[surf, domain = -1.05:1.05, opacity = 0.25] {5 + x + y + 0.5 * x * y};
    \draw[thick] (axis cs: 0, 0, 5) -- (axis cs: 0, 0, 8);
    \draw[dashed] (axis cs: 0, 0, 8) -- (axis cs: 1, 0, 8);
    \draw[dashed] (axis cs: 0, 0, 8) -- (axis cs: 0, 1, 8);
    \fill (axis cs: 0,  0, 8.0) circle (2pt) node[left] {$\bar{y}_{pc}$};

    \draw (axis cs: 0,  0, 5.0) circle (2pt) node[left] {$\hat{y}$};
    \fill (axis cs:-1, -1, 3.5) circle (2pt) node[right] {$\bar{y}_{(1)}$};
    \fill (axis cs:-1,  1, 4.5) circle (2pt) node[right] {$\bar{y}_{b}$};
    \fill (axis cs: 1, -1, 4.5) circle (2pt) node[left] {$\bar{y}_{a}$};
    \fill (axis cs: 1,  1, 7.5) circle (2pt) node[left] {$\bar{y}_{ab}$};

    \draw [decorate, -, decoration = {brace, amplitude = 1ex},
      xshift = 5pt, yshift = 0pt] (axis cs: 0,  0, 8) -- (axis cs: 0,  0, 5) 
      node [midway, xshift = 2pt, anchor = west] {LOF};

  \end{axis}
\end{tikzpicture}

\tikzset{%
  basic/.style={draw, text width=2cm, %drop shadow, 
    rectangle, minimum
    height=4ex},
  root/.style={basic, rounded corners=2pt, align=center, fill=gray!30},
  level 2/.style={basic, rounded corners=3pt, align=center,
    fill=gray!60, text width=6em},
  level 3/.style={basic, align=center, fill=gray, text width=16em},
  table/.style={
    matrix of nodes,
    % matrix of math nodes,
    nodes={align=center},
    % minimum height=1.5em,
    minimum width=2em,
    text depth=0ex,
    text height=1ex,
    nodes in empty cells
  },
  vertex/.style={circle, minimum size=4pt, inner sep=1pt, fill=gray!90},
  edge/.style={draw, -, black}
}%

\begin{tikzpicture}[%
  level 1/.append style={sibling distance=40mm},
  level 2/.append style={sibling distance=60mm},
  level 3/.append style={sibling distance=30mm},
  edge from parent/.style={-, draw},
  >=stealth]

  \node[draw, circle] (ini) {}
  child {
    node[level 2] (um) {Um fator}
  }
  child {
    node[level 2] (dois) {Dois ou mais}
    child {
      node[level 2] (cru) {Cruzada}
      child {node[level 2] (com) {Completo}}
      child {node[level 2] (fra) {Fra{\c c}{\~a}o}}
      child {node[level 2] (inc) {Incompleto}}
    }
    child {
      node[level 2] (ani) {Aninhada}
    }
  };

  \draw[dashed] ($(um.90)+(0,0.4)$)  node[left] {N\'umero de fatores} -- ($(dois.90)+(0,0.4)$);
  \draw[dashed] ($(cru.90)+(0,0.4)$) node[left] {Forma de combinar} -- ($(ani.90)+(0,0.4)$);
  \draw[dashed] ($(com.90)+(0,0.4)$) node[left] {Cruzamento} -- ($(inc.90)+(0,0.4)$);

 \begin{scope}
    \matrix[table, below=2mm of com] (tbcom) {
            & $B_1$    & $B_2$    \\
      $A_1$ & $\times$ & $\times$ \\ 
      $A_2$ & $\times$ & $\times$ \\ 
      $A_3$ & $\times$ & $\times$ \\ 
    };
    \draw (tbcom-1-2.north west) -- (tbcom-4-2.south west);
    \draw (tbcom-2-1.north west) -- (tbcom-2-3.north east);
    \matrix[table, below=2mm of inc] (tbinc) {
            & $B_1$    & $B_2$    \\
      $A_1$ & $\times$ & $\times$ \\ 
      $A_2$ & $\times$ &          \\ 
      $A_3$ & $\times$ & $\times$ \\ 
    };
    \draw (tbinc-1-2.north west) -- (tbinc-4-2.south west);
    \draw (tbinc-2-1.north west) -- (tbinc-2-3.north east);
    \matrix[table, below=2mm of tbinc] (tbadi) {
            & $B_1$    & $B_2$    & $T$ \\
      $A_1$ & $\times$ & $\times$ &     \\ 
      $A_2$ & $\times$ & $\times$ &     \\ 
      $T$   &          &          & $+$ \\ 
    };
    \draw (tbadi-1-2.north west) -- (tbadi-4-2.south west);
    \draw (tbadi-2-1.north west) -- (tbadi-2-4.north east);
    \matrix[
    matrix of nodes,
    nodes={align=center},
    text height=0.5ex,
    nodes in empty cells,
    below=5mm of fra,
    left delimiter = {[}, right delimiter = {]}] (tbfra) {
      $-$ & $-$ & $+$ \\
      $-$ & $+$ & $-$ \\
      $+$ & $-$ & $-$ \\
      $+$ & $+$ & $+$ \\
    };
    \node[above] at (tbfra-1-1.north) {$A$};
    \node[above] at (tbfra-1-2.north) {$B$};
    \node[above] at (tbfra-1-3.north) {$C$};
  \end{scope}

  \begin{scope}[thick, z={(0.45,0.35)}, node distance=0.5cm]
    \coordinate[below=1cm of tbcom] (centro);
    \node[vertex, below left=of centro] (v0) {};
    \node[vertex, above left=of centro] (v1) {};
    \node[vertex, below right=of centro] (v2) {};
    \node[vertex, above right=of centro] (v3) {};
    \node[vertex, above right=2ex of v0] (v4) {};
    \node[vertex, above right=2ex of v1] (v5) {};
    \node[vertex, above right=2ex of v2] (v6) {};
    \node[vertex, above right=2ex of v3] (v7) {};
    \draw[edge] (v0) -- (v1) -- (v3) -- (v2) -- (v0);
    \draw[edge] (v0) -- (v4) -- (v5) -- (v1);
    \draw[edge] (v2) -- (v6) -- (v7) -- (v3);
    \draw[edge] (v4) -- (v6);
    \draw[edge] (v5) -- (v7);
  \end{scope}

  \begin{scope}[thick, z={(0.45,0.35)}, node distance=0.5cm]
    \coordinate[below=1cm of tbfra] (centro);
    \node[vertex, fill=white, below left=of centro] (v0) {};
    \node[vertex, above left=of centro] (v1) {};
    \node[vertex, below right=of centro] (v2) {};
    \node[vertex, fill=white, above right=of centro] (v3) {};
    \node[vertex, above right=2ex of v0] (v4) {};
    \node[vertex, fill=white, above right=2ex of v1] (v5) {};
    \node[vertex, fill=white, above right=2ex of v2] (v6) {};
    \node[vertex, above right=2ex of v3] (v7) {};
    \draw[edge] (v0) -- (v1) -- (v3) -- (v2) -- (v0);
    \draw[edge] (v0) -- (v4) -- (v5) -- (v1);
    \draw[edge] (v2) -- (v6) -- (v7) -- (v3);
    \draw[edge] (v4) -- (v6);
    \draw[edge] (v5) -- (v7);
  \end{scope}

  \begin{scope}[
    grow=right,
    cx/.style={rounded corners=2pt, thin, align=center, fill=gray!30},
    level 1/.append style={sibling distance=8mm, level distance=10mm},
    edge from parent/.style={-, draw}]
    \coordinate[below=.75cm of ani] (anip);
    \node[cx, below left=0mm and 0mm of anip] (A1) {$A_1$}
    child {node[cx] {$B_2$}}
    child {node[cx] {$B_1$}};
    \node[cx, below=15mm of A1] (A2) {$A_2$}
    child {node[cx] {$B_5$}}
    child {node[cx] {$B_4$}}
    child {node[cx] {$B_3$}};
    \node[cx, below=15mm of A2] (A3) {$A_3$}
    child {node[cx] {$B_7$}}
    child {node[cx] {$B_6$}};

  \end{scope}

\end{tikzpicture}%

\def\d{1.35}

\begin{tikzpicture}[
  yscale=0.6,
  node distance=1 and 0.5,
  fator1/.style={%
    fill=gray!50},
  fator2/.style={%
    fill=darkgreen!80, minimum height=1.8em},
  profator2/.style={%
    grow=down, xshift=0.1cm, solid, anchor=west,
    edge from parent path={
      (\tikzparentnode.south) |- (\tikzchildnode.west)
    },
  },
  level1/.style ={level distance=\d cm},
  level2/.style ={level distance=2*\d cm},
  level3/.style ={level distance=3*\d cm},
  level 1/.style={sibling distance=1cm, level distance=0.5cm}]

  \node[fator1] (A1) {No solo}
    child [profator2, level1] {node[fator2] {25 kg}}
    child [profator2, level2] {node[fator2] {50 kg}}
    child [profator2, level3] {node[fator2] {75 kg}};
  \node[fator1, right=of A1] (A2) {Foliar}
    child [profator2, level1] {node[fator2] {2 L}}
    child [profator2, level2] {node[fator2] {4 L}}
    child [profator2, level3] {node[fator2] {6 L}};
  \node at ($(A1)!0.5!(A2)+(0,1)$) {Aduba\c{c}\~ao complementar};
\end{tikzpicture}

\def\d{1cm}
\def\k{1.4}

\begin{tikzpicture}[
  yscale=0.6,
  node distance=1 and 0.5,
  fator1/.style={%
    fill=gray!50, text width=2.5cm, text centered, minimum height=3em},
  fator2/.style={%
    fill=darkgreen!80, text width=1.5cm, text centered},
  profator2/.style={%
    grow=down, xshift=-0.2cm, solid, %anchor=west,
    edge from parent path={
      (\tikzparentnode.south west) |- (\tikzchildnode.west)
    },
  },
  level1/.style ={level distance=1.5cm},
  level2/.style ={level distance=2.5cm},
  level3/.style ={level distance=3.5cm}]

  \node[fator1] (H1) {Herbic\'{i}da\\ A}
    child [profator2, level1] {node[fator2] {1 L}}
    child [profator2, level2] {node[fator2] {2 L}}
    child [profator2, level3] {node[fator2] {3 L}};
  \node[fator1, right=of H1] (H2) {Herbic\'{i}da\\ B}
    child [profator2, level1] {node[fator2] {1 L}}
    child [profator2, level2] {node[fator2] {2 L}}
    child [profator2, level3] {node[fator2] {3 L}};
  \node[fator1, right=of H2] (Tm)
    {Sem herbic\'ida \\ \textbf{Sem} capina};
  \node[fator1, right=of Tm] (TM)
    {Sem herbic\'ida \\ \textbf{Com} capina};
  \draw (H1) |- ($(H2)+(0,\k)$);
  \draw (H2) |- ($(Tm)+(0,\k)$);
  \draw (Tm) |- ($(TM)+(0,\k)$) -- (TM);
\end{tikzpicture}

\def\d{1cm}
\def\k{0.6}

\begin{tikzpicture}[
  yscale=0.6,
  node distance=1 and 0.5,
  fator1/.style={%
    fill=gray!50},
  fator2/.style={%
    fill=darkgreen!80},
  profator2/.style={%
    grow=down, xshift=0.1cm, solid, anchor=west,
    edge from parent path={
      (\tikzparentnode.south) |- (\tikzchildnode.west)
    },
  },
  level1/.style ={level distance=1cm},
  level2/.style ={level distance=2cm},
  level3/.style ={level distance=3cm},
  level 1/.style={sibling distance=1cm, level distance=0.5cm}]

  \node[fator1] (A1) {A1}
    child [profator2, level1] {node[fator2] {B1}}
    child [profator2, level2] {node[fator2] {B2}}
    child [profator2, level3] {node[fator2] {B3}};
  \node[fator1, right=of A1] (A2) {A2}
    child [profator2, level1] {node[fator2] {B1}}
    child [profator2, level2] {node[fator2] {B2}}
    child [profator2, level3] {node[fator2] {B3}};
  \node[fator1, right=of A2] (Tm) {$T-$};
  \node[fator1, right=of Tm] (TM) {$T+$};
  \draw (A1) |- ($(A2)+(0,\k)$);
  \draw (A2) |- ($(Tm)+(0,\k)$);
  \draw (Tm) |- ($(TM)+(0,\k)$) -- (TM);
\end{tikzpicture}

\tikzstyle{every picture}+=[remember picture]
\newcommand{\nann}[2]{%
  \tikz[baseline] {%
    \node[%
    anchor=base,%
    inner sep=0pt,%
    outer sep=0pt,%
    ] (#1) {#2};%
  }%
}

\begin{tikzpicture}[
  >=stealth,
  mtx/.style={
    matrix of math nodes,
    left delimiter={[}, right delimiter={]}
  },
  hlt/.style={
    draw=red, thick, outer sep=0pt, inner sep=0pt, rounded corners,
    inner sep=-1pt
  },
  hltr/.style={opacity=0.5, rounded corners=2pt, inner sep=-1pt},
  rpath/.style={<->, draw, rounded corners},
  epath/.style={draw, ->, rounded corners, shorten <=3pt, >=stealth},
  every node/.style={rounded corners=false},
  ann/.style={font=\footnotesize, color=darkgreen}]

  \node (fat) {
    $\mu+
    \nann{a}{$\alpha$}_{i}+
    \nann{t}{$\tau$}_{j}+
    \nann{g}{$\gamma$}_{ij},
    \qquad \text{se cela fatorial}$
  };

  \path[epath] (a.north) |- ++(0.5,1)
    node[ann,right] (fa) {fator 1};
  \path[epath] (t.north) |- ++(0.5,0.7)
    node[ann,right] (ft) {fator 2};
  \path[epath] (g.north) |- ++(0.5,0.4)
    node[ann,right] (fg) {intera\c{c}\~ao};

  \node[below=of fat] (adi) {
    $\mu+
    \nann{th}{$\theta$}_{k},
    \qquad \text{se cela adicional}$
  };

  \path[epath] (th.south) |- ++(0.5,-0.5)
    node[ann,right] (tt) {testemunhas};

  \matrix[mtx, right=of fat] (X) {
    1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 
    1 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\ 
    1 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\ 
    1 & 1 & 1 & 0 & 1 & 0 & 0 & 0 \\ 
    1 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ 
    1 & 1 & 0 & 1 & 0 & 1 & 0 & 0 \\ 
    1 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \\ 
    1 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\
  };

  \begin{scope}[on background layer]
    \node[hltr, fill=blue, fit=(X-7-7)(X-8-8)] {};
    \node[hltr, fill=green, fit=(X-1-2)(X-6-6)] {};
    % \node[hltr, fill=green, fit=(X-1-2)(X-16-4)] {};
    % \node[hltr, fill=blue, fit=(X-1-5)(X-16-8)] {};
    % \node[hltr, fill=yellow, fit=(X-1-9)(X-16-20)] {};
  \end{scope}

  \foreach \col/\th in {
    1/$\mu$,2/$\alpha_2$,3/$\tau_2$,4/$\tau_3$,
    5/$\gamma_{23}$,6/$\gamma_{33}$,7/$\theta_1$,8/$\theta_2$
  }{
    \node[right, rotate=90, font=\tt]
      (p\col) at (X-1-\col.north) {\th};
  }

  \draw (fa) to[out=90, in=90] (p2.east);
  \draw (ft) to[out=90, in=90] (p3.east);
  \draw (fg) to[out=90, in=90] (p5.east);
  % \draw (tt) .. controls (X-8-8.south east) and +(5,-5) .. (p7.east);
  \draw (tt) to[out=0, in=180] ($(X-8-8.south)+(0.5,-0.25)$)
  to[out=10, in=60] (p8.east);

\end{tikzpicture}

\begin{tikzpicture}[
  >=stealth,
  mtx/.style={
    matrix of math nodes,
    % row sep=0ex, column sep=0em, text height=1ex,
    left delimiter={[}, right delimiter={]}
  },
  hlt/.style={
    draw=red, thick, outer sep=0pt, inner sep=0pt,
    rounded corners, inner sep=-1pt
  },
  hltr/.style={opacity=0.5, rounded corners=2pt, inner sep=-1pt},
  rpath/.style={<->, draw, rounded corners}]

  \matrix[mtx] (X) at (0,0) {
    1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 
    1 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 
    1 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 
    1 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 
    1 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 
    1 & 1 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 
    1 & 0 & 1 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ 
    1 & 0 & 0 & 1 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\ 
  };

  \foreach \col/\th in {
    1/(Intercept) - $\mu$,
    2/A2 - $\alpha_2$,
    3/AL - $\alpha_3 = \theta_1$,
    4/AU - $\alpha_4 = \theta_2$,
    5/B2 - $\tau_2$,
    6/B3 - $\tau_3$,
    7/BL - $\tau_4 = \theta_1$,
    8/BU - $\tau_5 = \theta_2$,
    9/A2:B2 - $\gamma_{22}$,
    10/AL:B2,
    11/AU:B2,
    12/A2:B3 - $\gamma_{23}$,
    13/AL:B3,
    14/AU:B3,
    15/A2:BL,
    16/AL:BL - $\theta_1$,
    17/AU:BL,
    18/A2:BU,
    19/AL:BU,
    20/AU:BU - $\theta_2$
  }{
    \node[right, rotate=90, font=\tt] at (X-1-\col.north) {\th};
  }

  \begin{scope}[on background layer]
    \node[hltr, fill=gray, fit=(X-1-1)(X-8-1)] {};
    \node[hltr, fill=green, fit=(X-1-2)(X-8-4)] {};
    \node[hltr, fill=blue, fit=(X-1-5)(X-8-8)] {};
    \node[hltr, fill=yellow, fit=(X-1-9)(X-8-20)] {};
  \end{scope}

  \node[hlt, dashed, fit=(X-1-3)(X-8-4)] {};
  \node[hlt, fit=(X-1-7)(X-8-8)] {};
  \node[hlt, fit=(X-1-16)(X-8-16)] {};
  \node[hlt, fit=(X-1-20)(X-8-20)] {};

  \path[rpath] (X-8-3) |- ++(0,-0.6) -| (X-8-7);
  \path[rpath] (X-8-7) |- ++(0,-0.6) -| (X-8-16);
  \path[rpath] (X-8-4) |- ++(0,-0.75) -| (X-8-8);
  \path[rpath] (X-8-8) |- ++(0,-0.75) -| (X-8-20);

  \foreach \col in {10,11,13,14,15,17,18,19}{
    \draw[red, snake, segment length=2pt]
      (X-1-\col.north) -- (X-8-\col.south);
  }

  \foreach \col in {1,...,6,9,12}{
    \node[purple] at (X-1-\col.north)
      {\footnotesize $\blacktriangledown$};
  }

  \matrix[left=of X, matrix of nodes] (da) {
    \hline
    a1 & b1 \\ 
    a2 & b1 \\ 
    a1 & b2 \\ 
    a2 & b2 \\ 
    a1 & b3 \\ 
    a2 & b3 \\ 
    L & L \\ 
    U & U \\ \hline\\
  };

  \foreach \col/\th in {1/A, 2/B}{
    \node[above, rotate=0, font=\tt] at (da-1-\col.north) {\th};
  }

  \begin{scope}[on background layer]
    \node[hltr, fill=orange, fit=(da-7-1)(da-8-2)] {};
  \end{scope}

\end{tikzpicture}

\tikzstyle{vertex1}=[
  rectangle, minimum size=12pt, inner sep=1pt, fill=gray!10]
\tikzstyle{vertex2}=[
  rectangle, minimum size=12pt, inner sep=1pt, fill=gray!90]
\tikzstyle{edge}=[draw,thick,-,black]

\begin{tikzpicture}[
  xscale=2.2, yscale=2.1, ->, thick,
  z={(0.45,0.35)}, node distance=0.65cm]
  \node[vertex1] (v0) at (0,0,0) {$(1) = 550$};
  \node[vertex2] (v1) at (0,1,0) {$cd = 1075$};
  \node[vertex2] (v2) at (1,0,0) {$ad = 749$};
  \node[vertex1] (v3) at (1,1,0) {$ac = 642$};
  \node[vertex2] (v4) at (0,0,1) {$bd = 1052$};
  \node[vertex1] (v5) at (0,1,1) {$bc = 601$};
  \node[vertex1] (v6) at (1,0,1) {$ab = 650$};
  \node[vertex2] (v7) at (1,1,1) {$abcd = 729$};
  \draw[edge] (v0) -- (v1) -- (v3) -- (v2) -- (v0);
  \draw[edge] (v0) -- (v4) -- (v5) -- (v1);
  \draw[edge] (v2) -- (v6) -- (v7) -- (v3);
  \draw[edge] (v4) -- (v6); \draw[edge] (v5) -- (v7);
\end{tikzpicture}

% Figure 6-35, page 273 in MONTGOMERY, D. C. Design and analysis of experiments. 5th ed. New York: John Wiley & Sons, 2001.
\usetikzlibrary{decorations.pathreplacing}%
\begin{tikzpicture}[%
  xscale = 2,
  yscale = 2,
  thick,
  line cap = round]

  \coordinate (1) at (-1, -1);
  \node[anchor = south west] at (1) {39.9};

  \coordinate (a) at (1, -1);
  \node[anchor = south east] at (a) {40.9};

  \coordinate (b) at (-1, 1);
  \node[anchor = north west] at (b) {40.0};

  \coordinate (ab) at (1, 1);
  \node[anchor = north east] at (ab) {41.5};

  \draw (1) -- (a) -- (ab) -- (b) -- (1);

  \coordinate (pc) at (0, 0);
  \node[xshift = 5.5pt, anchor = west, align = left]
    at (pc) {40.3\\ 40.5\\ 40.7\\ 40.2\\ 40.6};
  \draw [decorate, -, decoration = {brace, amplitude = 1ex},
    xshift = 4.5pt, yshift = 0pt] (0, -0.5) -- (0, 0.5);

  \foreach \p in {1, a, b, ab, pc} {
    \fill (\p) circle (1.25pt);
  }

  \begin{scope}[yshift = -1.2cm]
    \draw (-1, 0) -- (1, 0);
    \foreach \x in {-1, 0, 1} {
      \draw (\x, 0) -- (\x, 0.05) node[below = 2pt] {\x};
    }
  \end{scope}

  \begin{scope}[yshift = -1.6cm]
    \draw (-1, 0) -- (1, 0);
    \foreach \x/\a in {-1/30, 0/35, 1/40} {
      \draw (\x, 0) -- (\x, 0.05) node[below = 2pt] {\a};
    }
    \node at (0, -0.35) {Tempo de rea{\c c}{\~ a}o (min)};
  \end{scope}

  \begin{scope}[xshift = -1.2cm]
    \draw (0, -1) -- (0, 1);
    \foreach \y in {-1, 0, 1} {
      \draw (0, \y) -- (0.05, \y) node[left = 2pt] {\y};
    }
  \end{scope}

  \begin{scope}[xshift = -1.6cm]
    \draw (0, -1) -- (0, 1);
    \foreach \y/\a in {-1/150, 0/155, 1/160} {
      \draw (0, \y) -- (0.05, \y) node[left = 2pt] {\a};
    }
    \node[rotate = 90] at (-0.45, 0) {Temperatura ($^\circ$C)};
  \end{scope}

\end{tikzpicture}%

\def\dist{1.5}
\tikzstyle{vertex1}=[
  rectangle, minimum size=12pt, inner sep=1pt, fill=gray!10]
\tikzstyle{edge}=[draw,thick,-,black]

\begin{tikzpicture}[
  xscale=1.5, yscale=1.5, ->, thick, node distance=0.65cm]
  \draw[<->] (-\dist,\dist) node[above left] {RP} |-
    (\dist,-\dist) node[below right] {T};
  \node[left] at (-\dist,-1) {1.1};
  \node[left] at (-\dist,0) {1.2};
  \node[left] at (-\dist,1) {1.3};
  \node[below] at (-1,-\dist) {-225};
  \node[below] at (0,-\dist) {-220};
  \node[below] at (1,-\dist) {-215};
  \node[vertex1] (1) at (-1,-1) {$82.8$};
  \node[vertex1] (a) at (1,-1) {$84.7$};
  \node[vertex1] (b) at (-1,1) {$83.5$};
  \node[vertex1] (ab) at (1,1) {$85.0$};
  \node[vertex1] (0) at (0,0) {
    \begin{tabular}{c}
      84.1 \\ 84.5 \\ 83.9 \\ 84.3
    \end{tabular}
  };
  \draw[edge] (1) -- (a) -- (ab) -- (b) -- (1);
\end{tikzpicture}

\usetikzlibrary{decorations.pathreplacing}%
\begin{tikzpicture}[%
  mtx/.style = {
    matrix of math nodes,
    % left delimiter = {[},
    % right delimiter = {]},
    nodes = {
      text width = 1.25em,
      text height = 1.5ex,
      align = center,
    }
  },
  edge/.style = {draw, line cap = round, line join = round},
  hltr/.style = {opacity = 0.2, rounded corners = 2pt, inner sep = -1pt},
  txtup/.style = {rotate = 0, above},
  txtbt/.style = {yshift = -1ex}
  ]

  \def\cube{

    \foreach \x in {0, 1} {
      \foreach \y in {0, 1} {
        \foreach \z in {0, 1} {
          \coordinate (v\x\y\z) at (\x, \y, \z);
        }
      }
    }

    \begin{scope}[on background layer]
      \foreach \y in {0, 1} {
        \draw[edge] (v0\y0) -- (v1\y0) -- (v1\y1) -- (v0\y1) -- cycle;
      }
      \foreach \x in {0, 1} {
        \foreach \z in {0, 1} {
          \draw[edge] (v\x0\z) -- (v\x1\z);
        }
      }
    \end{scope}

  } % \cube

  \begin{scope}[->, > = latex]

    \matrix (X) [mtx] {
      1 & - & - & - & + & + & + & - \\
      1 & + & - & - & - & - & + & + \\
      1 & - & + & - & - & + & - & + \\
      1 & + & + & - & + & - & - & - \\
      1 & - & - & + & + & - & - & + \\
      1 & + & - & + & - & + & - & - \\
      1 & - & + & + & - & - & + & - \\
      1 & + & + & + & + & + & + & + \\
    };

    \foreach \col/\lab in {1/I, 2/A, 3/B, 4/C, 5/AB, 6/AC, 7/BC, 8/ABC} {
      \node[txtup] (\lab) at (X-1-\col.north) {$\lab$};
    }

    \node[above = 4em of X-1-4] (I1) {$I_1 = AB$};
    \node[right = 1em of I1] (I2) {$I_2 = AC$};
    \node[right = 1em of I2] (I3) {$I_3 = I_1\cdot I_2 = BC$};

    \path (I1) edge[out = -90, in = 90] (AB);
    \path (I2) edge[out = -90, in = 90] (AC);
    \path[gray, dashed] (I3) edge[out = -90, in = 90] (BC);

    \draw [decorate, -, decoration = {brace, amplitude = 1.5ex}]
    ($(X-8-7.south east) + (0, -0.1)$) -- ($(X-8-5.south west) + (0, -0.1)$)
    node [midway, yshift = -1ex, anchor = north] {4 blocos $\rightarrow$ 3 GL};

  \end{scope}

  \begin{scope}[on background layer]
    \node[hltr, fill = green, fit = (X-1-5)(X-8-5)] {};
    \node[hltr, fill = purple, fit = (X-1-6)(X-8-6)] {};
    \node[hltr, draw, dashed, fit = (X-1-7)(X-8-7)] {};
  \end{scope}

  \newcommand{\experimentalpoint}[1]{
    \draw[fill = \mycol] (#1) circle (2.5pt);
  }

  \begin{scope}[inner sep = 1ex]

    \begin{scope}[scale = 0.75, xshift = 10.5cm, yshift = 3cm]
      \node[draw, fill = cyan!50!white] (bl1) at (-3.5, 0.2) {
        \begin{minipage}[c][1em]{8em}
          \begin{center}
            Bloco I:\quad (1)\quad abc
          \end{center}
        \end{minipage}
      };
      \cube{}
      \def\mycol{cyan!50!white}
      \experimentalpoint{v110};
      \experimentalpoint{v001};
    \end{scope}

    \begin{scope}[scale = 0.75, xshift = 10.5cm, yshift = 1cm]
      \node[draw, fill = orange!50!white] (bl2) at (-3.5, 0.2) {
        \begin{minipage}[c][1em]{8em}
          \begin{center}
            Bloco II:\quad a\quad bc
          \end{center}
        \end{minipage}
      };
      \cube{}
      \def\mycol{orange!50!white}
      \experimentalpoint{v101};
      \experimentalpoint{v010};
    \end{scope}

    \begin{scope}[scale = 0.75, xshift = 10.5cm, yshift = -1cm]
      \node[draw, fill = pink!50!white] (bl3) at (-3.5, 0.2) {
        \begin{minipage}[c][1em]{8em}
          \begin{center}
            Bloco III:\quad b\quad ac
          \end{center}
        \end{minipage}
      };
      \cube{}
      \def\mycol{pink!50!white}
      \experimentalpoint{v011};
      \experimentalpoint{v100};
    \end{scope}

    \begin{scope}[scale = 0.75, xshift = 10.5cm, yshift = -3cm]
      \node[draw, fill = yellow!50!white] (bl4) at (-3.5, 0.2) {
        \begin{minipage}[c][1em]{8em}
          \begin{center}
            Bloco IV:\quad ab\quad c
          \end{center}
        \end{minipage}
      };
      \cube{}
      \def\mycol{yellow!50!white}
      \experimentalpoint{v000};
      \experimentalpoint{v111};
    \end{scope}

  \end{scope}

  \foreach \line/\blc in {1/1, 8/1, 2/2, 7/2, 3/3, 6/3, 4/4, 5/4} {
    \path[draw] (X-\line-8.east) -- (bl\blc.west);
  }

\end{tikzpicture}%

\begin{tikzpicture}[%
  mtx/.style = {
    matrix of math nodes,
    % left delimiter = {[},
    % right delimiter = {]},
    nodes = {
      text width = 1.25em,
      text height = 1.5ex,
      align = center,
    }
  },
  edge/.style = {draw, line cap = round, line join = round},
  hltr/.style = {opacity = 0.2, rounded corners = 2pt, inner sep = -1pt},
  txtup/.style = {rotate = 0, above},
  txtbt/.style = {yshift = -1ex}
  ]

  \def\cube{

    \foreach \x in {0, 1} {
      \foreach \y in {0, 1} {
        \foreach \z in {0, 1} {
          \coordinate (v\x\y\z) at (\x, \y, \z);
        }
      }
    }

    \begin{scope}[on background layer]
      \foreach \y in {0, 1} {
        \draw[edge] (v0\y0) -- (v1\y0) -- (v1\y1) -- (v0\y1) -- cycle;
      }
      \foreach \x in {0, 1} {
        \foreach \z in {0, 1} {
          \draw[edge] (v\x0\z) -- (v\x1\z);
        }
      }
    \end{scope}

  } % \cube

  \begin{scope}[->, > = latex]

    \matrix (X) [mtx] {
      1 & - & - & - & + & + & + & - \\
      1 & + & - & - & - & - & + & + \\
      1 & - & + & - & - & + & - & + \\
      1 & + & + & - & + & - & - & - \\
      1 & - & - & + & + & - & - & + \\
      1 & + & - & + & - & + & - & - \\
      1 & - & + & + & - & - & + & - \\
      1 & + & + & + & + & + & + & + \\
    };

    \foreach \col/\lab in {1/I, 2/A, 3/B, 4/C, 5/AB, 6/AC, 7/BC, 8/ABC} {
      \node[txtup] (\lab) at (X-1-\col.north) {$\lab$};
    }

    \node[above = 3em of X-1-8] (I1) {$I = ABC$};
    \path (I1) edge[out = -90, in = 90] (ABC);

    \draw [decorate, -, decoration = {brace, amplitude = 1.0ex}]
      ($(X-8-8.south east) + (0, -0.1)$) -- ($(X-8-8.south west) + (0, -0.1)$)
      node [midway, yshift = -1ex, anchor = north] {2 blocos $\rightarrow$ 1 GL};

  \end{scope}

  \begin{scope}[on background layer]
    \node[hltr, fill = green, fit = (X-1-8)(X-8-8)] {};
  \end{scope}

  \newcommand{\experimentalpoint}[1]{
    \draw[fill = \mycol] (#1) circle (2.5pt);
  }

  \begin{scope}[inner sep = 1ex]

    \begin{scope}[scale = 0.75, xshift = 11cm, yshift = 1cm]
      \node[draw, fill = cyan!50!white] (bl1) at (-3.5, 0.3) {
        \begin{minipage}[c][2.25em]{9em}
          \begin{center}
            Bloco I\\ (1)\quad ab \quad ac \quad bc
          \end{center}
        \end{minipage}
      };
      \cube{}
      \def\mycol{cyan!50!white}
      \experimentalpoint{v111};
      \experimentalpoint{v100};
      \experimentalpoint{v010};
      \experimentalpoint{v001};
    \end{scope}

    \begin{scope}[scale = 0.75, xshift = 11cm, yshift = -1.5cm]
      \node[draw, fill = orange!50!white] (bl2) at (-3.5, 0.3) {
        \begin{minipage}[c][2.25em]{9em}
          \begin{center}
            Bloco II\\ a \quad b \quad c \quad abc
          \end{center}
        \end{minipage}
      };
      \cube{}
      \def\mycol{orange!50!white}
      \experimentalpoint{v000};
      \experimentalpoint{v101};
      \experimentalpoint{v110};
      \experimentalpoint{v011};
    \end{scope}

    \foreach \line in {1, 4, 6, 7} {
      \path[draw, color = cyan] (X-\line-8.east) -- (bl1.west);
    }

    \foreach \line in {2, 3, 5, 8} {
      \path[draw, color = orange] (X-\line-8.east) -- (bl2.west);
    }

  \end{scope}

\end{tikzpicture}%

\begin{tikzpicture}[%
  mtx/.style = {
    matrix of math nodes,
    nodes in empty cells,
    left delimiter = {[},
    right delimiter = {]},
    every node/.style = {
      anchor = base,
      text width = 1em,
      text height = 1.2ex,
      align = right,
      anchor = base east
    }
  },
  hltr/.style = {opacity = 0.2, rounded corners = 2pt, inner sep = -1pt},
  txtup/.style = {rotate = 90, right},
  txtbt/.style = {yshift = -1ex}
]


% # Qualitative.
% da <- expand.grid(A = c("$a_1$", "$a_2$"),
%                   B = c("$b_1$", "$b_2$"),
%                   C = c("$c_1$", "$c_2$"),
%                   KEEP.OUT.ATTRS = FALSE)
% da
% 
% # Quantitative in the original scale.
% da <- expand.grid(A = c(3, 5),
%                   B = c(5, 7),
%                   C = c(1, 2),
%                   KEEP.OUT.ATTRS = FALSE)
% da
% 
% # Codified scale.
% da <- expand.grid(A = c(-1, 1),
%                   B = c(-1, 1),
%                   C = c(-1, 1),
%                   KEEP.OUT.ATTRS = FALSE)
% da
% 
% xtable::print.xtable(xtable::xtable(da, digits = 0),
%                      include.rownames = FALSE,
%                      # include.colnames = FALSE,
%                      only.contents = TRUE,
%                      sanitize.text.function = identity,
%                      comment = FALSE,
%                      hline.after = NULL)
% 
% X <- model.matrix(~A * B * C,
%                   data = da)
% 
% xtable::print.xtable(xtable::xtable(X, digits = 0),
%                      include.rownames = FALSE,
%                      include.colnames = FALSE,
%                      only.contents = TRUE,
%                      comment = FALSE,
%                      hline.after = NULL)
% 
% xtable::print.xtable(xtable::xtable(t(X) %*% X, digits = 0),
%                      include.rownames = FALSE,
%                      include.colnames = FALSE,
%                      only.contents = TRUE,
%                      comment = FALSE,
%                      hline.after = NULL)

\begin{scope}

  \matrix (X) [mtx] {
    1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 
    1 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\ 
    1 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\ 
    1 & 1 & 1 & 0 & 1 & 0 & 0 & 0 \\ 
    1 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ 
    1 & 1 & 0 & 1 & 0 & 1 & 0 & 0 \\ 
    1 & 0 & 1 & 1 & 0 & 0 & 1 & 0 \\ 
    1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\ 
  };

  \node[left=1em of X] (Xequal) {$\Rightarrow X = $};
  \node[right=1em of X] (Xarrow) {$\Rightarrow X^\top X = $};

  \node[left = 2em of X, anchor = east] (tb) {
  \begin{minipage}{3cm}
  \begin{tabular}{rrr}
  \hline
    A & B & C \\ \hline
    $a_1$ & $b_1$ & $c_1$ \\ 
    $a_2$ & $b_1$ & $c_1$ \\ 
    $a_1$ & $b_2$ & $c_1$ \\ 
    $a_2$ & $b_2$ & $c_1$ \\ 
    $a_1$ & $b_1$ & $c_2$ \\ 
    $a_2$ & $b_1$ & $c_2$ \\ 
    $a_1$ & $b_2$ & $c_2$ \\ 
    $a_2$ & $b_2$ & $c_2$ \\ \hline
  \end{tabular}
  \end{minipage}
  };

  \matrix (XX) [mtx, right=1em of Xarrow] {
  8 & 4 & 4 & 4 & 2 & 2 & 2 & 1 \\ 
  4 & 4 & 2 & 2 & 2 & 2 & 1 & 1 \\ 
  4 & 2 & 4 & 2 & 2 & 1 & 2 & 1 \\ 
  4 & 2 & 2 & 4 & 1 & 2 & 2 & 1 \\ 
  2 & 2 & 2 & 1 & 2 & 1 & 1 & 1 \\ 
  2 & 2 & 1 & 2 & 1 & 2 & 1 & 1 \\ 
  2 & 1 & 2 & 2 & 1 & 1 & 2 & 1 \\ 
  1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\ 
  };

  \node[above=2.5em of X-1-1, anchor = south west, align = left] {
    \textbf{Contraste/codifica{\c c}{\~ a}o de tratamento para fatores qualitativos}
  };

  % Efeitos.
  \node[txtup] at (X-1-1.north) {$\mu$};
  \node[txtup] at (X-1-2.north) {$A$};
  \node[txtup] at (X-1-3.north) {$B$};
  \node[txtup] at (X-1-4.north) {$C$};
  \node[txtup] at (X-1-5.north) {$AB$};
  \node[txtup] at (X-1-6.north) {$AC$};
  \node[txtup] at (X-1-7.north) {$BC$};
  \node[txtup] at (X-1-8.north) {$ABC$};

\end{scope}

\begin{scope}[yshift = -6cm]

  \matrix (X) [mtx] {
  1 & 3 & 5 & 1 & 15 & 3 & 5 & 15 \\ 
  1 & 5 & 5 & 1 & 25 & 5 & 5 & 25 \\ 
  1 & 3 & 7 & 1 & 21 & 3 & 7 & 21 \\ 
  1 & 5 & 7 & 1 & 35 & 5 & 7 & 35 \\ 
  1 & 3 & 5 & 2 & 15 & 6 & 10 & 30 \\ 
  1 & 5 & 5 & 2 & 25 & 10 & 10 & 50 \\ 
  1 & 3 & 7 & 2 & 21 & 6 & 14 & 42 \\ 
  1 & 5 & 7 & 2 & 35 & 10 & 14 & 70 \\ 
  };

  \node[left=1em of X] (Xequal) {$\Rightarrow X = $};
  \node[right=1em of X] (Xarrow) {$\Rightarrow X^\top X = $};

  \node[left = 2em of X, anchor = east] (tb) {
  \begin{minipage}{3cm}
  \begin{tabular}{rrr}
  \hline
    A & B & C \\ \hline
    3 & 5 & 1 \\ 
    5 & 5 & 1 \\ 
    3 & 7 & 1 \\ 
    5 & 7 & 1 \\ 
    3 & 5 & 2 \\ 
    5 & 5 & 2 \\ 
    3 & 7 & 2 \\ 
    5 & 7 & 2 \\ \hline
  \end{tabular}
  \end{minipage}
  };

  \matrix (XX) [mtx, right=1em of Xarrow,
    every node/.style = {text width = 2em, align = right},
  ] {
  8 & 32 & 48 & 12 & 192 & 48 & 72 & 288 \\ 
  32 & 136 & 192 & 48 & 816 & 204 & 288 & 1224 \\ 
  48 & 192 & 296 & 72 & 1184 & 288 & 444 & 1776 \\ 
  12 & 48 & 72 & 20 & 288 & 80 & 120 & 480 \\ 
  192 & 816 & 1184 & 288 & 5032 & 1224 & 1776 & 7548 \\ 
  48 & 204 & 288 & 80 & 1224 & 340 & 480 & 2040 \\ 
  72 & 288 & 444 & 120 & 1776 & 480 & 740 & 2960 \\ 
  288 & 1224 & 1776 & 480 & 7548 & 2040 & 2960 & 12580 \\ 
 };

  \node[above=2.5em of X-1-1, anchor = south west, align = left] {
    \textbf{Fatores quantitativos na escala original}
  };

  % Efeitos.
  \node[txtup] at (X-1-1.north) {$\mu$};
  \node[txtup] at (X-1-2.north) {$A$};
  \node[txtup] at (X-1-3.north) {$B$};
  \node[txtup] at (X-1-4.north) {$C$};
  \node[txtup] at (X-1-5.north) {$AB$};
  \node[txtup] at (X-1-6.north) {$AC$};
  \node[txtup] at (X-1-7.north) {$BC$};
  \node[txtup] at (X-1-8.north) {$ABC$};

\end{scope}

\begin{scope}[yshift = -12cm]

  \matrix (X) [mtx] {
  1 & -1 & -1 & -1 & 1 & 1 & 1 & -1 \\ 
  1 & 1 & -1 & -1 & -1 & -1 & 1 & 1 \\ 
  1 & -1 & 1 & -1 & -1 & 1 & -1 & 1 \\ 
  1 & 1 & 1 & -1 & 1 & -1 & -1 & -1 \\ 
  1 & -1 & -1 & 1 & 1 & -1 & -1 & 1 \\ 
  1 & 1 & -1 & 1 & -1 & 1 & -1 & -1 \\ 
  1 & -1 & 1 & 1 & -1 & -1 & 1 & -1 \\ 
  1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\ 
  };

  \node[left=1em of X] (Xequal) {$X = $};
  \node[right=1em of X] (Xarrow) {$\Rightarrow X^\top X = $};

  \matrix (XX) [mtx, right=1em of Xarrow] {
  8 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 
  0 & 8 & 0 & 0 & 0 & 0 & 0 & 0 \\ 
  0 & 0 & 8 & 0 & 0 & 0 & 0 & 0 \\ 
  0 & 0 & 0 & 8 & 0 & 0 & 0 & 0 \\ 
  0 & 0 & 0 & 0 & 8 & 0 & 0 & 0 \\ 
  0 & 0 & 0 & 0 & 0 & 8 & 0 & 0 \\ 
  0 & 0 & 0 & 0 & 0 & 0 & 8 & 0 \\ 
  0 & 0 & 0 & 0 & 0 & 0 & 0 & 8 \\ 
 };

  \node[above=2.5em of X-1-1, anchor = south west, align = left] {
    \textbf{Fatores na escala codificada}
  };

  % Efeitos.
  \node[txtup] at (X-1-1.north) {$\mu$};
  \node[txtup] at (X-1-2.north) {$A$};
  \node[txtup] at (X-1-3.north) {$B$};
  \node[txtup] at (X-1-4.north) {$C$};
  \node[txtup] at (X-1-5.north) {$AB$};
  \node[txtup] at (X-1-6.north) {$AC$};
  \node[txtup] at (X-1-7.north) {$BC$};
  \node[txtup] at (X-1-8.north) {$ABC$};

\end{scope}

\end{tikzpicture}%

\begin{tikzpicture}[%
  mtx/.style = {
    matrix of math nodes,
    nodes in empty cells,
    left delimiter = {[},
    right delimiter = {]},
    every node/.style = {
      anchor = base,
      text width = 1em,
      text height = 1.2ex,
      align = right,
      anchor = base east
    }
  },
  every path/.style = {> = latex},
  hltr/.style = {opacity = 0.2, rounded corners = 2pt, inner sep = -1pt},
  txtup/.style = {rotate = 90, right},
  txtbt/.style = {yshift = -1ex}
]


% # Qualitative.
% da <- expand.grid(A = c("$a_1$", "$a_2$"),
%                   B = c("$b_1$", "$b_2$"),
%                   C = c("$c_1$", "$c_2$"),
%                   KEEP.OUT.ATTRS = FALSE)
% da
% 
% # Quantitative in the original scale.
% da <- expand.grid(A = c(3, 5),
%                   B = c(5, 7),
%                   C = c(1, 2),
%                   KEEP.OUT.ATTRS = FALSE)
% da
% 
% # Codified scale.
% da <- expand.grid(A = c(-1, 1),
%                   B = c(-1, 1),
%                   C = c(-1, 1),
%                   KEEP.OUT.ATTRS = FALSE)
% da
% 
% xtable::print.xtable(xtable::xtable(da, digits = 0),
%                      include.rownames = FALSE,
%                      # include.colnames = FALSE,
%                      only.contents = TRUE,
%                      sanitize.text.function = identity,
%                      comment = FALSE,
%                      hline.after = NULL)
% 
% X <- model.matrix(~A * B * C,
%                   data = da)
% 
% xtable::print.xtable(xtable::xtable(X, digits = 0),
%                      include.rownames = FALSE,
%                      include.colnames = FALSE,
%                      only.contents = TRUE,
%                      comment = FALSE,
%                      hline.after = NULL)
% 
% xtable::print.xtable(xtable::xtable(t(X) %*% X, digits = 0),
%                      include.rownames = FALSE,
%                      include.colnames = FALSE,
%                      only.contents = TRUE,
%                      comment = FALSE,
%                      hline.after = NULL)

\begin{scope}

  \matrix (X) [mtx] {
  1 & -1 & -1 & -1 & 1 & 1 & 1 & -1 \\ 
  1 & 1 & -1 & -1 & -1 & -1 & 1 & 1 \\ 
  1 & -1 & 1 & -1 & -1 & 1 & -1 & 1 \\ 
  1 & 1 & 1 & -1 & 1 & -1 & -1 & -1 \\ 
  1 & -1 & -1 & 1 & 1 & -1 & -1 & 1 \\ 
  1 & 1 & -1 & 1 & -1 & 1 & -1 & -1 \\ 
  1 & -1 & 1 & 1 & -1 & -1 & 1 & -1 \\ 
  1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\ 
  };

  \node[left=1em of X] (Xequal) {$\Rightarrow X = $};
  \node[right=1em of X] (Xarrow) {$\Rightarrow X^\top X = $};

  \node[left = 2em of X, anchor = east] (tb) {
  \begin{minipage}{4.25cm}
  \begin{tabular}{rrrr}
  \hline
  nom. & A & B & C \\ \hline
  $(1)$ & $a_1$ & $b_1$ & $c_1$ \\ 
  $a$   & $a_2$ & $b_1$ & $c_1$ \\ 
  $b$   & $a_1$ & $b_2$ & $c_1$ \\ 
  $ab$  & $a_2$ & $b_2$ & $c_1$ \\ 
  $c$   & $a_1$ & $b_1$ & $c_2$ \\ 
  $ac$  & $a_2$ & $b_1$ & $c_2$ \\ 
  $bc$  & $a_1$ & $b_2$ & $c_2$ \\ 
  $abc$ & $a_2$ & $b_2$ & $c_2$ \\ \hline
  \end{tabular}
  \end{minipage}
  };

  \matrix (XX) [mtx, right=1em of Xarrow] {
  8 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 
  0 & 8 & 0 & 0 & 0 & 0 & 0 & 0 \\ 
  0 & 0 & 8 & 0 & 0 & 0 & 0 & 0 \\ 
  0 & 0 & 0 & 8 & 0 & 0 & 0 & 0 \\ 
  0 & 0 & 0 & 0 & 8 & 0 & 0 & 0 \\ 
  0 & 0 & 0 & 0 & 0 & 8 & 0 & 0 \\ 
  0 & 0 & 0 & 0 & 0 & 0 & 8 & 0 \\ 
  0 & 0 & 0 & 0 & 0 & 0 & 0 & 8 \\ 
  };

  % Efeitos.
  \node[txtup] at (X-1-1.north) {$\mu$};
  \node[txtup] at (X-1-2.north) {$A$};
  \node[txtup] at (X-1-3.north) {$B$};
  \node[txtup] at (X-1-4.north) {$C$};
  \node[txtup] at (X-1-5.north) {$AB$};
  \node[txtup] at (X-1-6.north) {$AC$};
  \node[txtup] at (X-1-7.north) {$BC$};
  \node[txtup] at (X-1-8.north) {$ABC$};

  \begin{scope}[on background layer]
    \node[hltr, fill = gray, fit = (X-1-2) (X-8-2)] {};
  \end{scope}

  \matrix (Xtrans) [mtx, below = 6em of X, xshift = -3cm] {
  1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\ 
  -1 & 1 & -1 & 1 & -1 & 1 & -1 & 1 \\ 
  -1 & -1 & 1 & 1 & -1 & -1 & 1 & 1 \\ 
  -1 & -1 & -1 & -1 & 1 & 1 & 1 & 1 \\ 
  1 & -1 & -1 & 1 & 1 & -1 & -1 & 1 \\ 
  1 & -1 & 1 & -1 & -1 & 1 & -1 & 1 \\ 
  1 & 1 & -1 & -1 & -1 & -1 & 1 & 1 \\ 
  -1 & 1 & 1 & -1 & 1 & -1 & -1 & 1 \\ 
  };

  \begin{scope}[on background layer]
    \node[hltr, fill = gray, fit = (Xtrans-2-1) (Xtrans-2-8)] {};
  \end{scope}

  \path[->] (X-8-2) edge[out = -90, in = 120] (Xtrans-2-1);

  \matrix (y) [mtx, right = 1.5em of Xtrans] {
  $y_{(1)}$ \\ 
  $y_{a}$ \\ 
  $y_{b}$ \\ 
  $y_{ab}$ \\ 
  $y_{c}$ \\ 
  $y_{ac}$ \\ 
  $y_{bc}$ \\ 
  $y_{abc}$ \\ 
  };

  \node[left = 1em of Xtrans] {$(X^\top X)^{-1} X^\top y = \displaystyle \frac{1}{8} \cdot$};
  \node[right = 1em of y] (Xy) {$ = \displaystyle \frac{1}{8} \cdot$};

  \matrix (beta) [mtx, right = 1em of Xy, every node/.style = {text width = 19em}] {
  $y_{(1)} + y_{a} + y_{b} + y_{ab} + y_{c} + y_{ac} + y_{bc} + y_{abc}$\\
  $\textcolor{orange!80!black}{(y_{a} + y_{ab} + y_{ac} + y_{abc})} - \textcolor{blue!80!black}{(y_{(1)} + y_{b} + y_{c} + y_{bc})}$\\
  $\textcolor{orange!80!black}{(y_{b} + y_{ab} + y_{bc} + y_{abc})} - \textcolor{blue!80!black}{(y_{(1)} + y_{a} + y_{c} + y_{ac})}$\\
  $\textcolor{orange!80!black}{(y_{c} + y_{ac} + y_{bc} + y_{abc})} - \textcolor{blue!80!black}{(y_{(1)} + y_{a} + y_{b} + y_{ab})}$\\
  $\textcolor{orange!80!black}{(y_{(1)} + y_{ab} + y_{c} + y_{abc})} - \textcolor{blue!80!black}{(y_{a} + y_{b} + y_{ac} + y_{bc})}$\\
  $\textcolor{orange!80!black}{(y_{(1)} + y_{b} + y_{ac} + y_{abc})} - \textcolor{blue!80!black}{(y_{a} + y_{ab} + y_{c} + y_{bc})}$\\
  $\textcolor{orange!80!black}{(y_{(1)} + y_{a} + y_{bc} + y_{abc})} - \textcolor{blue!80!black}{(y_{b} + y_{ab} + y_{c} + y_{ac})}$\\
  $\textcolor{orange!80!black}{(y_{a} + y_{b} + y_{c} + y_{abc})} - \textcolor{blue!80!black}{(y_{(1)} + y_{ab} + y_{ac} + y_{bc})}$\\
  };

  \node (ef) at ($(beta-2-1.east) + (-1.5, 1.5)$) {Efeito de A};
  \path[->] (beta-2-1.east) edge[out = 45, in = 0] (ef);

  \begin{scope}[on background layer]
    \node[hltr, fill = gray, fit = (beta-2-1) (beta-2-1)] {};
  \end{scope}

\end{scope}

\end{tikzpicture}%

\begin{tikzpicture}[%
  mtx/.style = {
    matrix of math nodes,
    nodes in empty cells,
    left delimiter = {[},
    right delimiter = {]},
    every node/.style = {
      anchor = base,
      text width = 1.8em,
      text height = 1.2ex,
      align = right,
      anchor = base east
    }
  },
  every path/.style = {> = latex},
  hltr/.style = {opacity = 0.2, rounded corners = 2pt, inner sep = -1pt},
  txtup/.style = {rotate = 90, right},
  txtbt/.style = {yshift = -1ex}
]

\begin{scope}

  \matrix (H1) [mtx] {
  1/4 & 0 & 1/4 & 0 & 1/4 & 0 & 1/4 & 0 \\ 
  0 & 1/4 & 0 & 1/4 & 0 & 1/4 & 0 & 1/4 \\ 
  1/4 & 0 & 1/4 & 0 & 1/4 & 0 & 1/4 & 0 \\ 
  0 & 1/4 & 0 & 1/4 & 0 & 1/4 & 0 & 1/4 \\ 
  1/4 & 0 & 1/4 & 0 & 1/4 & 0 & 1/4 & 0 \\ 
  0 & 1/4 & 0 & 1/4 & 0 & 1/4 & 0 & 1/4 \\ 
  1/4 & 0 & 1/4 & 0 & 1/4 & 0 & 1/4 & 0 \\ 
  0 & 1/4 & 0 & 1/4 & 0 & 1/4 & 0 & 1/4 \\ 
  };

  \node[left = 1em of H1] {$H_{\mu, A} - H_{\mu} = $};
  \node[right = 1em of H1] (H1minusH0) {$ - $};

  \matrix (H0) [mtx, right = 1em of H1minusH0] {
  1/8 & 1/8 & 1/8 & 1/8 & 1/8 & 1/8 & 1/8 & 1/8 \\ 
  1/8 & 1/8 & 1/8 & 1/8 & 1/8 & 1/8 & 1/8 & 1/8 \\ 
  1/8 & 1/8 & 1/8 & 1/8 & 1/8 & 1/8 & 1/8 & 1/8 \\ 
  1/8 & 1/8 & 1/8 & 1/8 & 1/8 & 1/8 & 1/8 & 1/8 \\ 
  1/8 & 1/8 & 1/8 & 1/8 & 1/8 & 1/8 & 1/8 & 1/8 \\ 
  1/8 & 1/8 & 1/8 & 1/8 & 1/8 & 1/8 & 1/8 & 1/8 \\ 
  1/8 & 1/8 & 1/8 & 1/8 & 1/8 & 1/8 & 1/8 & 1/8 \\ 
  1/8 & 1/8 & 1/8 & 1/8 & 1/8 & 1/8 & 1/8 & 1/8 \\ 
  };

  \matrix (H1H0) [mtx, below = 1em of H1] {
  1/8 & -1/8 & 1/8 & -1/8 & 1/8 & -1/8 & 1/8 & -1/8 \\ 
  -1/8 & 1/8 & -1/8 & 1/8 & -1/8 & 1/8 & -1/8 & 1/8 \\ 
  1/8 & -1/8 & 1/8 & -1/8 & 1/8 & -1/8 & 1/8 & -1/8 \\ 
  -1/8 & 1/8 & -1/8 & 1/8 & -1/8 & 1/8 & -1/8 & 1/8 \\ 
  1/8 & -1/8 & 1/8 & -1/8 & 1/8 & -1/8 & 1/8 & -1/8 \\ 
  -1/8 & 1/8 & -1/8 & 1/8 & -1/8 & 1/8 & -1/8 & 1/8 \\ 
  1/8 & -1/8 & 1/8 & -1/8 & 1/8 & -1/8 & 1/8 & -1/8 \\ 
  -1/8 & 1/8 & -1/8 & 1/8 & -1/8 & 1/8 & -1/8 & 1/8 \\ 
  };

  \node[left = 1em of H1H0] {$H_{\mu, A} - H_{\mu} = $};

  \node (times1) at (6, -3.5) {4x};
  \node[below = 1em of times1] (times2) {4x};
  \foreach \x in {1,3,...,7} {
     \path[color = blue] (H1H0-\x-8.east) edge (times1.west);
  }
  \foreach \x in {2,4,...,8} {
     \path[color = orange] (H1H0-\x-8.east) edge (times2.west);
  }

  \begin{scope}[on background layer]
    \node[hltr, fill = blue, fit = (H1-1-1) (H1-1-8)] {};
    \node[hltr, fill = orange, fit = (H1-2-1) (H1-2-8)] {};
    \node[hltr, fill = blue, fit = (H1-3-1) (H1-3-8)] {};
    \node[hltr, fill = orange, fit = (H1-4-1) (H1-4-8)] {};
    \node[hltr, fill = blue, fit = (H1-5-1) (H1-5-8)] {};
    \node[hltr, fill = orange, fit = (H1-6-1) (H1-6-8)] {};
    \node[hltr, fill = blue, fit = (H1-7-1) (H1-7-8)] {};
    \node[hltr, fill = orange, fit = (H1-8-1) (H1-8-8)] {};
  \end{scope}

  \begin{scope}[on background layer]
    \node[hltr, fill = blue, fit = (H1H0-1-1) (H1H0-1-8)] {};
    \node[hltr, fill = orange, fit = (H1H0-2-1) (H1H0-2-8)] {};
    \node[hltr, fill = blue, fit = (H1H0-3-1) (H1H0-3-8)] {};
    \node[hltr, fill = orange, fit = (H1H0-4-1) (H1H0-4-8)] {};
    \node[hltr, fill = blue, fit = (H1H0-5-1) (H1H0-5-8)] {};
    \node[hltr, fill = orange, fit = (H1H0-6-1) (H1H0-6-8)] {};
    \node[hltr, fill = blue, fit = (H1H0-7-1) (H1H0-7-8)] {};
    \node[hltr, fill = orange, fit = (H1H0-8-1) (H1H0-8-8)] {};
  \end{scope}

  \begin{scope}

  \matrix (yH1H0y) [mtx, below = 2.5em of H1H0, xshift = 1.64cm] {
  1/8 & -1/8 & 1/8 & -1/8 & 1/8 & -1/8 & 1/8 & -1/8 \\ 
  -1/8 & 1/8 & -1/8 & 1/8 & -1/8 & 1/8 & -1/8 & 1/8 \\ 
  1/8 & -1/8 & 1/8 & -1/8 & 1/8 & -1/8 & 1/8 & -1/8 \\ 
  -1/8 & 1/8 & -1/8 & 1/8 & -1/8 & 1/8 & -1/8 & 1/8 \\ 
  1/8 & -1/8 & 1/8 & -1/8 & 1/8 & -1/8 & 1/8 & -1/8 \\ 
  -1/8 & 1/8 & -1/8 & 1/8 & -1/8 & 1/8 & -1/8 & 1/8 \\ 
  1/8 & -1/8 & 1/8 & -1/8 & 1/8 & -1/8 & 1/8 & -1/8 \\ 
  -1/8 & 1/8 & -1/8 & 1/8 & -1/8 & 1/8 & -1/8 & 1/8 \\ 
  };

  \matrix (yH) [mtx, left = 1.5em of yH1H0y] {
  $y_{(1)}$ \\ 
  $y_{a}$ \\ 
  $y_{b}$ \\ 
  $y_{ab}$ \\ 
  $y_{c}$ \\ 
  $y_{ac}$ \\ 
  $y_{bc}$ \\ 
  $y_{abc}$ \\ 
  };

  \node[left = 1em of yH] {$y^\top (H_{\mu, A} - H_{\mu}) y = $};

  \node at ($(yH-1-1) + (0.9, 0.5)$) {$\top$};

  \matrix (Hy) [mtx, right = 1.5em of yH1H0y] {
  $y_{(1)}$ \\ 
  $y_{a}$ \\ 
  $y_{b}$ \\ 
  $y_{ab}$ \\ 
  $y_{c}$ \\ 
  $y_{ac}$ \\ 
  $y_{bc}$ \\ 
  $y_{abc}$ \\ 
  };

  \end{scope}

  \begin{scope}[yshift = -12.5cm, xshift = 1.7cm]

  \node {
    $
    SS_{A} = y^\top (H_{\mu, A} - H_{\mu}) y = 
    \displaystyle\frac{ 
      \left[ (y_{a} + y_{ab} + y_{ac} + y_{abc}) - (y_{(1)} + y_{b} + y_{c} + y_{bc})
      \right]^2}{
      8} = \frac{\text{Contraste}^2}{r2^k}
    $
  };

  \end{scope}

\end{scope}

\end{tikzpicture}%

\begin{tikzpicture}[%
  mtx/.style = {
    matrix of math nodes,
    nodes in empty cells,
    left delimiter = {[},
    right delimiter = {]},
    every node/.style = {
      anchor = base,
      text width = 1em,
      text height = 1.2ex,
      align = right,
      anchor = base east
    }
  },
  hltr/.style = {opacity = 0.2, rounded corners = 2pt, inner sep = -1pt},
  txtup/.style = {rotate = 90, right},
  txtbt/.style = {yshift = -1ex}
]

\begin{scope}

  \matrix (X) at (0, 0) [mtx] {
    1 & 1 & . & . & 1 & . & 1 & . & . & . & . & . \\
    1 & . & 1 & . & 1 & . & . & 1 & . & . & . & . \\
    1 & . & . & 1 & 1 & . & . & . & 1 & . & . & . \\
    1 & 1 & . & . & . & 1 & . & . & . & 1 & . & . \\
    1 & . & 1 & . & . & 1 & . & . & . & . & 1 & . \\
    1 & . & . & 1 & . & 1 & . & . & . & . & . & 1 \\
  };

  \node[left=1em of X] (Xequal) {$X = $};
  \node[right=1em of X] (Xarrow) {$\Rightarrow X = $};

  \node[above=5em of Xequal, anchor = south west, align = left] {
    \textbf{Contraste tratamento}\\
    $\theta_1 = 0$ para $\theta = \alpha, \beta$.
  };

  % Efeitos.
  \node[txtup] at (X-1-1.north) {$\mu$};
  \node[txtup] at (X-1-2.north) {$\alpha_1$};
  \node[txtup] at (X-1-3.north) {$\alpha_2$};
  \node[txtup] at (X-1-4.north) {$\alpha_3$};
  \node[txtup] at (X-1-5.north) {$\beta_1$};
  \node[txtup] at (X-1-6.north) {$\beta_2$};
  \node[txtup] at (X-1-7.north) {$\gamma_{11}$};
  \node[txtup] at (X-1-8.north) {$\gamma_{21}$};
  \node[txtup] at (X-1-9.north) {$\gamma_{31}$};
  \node[txtup] at (X-1-10.north) {$\gamma_{12}$};
  \node[txtup] at (X-1-11.north) {$\gamma_{22}$};
  \node[txtup] at (X-1-12.north) {$\gamma_{32}$};

  % Restricoes.
  \draw (X-6-2.south) |- +(0.25, -1em) node[right] {$\alpha_1 = 0$};
  \draw (X-6-5.south) |- +(0.25, -1em) node[right] {$\beta_1 = 0$};

  % Colunas de efeitos.
  \begin{scope}[on background layer]
  \node[hltr, fill = orange, fit = (X-1-2)(X-6-4)] {};
  \node[hltr, fill = purple, fit = (X-1-5)(X-6-6)] {};
  \node[hltr, fill = gray,   fit = (X-1-7)(X-6-12)] {};
  \end{scope}

  \matrix (XX) [mtx, right = 1em of Xarrow] {
  1 & . & . & . & . & . \\ 
  1 & 1 & . & . & . & . \\ 
  1 & . & 1 & . & . & . \\ 
  1 & . & . & 1 & . & . \\ 
  1 & 1 & . & 1 & 1 & . \\ 
  1 & . & 1 & 1 & . & 1 \\ 
  };

  % Efeitos.
  \node[txtup] at (XX-1-1.north) {$\mu$};
  \node[txtup] at (XX-1-2.north) {$\alpha_2$};
  \node[txtup] at (XX-1-3.north) {$\alpha_3$};
  \node[txtup] at (XX-1-4.north) {$\beta_2$};
  \node[txtup] at (XX-1-5.north) {$\gamma_{22}$};
  \node[txtup] at (XX-1-6.north) {$\gamma_{32}$};

  % Colunas de efeitos.
  \begin{scope}[on background layer]
  \node[hltr, fill = orange, fit = (XX-1-2)(XX-6-3)] {};
  \node[hltr, fill = purple, fit = (XX-1-4)(XX-6-4)] {};
  \node[hltr, fill = gray,   fit = (XX-1-5)(XX-6-6)] {};
  \end{scope}

  \draw ($(XX-6-1.west)+(0, -.40)$) |- +(0, -0.1) -- ($(XX-6-1.east)+(0, -.50)$) node[right] {$X_{\mu}$} -- +(0, 0.1);

  \draw ($(XX-6-1.west)+(0, -.80)$) |- +(0, -0.1) -- ($(XX-6-3.east)+(0, -.90)$) node[right] {$X_{\mu:\alpha}$} -- +(0, 0.1);
  \draw ($(XX-6-1.west)+(0, -1.2)$) |- +(0, -0.1) -- ($(XX-6-4.east)+(0, -1.3)$) node[right] {$X_{\mu:\beta}$} -- +(0, 0.1);
  \draw ($(XX-6-1.west)+(0, -1.6)$) |- +(0, -0.1) -- ($(XX-6-6.east)+(0, -1.7)$) node[right] {$X_{\mu:\gamma}$} -- +(0, 0.1);

\end{scope}


\begin{scope}[yshift = -7cm]

  \matrix (X) at (0, 0) [mtx] {
    1 & 1 & . & . & 1 & . & 1 & . & . & . & . & . \\
    1 & . & 1 & . & 1 & . & . & 1 & . & . & . & . \\
    1 & . & . & 1 & 1 & . & . & . & 1 & . & . & . \\
    1 & 1 & . & . & . & 1 & . & . & . & 1 & . & . \\
    1 & . & 1 & . & . & 1 & . & . & . & . & 1 & . \\
    1 & . & . & 1 & . & 1 & . & . & . & . & . & 1 \\
  };

  \node[left=1em of X] (Xequal) {$X = $};
  \node[right=1em of X] (Xarrow) {$\Rightarrow X = $};

  \node[above=5em of Xequal, anchor = south west, align = left] {
    \textbf{Contraste soma zero}\\
    $\theta_k = -\displaystyle\sum_{i = 1}^{k - 1} \theta_i$ para $\theta = \alpha, \beta$
    e $k$ {\' e} o n{\' u}mero de n{\' i}veis.
  };

  % Efeitos.
  \node[txtup] at (X-1-1.north) {$\mu$};
  \node[txtup] at (X-1-2.north) {$\alpha_1$};
  \node[txtup] at (X-1-3.north) {$\alpha_2$};
  \node[txtup] at (X-1-4.north) {$\alpha_3$};
  \node[txtup] at (X-1-5.north) {$\beta_1$};
  \node[txtup] at (X-1-6.north) {$\beta_2$};
  \node[txtup] at (X-1-7.north) {$\gamma_{11}$};
  \node[txtup] at (X-1-8.north) {$\gamma_{21}$};
  \node[txtup] at (X-1-9.north) {$\gamma_{31}$};
  \node[txtup] at (X-1-10.north) {$\gamma_{12}$};
  \node[txtup] at (X-1-11.north) {$\gamma_{22}$};
  \node[txtup] at (X-1-12.north) {$\gamma_{32}$};

  % Restricoes.
  \draw (X-6-4.south) |- +(0.25, -2.5em) node[right] {$\alpha_3 = -(\alpha_1 + \alpha_2)$};
  \draw (X-6-6.south) |- +(0.25, -1em) node[right] {$\beta_2 = -\beta_1$};

  % Colunas de efeitos.
  \begin{scope}[on background layer]
  \node[hltr, fill = orange, fit = (X-1-2)(X-6-4)] {};
  \node[hltr, fill = purple, fit = (X-1-5)(X-6-6)] {};
  \node[hltr, fill = gray,   fit = (X-1-7)(X-6-12)] {};
  \end{scope}

  \matrix (XX) [mtx, right = 1em of Xarrow] {
  1 & 1 & . & 1 & 1 & . \\ 
  1 & . & 1 & 1 & . & 1 \\ 
  1 & -1 & -1 & 1 & -1 & -1 \\ 
  1 & 1 & . & -1 & -1 & . \\ 
  1 & . & 1 & -1 & . & -1 \\ 
  1 & -1 & -1 & -1 & 1 & 1 \\ 
  };

  % Efeitos.
  \node[txtup] at (XX-1-1.north) {$\mu$};
  \node[txtup] at (XX-1-2.north) {$\alpha_1$};
  \node[txtup] at (XX-1-3.north) {$\alpha_2$};
  \node[txtup] at (XX-1-4.north) {$\beta_1$};
  \node[txtup] at (XX-1-5.north) {$\gamma_{11}$};
  \node[txtup] at (XX-1-6.north) {$\gamma_{21}$};

  % Colunas de efeitos.
  \begin{scope}[on background layer]
  \node[hltr, fill = orange, fit = (XX-1-2)(XX-6-3)] {};
  \node[hltr, fill = purple, fit = (XX-1-4)(XX-6-4)] {};
  \node[hltr, fill = gray,   fit = (XX-1-5)(XX-6-6)] {};
  \end{scope}

  \draw ($(XX-6-1.west)+(0, -.40)$) |- +(0, -0.1) -- ($(XX-6-1.east)+(0, -.50)$) node[right] {$X_{\mu}$} -- +(0, 0.1);

  \draw ($(XX-6-1.west)+(0, -.80)$) |- +(0, -0.1) -- ($(XX-6-3.east)+(0, -.90)$) node[right] {$X_{\mu:\alpha}$} -- +(0, 0.1);
  \draw ($(XX-6-1.west)+(0, -1.2)$) |- +(0, -0.1) -- ($(XX-6-4.east)+(0, -1.3)$) node[right] {$X_{\mu:\beta}$} -- +(0, 0.1);
  \draw ($(XX-6-1.west)+(0, -1.6)$) |- +(0, -0.1) -- ($(XX-6-6.east)+(0, -1.7)$) node[right] {$X_{\mu:\gamma}$} -- +(0, 0.1);

\end{scope}


\begin{scope}[yshift = -14cm]

  \matrix (X) at (0, 0) [mtx] {
    1 & 1 & . & . & 1 & . & 1 & . & . & . & . & . \\
    1 & . & 1 & . & 1 & . & . & 1 & . & . & . & . \\
    1 & . & . & 1 & 1 & . & . & . & 1 & . & . & . \\
    1 & 1 & . & . & . & 1 & . & . & . & 1 & . & . \\
    1 & . & 1 & . & . & 1 & . & . & . & . & 1 & . \\
    1 & . & . & 1 & . & 1 & . & . & . & . & . & 1 \\
  };

  \node[left=1em of X] (Xequal) {$X = $};
  \node[right=1em of X] (Xarrow) {$\Rightarrow X = $};

  \node[above=5em of Xequal, anchor = south west, align = left] {
    \textbf{Contraste de Helmert}\\
    $(u - 1) \theta_u = -\displaystyle\sum_{i = 1}^{u - 1} \theta_i$ para $\theta = \alpha, \beta$
    sendo $u = 2, \ldots, k$ e $k$ {\' e} o n{\' u}mero de n{\' i}veis.
  };

  % Efeitos.
  \node[txtup] at (X-1-1.north) {$\mu$};
  \node[txtup] (alpha1) at (X-1-2.north) {$\alpha_1$};
  \node[txtup] (alpha2) at (X-1-3.north) {$\alpha_2$};
  \node[txtup] at (X-1-4.north) {$\alpha_3$};
  \node[txtup] (beta1) at (X-1-5.north) {$\beta_1$};
  \node[txtup] at (X-1-6.north) {$\beta_2$};
  \node[txtup] at (X-1-7.north) {$\gamma_{11}$};
  \node[txtup] at (X-1-8.north) {$\gamma_{21}$};
  \node[txtup] at (X-1-9.north) {$\gamma_{31}$};
  \node[txtup] at (X-1-10.north) {$\gamma_{12}$};
  \node[txtup] at (X-1-11.north) {$\gamma_{22}$};
  \node[txtup] at (X-1-12.north) {$\gamma_{32}$};

  % Restricoes.
  \draw (X-6-2.south) |- +(0.25, -4.0em) node[right] {$-\alpha_1 = \alpha_2$};
  \draw (X-6-3.south) |- +(0.25, -2.5em) node[right] {$-(\alpha_1 + \alpha_2) = 2\alpha_3$};
  \draw (X-6-5.south) |- +(0.25, -1.0em) node[right] {$-\beta_1 = \beta_2$};

  % Colunas de efeitos.
  \begin{scope}[on background layer]
  \node[hltr, fill = orange, fit = (X-1-2)(X-6-4)] {};
  \node[hltr, fill = purple, fit = (X-1-5)(X-6-6)] {};
  \node[hltr, fill = gray,   fit = (X-1-7)(X-6-12)] {};
  \end{scope}

  \matrix (XX) [mtx, right = 1em of Xarrow] {
    1 & -1 & -1 & -1 & 1 & 1 \\
    1 & 1 & -1 & -1 & -1 & 1 \\
    1 & . & 2 & -1 & . & -2 \\
    1 & -1 & -1 & 1 & -1 & -1 \\
    1 & 1 & -1 & 1 & 1 & -1 \\
    1 & . & 2 & 1 & . & 2 \\
  };

  % Efeitos.
  \node[txtup] at (XX-1-1.north) {$\mu$};
  \node[txtup] at (XX-1-2.north) {$\alpha_1$};
  \node[txtup] at (XX-1-3.north) {$\alpha_2$};
  \node[txtup] at (XX-1-4.north) {$\beta_1$};
  \node[txtup] at (XX-1-5.north) {$\gamma_{11}$};
  \node[txtup] at (XX-1-6.north) {$\gamma_{21}$};

  % Colunas de efeitos.
  \begin{scope}[on background layer]
  \node[hltr, fill = orange, fit = (XX-1-2)(XX-6-3)] {};
  \node[hltr, fill = purple, fit = (XX-1-4)(XX-6-4)] {};
  \node[hltr, fill = gray,   fit = (XX-1-5)(XX-6-6)] {};
  \end{scope}

  \draw ($(XX-6-1.west)+(0, -.40)$) |- +(0, -0.1) -- ($(XX-6-1.east)+(0, -.50)$) node[right] {$X_{\mu}$} -- +(0, 0.1);

  \draw ($(XX-6-1.west)+(0, -.80)$) |- +(0, -0.1) -- ($(XX-6-3.east)+(0, -.90)$) node[right] {$X_{\mu:\alpha}$} -- +(0, 0.1);
  \draw ($(XX-6-1.west)+(0, -1.2)$) |- +(0, -0.1) -- ($(XX-6-4.east)+(0, -1.3)$) node[right] {$X_{\mu:\beta}$} -- +(0, 0.1);
  \draw ($(XX-6-1.west)+(0, -1.6)$) |- +(0, -0.1) -- ($(XX-6-6.east)+(0, -1.7)$) node[right] {$X_{\mu:\gamma}$} -- +(0, 0.1);

\end{scope}

\end{tikzpicture}%