[Tex/LaTex] How to create a probability space diagram

diagramsgraphics

I would like to create graphs similar to the one shown below using LaTeX. Is it possible to create such a graph? If so, which tools / libraries / techniques can I use to be able to do it?

Probability Space

Best Answer

Final version

Here's the full image in a A4 page. You only need to fill the missing lines connecting the two groups, s# and f#. Remember that the counting start from the bottom, so f1/s1 is the lowest node.

Note that the "thick" arrows/visible overlapping is only a PDF viewer issue.

Output

enter image description here

Code

\documentclass[12pt, a4paper]{article}
\usepackage{amssymb}
\usepackage{mathrsfs}
\usepackage{tikz}

\usetikzlibrary{calc,fit, shapes,chains, arrows.meta}

\newcommand\myarrow[2]{
    \path (#1) coordinate (a1) --++ (6,0) coordinate (a2);
    \coordinate (int) at (intersection of a1--a2 and #2--b#2);
    \draw[rounded corners,very thin,->] (#1) -- (int) -- (#2);
}

\begin{document}
\begin{figure}[!h]
\centering
\resizebox{\textwidth}{!}{%
\begin{tikzpicture}

\begin{scope}[start chain=going above, node distance=2mm, shift={(-5,2)}]
    \foreach \i [count=\x] in {%
        {(TT)},
        {(TH)},
        {(HT)},
        {(HH)},
        }{%
        \node[on chain] (s\x) {\i};
    }
\end{scope}

\begin{scope}[start chain=going above, node distance=2mm, shift={(0,1)}]
    \foreach \i [count=\x] in {%
        {\textbar(HT), (TH)\textbar},
        {\textbar(HH), (TT)\textbar},
        {\textbar(TH), (HT), (TT)\textbar},
        {\textbar(HT), (HH), (TH)\textbar},
        {\textbar(TT)\textbar},
        {\textbar(HH)\textbar},
        {$\varnothing$},
        {S}%
        }{%
        \node[on chain] (f\x) {\i};
    }
\end{scope}

\node [ellipse,draw,fit=(f1) (f8),label=above:$\mathscr{F}$] {};
\node [ellipse,draw,fit=(s1) (s4),label=above:S] {};

    \begin{scope}[x=5cm, shift={(1,0)}]
    \draw (0,0) -- (1,0) node[right] {$P(\cdot)$};
        \foreach \x [count=\y] in {0,0.25,0.5,0.75,1}{
            \draw (\x,.2) coordinate (t\y) -- (\x,0) node[below] {\x};
            \path (t\y) --++ (95:5) coordinate (bt\y);
        }
    \end{scope}

\myarrow{f8}{t5}
\myarrow{f7}{t1}
\myarrow{f6}{t2}
\myarrow{f5}{t2}
\myarrow{f4}{t4}
\myarrow{f3}{t4}
\myarrow{f2}{t3}
\myarrow{f1}{t3}
\end{tikzpicture}}
\caption{The relationship between the sample space, $\sigma$-field and probability set function.}
\end{figure}
\end{document}

Edit — overlapping arrows

Here's an example with the arrows like your scheme above. It uses a small "hack" to achieve the overlapping arrows effect, but it doesn't require you to load extra packages/libraries.

If you have any questions about the code, feel free to comment.

Output

enter image description here

Code

\documentclass[margin=10pt]{standalone}
\usepackage{tikz}

\usetikzlibrary{calc,chains, arrows.meta}

\newcommand\myarrow[2]{
    \path (#1) coordinate (a1) --++ (6,0) coordinate (a2);
    \coordinate (int) at (intersection of a1--a2 and #2--b#2);
    \draw[rounded corners,-{Latex}] (#1) -- (int) -- (#2);
}

\begin{document}
\begin{tikzpicture}

    \begin{scope}[start chain=going above, node distance=2mm, shift={(0,1)}]
        \foreach \i [count=\x] in {%
            {some node},
            {some other node},
            {short},
            {yet node},
            {what node},
            {that node},%
            }{
            \node[on chain] (\x) {\i};
        }
    \end{scope}

    \begin{scope}[x=5cm, shift={(1,0)}]
    \draw (0,0) -- (1,0);
        \foreach \x [count=\y] in {0,0.2,0.4,0.6,0.8,1}{
            \draw (\x,.2) coordinate (s\y) -- (\x,0) node[below] {\x};
            \path (s\y) --++ (98:5) coordinate (bs\y);
        }
    \end{scope}

\myarrow{1}{s3}
\myarrow{3}{s2}
\myarrow{5}{s3}
\myarrow{2}{s6}
\myarrow{6}{s1}
\myarrow{4}{s6}
\end{tikzpicture}
\end{document}

Original answer

I'm not on my computer, so I can't post any code for now. But in the meantime, I can tell you what you can start looking at to create a graph like that.

  1. The columns on the right can be done in various ways. I think the best way is using the TikZ chains library. Indeed, in this case chains have greater flexibility. For example, if you need to add nodes later on.
  2. The scale on the right can be easily done with a line and a \foreach statement, which I'm sure you are familiar with in some way, to create the ticks and the labels. The syntax might differ, but it's the same command.
  3. In both the first points, you can assign node references, that you can use to create arrows or connecting lines. As easy as \draw (a) -- (b);.

The graph is not hard per se, but it will require some typing. If you encounter problems, I'll give you some code snippets to show you how to approach a certain task.

Related Question