1

enter image description here

The lifecycle is divided into n stages, starting from egg to adult. Individuals can only produce when they reach the adult stage. P11,p22... are survival prob and p12, p23... transition probability R is the production rate in state n to 1.

Qrrbrbirlbel
  • 119,821
Tareque
  • 11

1 Answers1

4

This example can be used to further adapt the figure to your needs. I haven't changed the final nodes before adult to n-1 and n.

The example code giving the Markov chain in nine steps:

\documentclass[11pt]{article}

\usepackage{tikz} \usetikzlibrary{arrows.meta,automata,decorations.markings,decorations.pathreplacing,decorations.text,backgrounds,shapes.geometric}

\begin{document}

\begin{tikzpicture}
    [trans/.style={to path={ .. controls +(60:1.5) and +(120:1.5) .. (\tikztotarget) \tikztonodes}},radius=2cm]

        \path (4,0) -- +(180:2cm) node(p0) {0} arc [start angle=-180, delta angle=-40] node(p1) {1};
        \draw[-{Stealth},shorten <=8pt, font=\footnotesize] (p0)  arc [start angle=-180, delta angle=-32]  (p1);
        \draw[fill=blue!30, opacity=0.2] (p0) circle[radius=3mm] (p1) circle[radius=3mm];
        \path[->] (p0) edge [trans,red,rotate=90] (p0); 
        \path[->] (p1) edge [trans,above,red,rotate=50] (p1); 
        \path (4,0) --+(160:1.6cm) node {$p_{01}$};
        \path (4,0) --+(180:3.3cm) node[red,rotate=90] {$p_{00}$};
        \path (4,0) --+(140:3.3cm) node[red,rotate=50] {$p_{01}$};

        \foreach [count=\i, evaluate=\px as \hk using 140+\px*40,   % calculate next arc angle
                            evaluate=\hk as \hkp using \hk+20,      % calculate halfway angle to place nodes on arc
                            evaluate=\px as \lpr using 90-\px*40,   % calculate edge to place loop
                            evaluate=\px as \lpa using \hk+40]      % calculate angle to place nodes on loop
                \px in {2,3,...,8}{
            \path[font=\small] (p\i) arc [start angle=-\hk, delta angle=-40] node(p\px) {\px};
            \draw[fill=blue!30, opacity=0.2] (p\px) circle[radius=3mm];
            \draw[-{Stealth},shorten <=8pt, font=\footnotesize] (p\i)  arc [start angle=-\hk, delta angle=-32]  (p\px);
            \path (4,0) -- +(-\hkp:1.6cm) node {$p_{\i\px}$};
            \path[->] (p\px) edge [trans,red,rotate=\lpr] (p\px);
            \path (4,0) --+(-\lpa:3.3cm) node[red,rotate=\lpr] {$p_{\px\px}$};
        }

    \draw[-{Stealth},shorten <=8pt, font=\footnotesize] (p8)  arc [start angle=-140, delta angle=-32]  (p0);
    \path[font=\bfseries\small] (4,0) --+(-160:1.6cm) node {R};
    \node[left of= p8, font=\bfseries\small] {adult};
    \node[right of= p0, font=\bfseries\small] {egg};

\end{tikzpicture}

\end{document}

markov_chain

Addition

Looking at the code above there were some minor errors in the nodes and the n-1 / n nodes weren't placed in the diagram. Also the subscripts in the nodes didn't look like subscripts at all. The tikzpicture code below solves / supplements all that:

    \begin{tikzpicture}
        [trans/.style={to path={ .. controls +(60:1.5) and +(120:1.5) .. (\tikztotarget) \tikztonodes}},radius=2cm]
    \path (4,0) -- +(180:2cm) node(p0) {0} arc [start angle=-180, delta angle=-40] node(p1) {1};
    \draw[-{Stealth},shorten <=8pt, font=\footnotesize] (p0)  arc [start angle=-180, delta angle=-32]  (p1);
    \draw[fill=blue!30, opacity=0.2] (p0) circle[radius=3mm] (p1) circle[radius=3mm];
    \path[-{Stealth}, shorten >=2pt] (p0) edge [trans,red,rotate=90] (p0); 
    \path[-{Stealth}, shorten >=2pt] (p1) edge [trans,above,red,rotate=50] (p1); 
    \path (4,0) --+(160:1.6cm) node {$p_{{\textstyle\mathstrut}01}$};
    \path (4,0) --+(180:3.3cm) node[red,rotate=90] {$p_{{\textstyle\mathstrut}00}$};
    \path (4,0) --+(140:3.3cm) node[red,rotate=50] {$p_{{\textstyle\mathstrut}11}$};

    \foreach [count=\i, evaluate=\px as \hk using 140+\px*40,   % calculate next arc angle
            evaluate=\hk as \hkp using \hk+20,      % calculate halfway angle to place nodes on arc
            evaluate=\px as \lpr using 90-\px*40,   % calculate edge to place loop
            evaluate=\px as \lpa using \hk+40]      % calculate angle to place nodes on loop
            \px in {2,3,...,5}{
        \path[font=\small] (p\i) arc [start angle=-\hk, delta angle=-40] node(p\px) {\px};
        \draw[fill=blue!30, opacity=0.2] (p\px) circle[radius=3mm];
        \draw[-{Stealth},shorten <=8pt, font=\footnotesize] (p\i)  arc [start angle=-\hk, delta angle=-32]  (p\px);
        \path (4,0) -- +(-\hkp:1.6cm) node {$p_{{\textstyle\mathstrut}\i\px}$};
        \path[-{Stealth}, shorten >=2pt] (p\px) edge [trans,red,rotate=\lpr] (p\px);
        \path (4,0) --+(-\lpa:3.3cm) node[red,rotate=\lpr] {$p_{{\textstyle\mathstrut}\px\px}$};
        }


    \path (4,0) -- +(260:2cm) node(p7) [font=\footnotesize] {$n\!\shortminus\!1$};
    \path (4,0) -- +(220:2cm) node(p8) {$n$};
    \draw[fill=blue!30, opacity=0.2] (p7) circle[radius=3mm] (p8) circle[radius=3mm];
    \draw[-{Stealth},shorten <=8pt, font=\footnotesize] (p7)  arc [start angle=-100, delta angle=-32]  (p8);
    \path[-{Stealth}, shorten >=2pt] (p7) edge [trans,red,rotate=170] (p7); 
    \path[-{Stealth}, shorten >=2pt] (p8) edge [trans,above,red,rotate=130] (p8); 
    \path (4,0) --+(260:1.6cm) node {$p_{{\textstyle\mathstrut}n(n\!\shortminus\!1)}$};
    \path (4,0) --+(220:3.3cm) node[red,rotate=130] {$p_{{\textstyle\mathstrut}nn}$};
    \path (4,0) --+(260:3.3cm) node[red,rotate=170] {$p_{{\textstyle\mathstrut}(n\!\shortminus\!1)(n\!\shortminus\!1)}$};

    \draw[-{Stealth},shorten <=8pt, font=\footnotesize] (p8)  arc [start angle=-140, delta angle=-32]  (p0);
    \path[font=\bfseries\small] (4,0) --+(-160:1.6cm) node {R};
    \node[left of= p8, font=\bfseries\small] {adult};
    \node[right of= p0, font=\bfseries\small, xshift=-2mm] {egg};

    \draw[-{Stealth},shorten <=8pt, font=\footnotesize,dashed] (p5)  arc [start angle=-20, delta angle=-70]  (p7); % decorate,decoration={shape=circle, shape size=2mm, shape sep={5mm, between centers}}, doesn't work unfortunately

\end{tikzpicture}

The result now looks almost as the provided photograph:

markov_chain_n_nodes

Since normal math mode uses a rather large minus sign I used the answer to shorter minus sign in the nodes. To use this answer add the following lines to the preamble:

\usepackage{amssymb}  % provided it isn't loaded by another package
\DeclareMathSymbol{\shortminus}{\mathbin}{AMSa}{"39}

The option to lower the subscripts can be found here.

alchemist
  • 1,761