\documentclass[11pt]{article}

    \usepackage[breakable]{tcolorbox}
    \usepackage{parskip} % Stop auto-indenting (to mimic markdown behaviour)

    \usepackage{iftex}
    \ifPDFTeX
    	\usepackage[T1]{fontenc}
    	\usepackage{mathpazo}
    \else
    	\usepackage{fontspec}
    \fi

    % Basic figure setup, for now with no caption control since it's done
    % automatically by Pandoc (which extracts ![](path) syntax from Markdown).
    \usepackage{graphicx}
    % Maintain compatibility with old templates. Remove in nbconvert 6.0
    \let\Oldincludegraphics\includegraphics
    % Ensure that by default, figures have no caption (until we provide a
    % proper Figure object with a Caption API and a way to capture that
    % in the conversion process - todo).
    \usepackage{caption}
    \DeclareCaptionFormat{nocaption}{}
    \captionsetup{format=nocaption,aboveskip=0pt,belowskip=0pt}

    \usepackage{float}
    \floatplacement{figure}{H} % forces figures to be placed at the correct location
    \usepackage{xcolor} % Allow colors to be defined
    \usepackage{enumerate} % Needed for markdown enumerations to work
    \usepackage{geometry} % Used to adjust the document margins
    \usepackage{amsmath} % Equations
    \usepackage{amssymb} % Equations
    \usepackage{textcomp} % defines textquotesingle
    % Hack from http://tex.stackexchange.com/a/47451/13684:
    \AtBeginDocument{%
        \def\PYZsq{\textquotesingle}% Upright quotes in Pygmentized code
    }
    \usepackage{upquote} % Upright quotes for verbatim code
    \usepackage{eurosym} % defines \euro
    \usepackage[mathletters]{ucs} % Extended unicode (utf-8) support
    \usepackage{fancyvrb} % verbatim replacement that allows latex
    \usepackage{grffile} % extends the file name processing of package graphics 
                         % to support a larger range
    \makeatletter % fix for old versions of grffile with XeLaTeX
    \@ifpackagelater{grffile}{2019/11/01}
    {
      % Do nothing on new versions
    }
    {
      \def\Gread@@xetex#1{%
        \IfFileExists{"\Gin@base".bb}%
        {\Gread@eps{\Gin@base.bb}}%
        {\Gread@@xetex@aux#1}%
      }
    }
    \makeatother
    \usepackage[Export]{adjustbox} % Used to constrain images to a maximum size
    \adjustboxset{max size={0.9\linewidth}{0.9\paperheight}}

    % The hyperref package gives us a pdf with properly built
    % internal navigation ('pdf bookmarks' for the table of contents,
    % internal cross-reference links, web links for URLs, etc.)
    \usepackage{hyperref}
    % The default LaTeX title has an obnoxious amount of whitespace. By default,
    % titling removes some of it. It also provides customization options.
    \usepackage{titling}
    \usepackage{longtable} % longtable support required by pandoc >1.10
    \usepackage{booktabs}  % table support for pandoc > 1.12.2
    \usepackage[inline]{enumitem} % IRkernel/repr support (it uses the enumerate* environment)
    \usepackage[normalem]{ulem} % ulem is needed to support strikethroughs (\sout)
                                % normalem makes italics be italics, not underlines
    \usepackage{mathrsfs}
    \usepackage{authblk}

    
    % Colors for the hyperref package
    \definecolor{urlcolor}{rgb}{0,.145,.698}
    \definecolor{linkcolor}{rgb}{.71,0.21,0.01}
    \definecolor{citecolor}{rgb}{.12,.54,.11}

    % ANSI colors
    \definecolor{ansi-black}{HTML}{3E424D}
    \definecolor{ansi-black-intense}{HTML}{282C36}
    \definecolor{ansi-red}{HTML}{E75C58}
    \definecolor{ansi-red-intense}{HTML}{B22B31}
    \definecolor{ansi-green}{HTML}{00A250}
    \definecolor{ansi-green-intense}{HTML}{007427}
    \definecolor{ansi-yellow}{HTML}{DDB62B}
    \definecolor{ansi-yellow-intense}{HTML}{B27D12}
    \definecolor{ansi-blue}{HTML}{208FFB}
    \definecolor{ansi-blue-intense}{HTML}{0065CA}
    \definecolor{ansi-magenta}{HTML}{D160C4}
    \definecolor{ansi-magenta-intense}{HTML}{A03196}
    \definecolor{ansi-cyan}{HTML}{60C6C8}
    \definecolor{ansi-cyan-intense}{HTML}{258F8F}
    \definecolor{ansi-white}{HTML}{C5C1B4}
    \definecolor{ansi-white-intense}{HTML}{A1A6B2}
    \definecolor{ansi-default-inverse-fg}{HTML}{FFFFFF}
    \definecolor{ansi-default-inverse-bg}{HTML}{000000}

    % common color for the border for error outputs.
    \definecolor{outerrorbackground}{HTML}{FFDFDF}

    % commands and environments needed by pandoc snippets
    % extracted from the output of `pandoc -s`
    \providecommand{\tightlist}{%
      \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
    \DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
    % Add ',fontsize=\small' for more characters per line
    \newenvironment{Shaded}{}{}
    \newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}}
    \newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.56,0.13,0.00}{{#1}}}
    \newcommand{\DecValTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
    \newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
    \newcommand{\FloatTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
    \newcommand{\CharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
    \newcommand{\StringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
    \newcommand{\CommentTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textit{{#1}}}}
    \newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{{#1}}}
    \newcommand{\AlertTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}}
    \newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.02,0.16,0.49}{{#1}}}
    \newcommand{\RegionMarkerTok}[1]{{#1}}
    \newcommand{\ErrorTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}}
    \newcommand{\NormalTok}[1]{{#1}}
    
    % Additional commands for more recent versions of Pandoc
    \newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.53,0.00,0.00}{{#1}}}
    \newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
    \newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
    \newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.73,0.40,0.53}{{#1}}}
    \newcommand{\ImportTok}[1]{{#1}}
    \newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.73,0.13,0.13}{\textit{{#1}}}}
    \newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
    \newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
    \newcommand{\VariableTok}[1]{\textcolor[rgb]{0.10,0.09,0.49}{{#1}}}
    \newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}}
    \newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.40,0.40,0.40}{{#1}}}
    \newcommand{\BuiltInTok}[1]{{#1}}
    \newcommand{\ExtensionTok}[1]{{#1}}
    \newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.74,0.48,0.00}{{#1}}}
    \newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.49,0.56,0.16}{{#1}}}
    \newcommand{\InformationTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
    \newcommand{\WarningTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
    
    
    % Define a nice break command that doesn't care if a line doesn't already
    % exist.
    \def\br{\hspace*{\fill} \\* }
    % Math Jax compatibility definitions
    \def\gt{>}
    \def\lt{<}
    \let\Oldtex\TeX
    \let\Oldlatex\LaTeX
    \renewcommand{\TeX}{\textrm{\Oldtex}}
    \renewcommand{\LaTeX}{\textrm{\Oldlatex}}
    % Document parameters
    % Document title
    \title{Simulating tree species migration: from post-glacial to future climate change}
    \author[1]{Heike Lischke}
    \author[1,2]{Veiko Lehsten}
    \author[1,2]{Deborah Zani}
    \affil[1]{Swiss Federal Institute of Forest, Snow and Landscape Research WSL}
    \affil[2]{University of Lund, Sweden}
    
    \date{}   

% Pygments definitions
\makeatletter
\def\PY@reset{\let\PY@it=\relax \let\PY@bf=\relax%
    \let\PY@ul=\relax \let\PY@tc=\relax%
    \let\PY@bc=\relax \let\PY@ff=\relax}
\def\PY@tok#1{\csname PY@tok@#1\endcsname}
\def\PY@toks#1+{\ifx\relax#1\empty\else%
    \PY@tok{#1}\expandafter\PY@toks\fi}
\def\PY@do#1{\PY@bc{\PY@tc{\PY@ul{%
    \PY@it{\PY@bf{\PY@ff{#1}}}}}}}
\def\PY#1#2{\PY@reset\PY@toks#1+\relax+\PY@do{#2}}

\@namedef{PY@tok@w}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.73,0.73}{##1}}}
\@namedef{PY@tok@c}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\@namedef{PY@tok@cp}{\def\PY@tc##1{\textcolor[rgb]{0.74,0.48,0.00}{##1}}}
\@namedef{PY@tok@k}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@kp}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@kt}{\def\PY@tc##1{\textcolor[rgb]{0.69,0.00,0.25}{##1}}}
\@namedef{PY@tok@o}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@ow}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.67,0.13,1.00}{##1}}}
\@namedef{PY@tok@nb}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@nf}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
\@namedef{PY@tok@nc}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
\@namedef{PY@tok@nn}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
\@namedef{PY@tok@ne}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.82,0.25,0.23}{##1}}}
\@namedef{PY@tok@nv}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\@namedef{PY@tok@no}{\def\PY@tc##1{\textcolor[rgb]{0.53,0.00,0.00}{##1}}}
\@namedef{PY@tok@nl}{\def\PY@tc##1{\textcolor[rgb]{0.63,0.63,0.00}{##1}}}
\@namedef{PY@tok@ni}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.60,0.60,0.60}{##1}}}
\@namedef{PY@tok@na}{\def\PY@tc##1{\textcolor[rgb]{0.49,0.56,0.16}{##1}}}
\@namedef{PY@tok@nt}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@nd}{\def\PY@tc##1{\textcolor[rgb]{0.67,0.13,1.00}{##1}}}
\@namedef{PY@tok@s}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@sd}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@si}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.73,0.40,0.53}{##1}}}
\@namedef{PY@tok@se}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.73,0.40,0.13}{##1}}}
\@namedef{PY@tok@sr}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.40,0.53}{##1}}}
\@namedef{PY@tok@ss}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\@namedef{PY@tok@sx}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@m}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@gh}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,0.50}{##1}}}
\@namedef{PY@tok@gu}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.50,0.00,0.50}{##1}}}
\@namedef{PY@tok@gd}{\def\PY@tc##1{\textcolor[rgb]{0.63,0.00,0.00}{##1}}}
\@namedef{PY@tok@gi}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.63,0.00}{##1}}}
\@namedef{PY@tok@gr}{\def\PY@tc##1{\textcolor[rgb]{1.00,0.00,0.00}{##1}}}
\@namedef{PY@tok@ge}{\let\PY@it=\textit}
\@namedef{PY@tok@gs}{\let\PY@bf=\textbf}
\@namedef{PY@tok@gp}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,0.50}{##1}}}
\@namedef{PY@tok@go}{\def\PY@tc##1{\textcolor[rgb]{0.53,0.53,0.53}{##1}}}
\@namedef{PY@tok@gt}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.27,0.87}{##1}}}
\@namedef{PY@tok@err}{\def\PY@bc##1{{\setlength{\fboxsep}{\string -\fboxrule}\fcolorbox[rgb]{1.00,0.00,0.00}{1,1,1}{\strut ##1}}}}
\@namedef{PY@tok@kc}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@kd}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@kn}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@kr}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@bp}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@fm}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
\@namedef{PY@tok@vc}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\@namedef{PY@tok@vg}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\@namedef{PY@tok@vi}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\@namedef{PY@tok@vm}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\@namedef{PY@tok@sa}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@sb}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@sc}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@dl}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@s2}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@sh}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@s1}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@mb}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@mf}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@mh}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@mi}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@il}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@mo}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@ch}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\@namedef{PY@tok@cm}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\@namedef{PY@tok@cpf}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\@namedef{PY@tok@c1}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\@namedef{PY@tok@cs}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}

\def\PYZbs{\char`\\}
\def\PYZus{\char`\_}
\def\PYZob{\char`\{}
\def\PYZcb{\char`\}}
\def\PYZca{\char`\^}
\def\PYZam{\char`\&}
\def\PYZlt{\char`\<}
\def\PYZgt{\char`\>}
\def\PYZsh{\char`\#}
\def\PYZpc{\char`\%}
\def\PYZdl{\char`\$}
\def\PYZhy{\char`\-}
\def\PYZsq{\char`\'}
\def\PYZdq{\char`\"}
\def\PYZti{\char`\~}
% for compatibility with earlier versions
\def\PYZat{@}
\def\PYZlb{[}
\def\PYZrb{]}
\makeatother


    % For linebreaks inside Verbatim environment from package fancyvrb. 
    \makeatletter
        \newbox\Wrappedcontinuationbox 
        \newbox\Wrappedvisiblespacebox 
        \newcommand*\Wrappedvisiblespace {\textcolor{red}{\textvisiblespace}} 
        \newcommand*\Wrappedcontinuationsymbol {\textcolor{red}{\llap{\tiny$\m@th\hookrightarrow$}}} 
        \newcommand*\Wrappedcontinuationindent {3ex } 
        \newcommand*\Wrappedafterbreak {\kern\Wrappedcontinuationindent\copy\Wrappedcontinuationbox} 
        % Take advantage of the already applied Pygments mark-up to insert 
        % potential linebreaks for TeX processing. 
        %        {, <, #, %, $, ' and ": go to next line. 
        %        _, }, ^, &, >, - and ~: stay at end of broken line. 
        % Use of \textquotesingle for straight quote. 
        \newcommand*\Wrappedbreaksatspecials {% 
            \def\PYGZus{\discretionary{\char`\_}{\Wrappedafterbreak}{\char`\_}}% 
            \def\PYGZob{\discretionary{}{\Wrappedafterbreak\char`\{}{\char`\{}}% 
            \def\PYGZcb{\discretionary{\char`\}}{\Wrappedafterbreak}{\char`\}}}% 
            \def\PYGZca{\discretionary{\char`\^}{\Wrappedafterbreak}{\char`\^}}% 
            \def\PYGZam{\discretionary{\char`\&}{\Wrappedafterbreak}{\char`\&}}% 
            \def\PYGZlt{\discretionary{}{\Wrappedafterbreak\char`\<}{\char`\<}}% 
            \def\PYGZgt{\discretionary{\char`\>}{\Wrappedafterbreak}{\char`\>}}% 
            \def\PYGZsh{\discretionary{}{\Wrappedafterbreak\char`\#}{\char`\#}}% 
            \def\PYGZpc{\discretionary{}{\Wrappedafterbreak\char`\%}{\char`\%}}% 
            \def\PYGZdl{\discretionary{}{\Wrappedafterbreak\char`\$}{\char`\$}}% 
            \def\PYGZhy{\discretionary{\char`\-}{\Wrappedafterbreak}{\char`\-}}% 
            \def\PYGZsq{\discretionary{}{\Wrappedafterbreak\textquotesingle}{\textquotesingle}}% 
            \def\PYGZdq{\discretionary{}{\Wrappedafterbreak\char`\"}{\char`\"}}% 
            \def\PYGZti{\discretionary{\char`\~}{\Wrappedafterbreak}{\char`\~}}% 
        } 
        % Some characters . , ; ? ! / are not pygmentized. 
        % This macro makes them "active" and they will insert potential linebreaks 
        \newcommand*\Wrappedbreaksatpunct {% 
            \lccode`\~`\.\lowercase{\def~}{\discretionary{\hbox{\char`\.}}{\Wrappedafterbreak}{\hbox{\char`\.}}}% 
            \lccode`\~`\,\lowercase{\def~}{\discretionary{\hbox{\char`\,}}{\Wrappedafterbreak}{\hbox{\char`\,}}}% 
            \lccode`\~`\;\lowercase{\def~}{\discretionary{\hbox{\char`\;}}{\Wrappedafterbreak}{\hbox{\char`\;}}}% 
            \lccode`\~`\:\lowercase{\def~}{\discretionary{\hbox{\char`\:}}{\Wrappedafterbreak}{\hbox{\char`\:}}}% 
            \lccode`\~`\?\lowercase{\def~}{\discretionary{\hbox{\char`\?}}{\Wrappedafterbreak}{\hbox{\char`\?}}}% 
            \lccode`\~`\!\lowercase{\def~}{\discretionary{\hbox{\char`\!}}{\Wrappedafterbreak}{\hbox{\char`\!}}}% 
            \lccode`\~`\/\lowercase{\def~}{\discretionary{\hbox{\char`\/}}{\Wrappedafterbreak}{\hbox{\char`\/}}}% 
            \catcode`\.\active
            \catcode`\,\active 
            \catcode`\;\active
            \catcode`\:\active
            \catcode`\?\active
            \catcode`\!\active
            \catcode`\/\active 
            \lccode`\~`\~ 	
        }
    \makeatother

    \let\OriginalVerbatim=\Verbatim
    \makeatletter
    \renewcommand{\Verbatim}[1][1]{%
        %\parskip\z@skip
        \sbox\Wrappedcontinuationbox {\Wrappedcontinuationsymbol}%
        \sbox\Wrappedvisiblespacebox {\FV@SetupFont\Wrappedvisiblespace}%
        \def\FancyVerbFormatLine ##1{\hsize\linewidth
            \vtop{\raggedright\hyphenpenalty\z@\exhyphenpenalty\z@
                \doublehyphendemerits\z@\finalhyphendemerits\z@
                \strut ##1\strut}%
        }%
        % If the linebreak is at a space, the latter will be displayed as visible
        % space at end of first line, and a continuation symbol starts next line.
        % Stretch/shrink are however usually zero for typewriter font.
        \def\FV@Space {%
            \nobreak\hskip\z@ plus\fontdimen3\font minus\fontdimen4\font
            \discretionary{\copy\Wrappedvisiblespacebox}{\Wrappedafterbreak}
            {\kern\fontdimen2\font}%
        }%
        
        % Allow breaks at special characters using \PYG... macros.
        \Wrappedbreaksatspecials
        % Breaks at punctuation characters . , ; ? ! and / need catcode=\active 	
        \OriginalVerbatim[#1,codes*=\Wrappedbreaksatpunct]%
    }
    \makeatother

    % Exact colors from NB
    \definecolor{incolor}{HTML}{303F9F}
    \definecolor{outcolor}{HTML}{D84315}
    \definecolor{cellborder}{HTML}{CFCFCF}
    \definecolor{cellbackground}{HTML}{F7F7F7}
    
    % prompt
    \makeatletter
    \newcommand{\boxspacing}{\kern\kvtcb@left@rule\kern\kvtcb@boxsep}
    \makeatother
    \newcommand{\prompt}[4]{
        {\ttfamily\llap{{\color{#2}[#3]:\hspace{3pt}#4}}\vspace{-\baselineskip}}
    }
    

    
    % Prevent overflowing lines due to hard-to-break entities
    \sloppy 
    % Setup hyperref package
    \hypersetup{
      breaklinks=true,  % so long urls are correctly broken across lines
      colorlinks=true,
      urlcolor=urlcolor,
      linkcolor=linkcolor,
      citecolor=citecolor,
      }
    % Slightly bigger margins than the latex defaults
    
    \geometry{verbose,tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in}
    

\begin{document}
    
\maketitle
    
This Notebook reproduces the analyses of the paper
\href{https://doi.org/xxx}{Zani et al.~Geosci. Model Dev., XX, 20XX},
including the generation of figures and supplement tables. It also
allows to inspect the data in more details.

\begin{abstract}
The prediction of species geographic redistribution under climate change
(i.e.~range shifts) has been addressed by both experimental and
modelling approaches and can be used to inform efficient policy measures
on the functioning and services of future ecosystems. Dynamic Global
Vegetation Models (DGVMs) are considered state-of-the art tools to
understand and quantify the spatio-temporal dynamics of ecosystems at
large scales and their response to changing environments. They can
explicitly include local vegetation dynamics relevant to migration
(establishment, growth, seed production), species-specific dispersal
abilities and the competitive interactions with other species in the new
environment. However, the inclusion of more detailed mechanistic
formulations of range shift processes may also widen the overall
uncertainty of the model. Thus, a quantification of these uncertainties
is needed to evaluate and improve our confidence in the model
predictions. In this study, we present an efficient assessment of
parameter and model uncertainties combining low-cost analyses in
successive steps: local sensitivity analysis, exploration of the
performance landscape at extreme parameter values, and inclusion of
relevant ecological processes in the model structure. This approach was
tested on the newly-implemented migration module of the state-of-the-art
DGVM, LPJ-GM. Estimates of post-glacial migration rates obtained from
pollen and macrofossil records of dominant European tree taxa were used
to test the model performance. The results indicate higher sensitivity
of migration rates to parameters associated with the dispersal kernel
(dispersal distances and kernel shape) compared to plant traits
(germination rate and maximum fecundity) and highlight the importance of
representing rare long-distance dispersal events via fat-tailed kernels.
Overall, the successful parametrization and model selection of LPJ-GM
will allow simulating plant migration with a more mechanistic approach
at larger spatial and temporal scales, thus improving our efforts to
understand past vegetation dynamics and predict future range shifts in a
context of global change.
\end{abstract}

    \hypertarget{how-to-run-this-notebook}{%
\section{How to run this notebook}\label{how-to-run-this-notebook}}

After downloading the Supplement folder containing this notebook
\href{https://doi.org/xxx}{here}, activate the environment
\texttt{environment.yml} and start the notebook from the command line:

\begin{verbatim}
(base)%pwd >conda activate LPJGM_uncertainty
(LPJGM_uncertainty)%pwd >jupyter-notebook
\end{verbatim}

Input data are included in the folder at the address \texttt{\%pwd}.

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{1}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{datapath} \PY{o}{=} \PY{o}{\PYZpc{}}\PY{k}{pwd} 
\end{Verbatim}
\end{tcolorbox}
        
    \hypertarget{libraries}{%
\section{Libraries}\label{libraries}}

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{2}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{k+kn}{import} \PY{n+nn}{numpy} \PY{k}{as} \PY{n+nn}{np}
\PY{k+kn}{from} \PY{n+nn}{numpy} \PY{k+kn}{import} \PY{n}{nanmean}
\PY{k+kn}{import} \PY{n+nn}{pandas} \PY{k}{as} \PY{n+nn}{pd}
\PY{k+kn}{import} \PY{n+nn}{matplotlib}\PY{n+nn}{.}\PY{n+nn}{pyplot} \PY{k}{as} \PY{n+nn}{plt}
\PY{k+kn}{import} \PY{n+nn}{seaborn} \PY{k}{as} \PY{n+nn}{sns}
\PY{k+kn}{import} \PY{n+nn}{statistics}
\PY{k+kn}{from} \PY{n+nn}{scipy} \PY{k+kn}{import} \PY{n}{stats}
\PY{k+kn}{from} \PY{n+nn}{scipy}\PY{n+nn}{.}\PY{n+nn}{stats} \PY{k+kn}{import} \PY{n}{mannwhitneyu}
\PY{k+kn}{from} \PY{n+nn}{statsmodels}\PY{n+nn}{.}\PY{n+nn}{sandbox}\PY{n+nn}{.}\PY{n+nn}{stats}\PY{n+nn}{.}\PY{n+nn}{multicomp} \PY{k+kn}{import} \PY{n}{multipletests}
\PY{k+kn}{from} \PY{n+nn}{statsmodels}\PY{n+nn}{.}\PY{n+nn}{stats}\PY{n+nn}{.}\PY{n+nn}{multicomp} \PY{k+kn}{import} \PY{n}{pairwise\PYZus{}tukeyhsd}
\PY{k+kn}{import} \PY{n+nn}{copy}
\PY{k+kn}{from} \PY{n+nn}{sklearn} \PY{k+kn}{import} \PY{n}{preprocessing}
\PY{k+kn}{from} \PY{n+nn}{sklearn}\PY{n+nn}{.}\PY{n+nn}{preprocessing} \PY{k+kn}{import} \PY{n}{StandardScaler}
\PY{k+kn}{from} \PY{n+nn}{scipy}\PY{n+nn}{.}\PY{n+nn}{special} \PY{k+kn}{import} \PY{n}{gamma}
\end{Verbatim}
\end{tcolorbox}

    \hypertarget{observational-data-estimates-of-past-migration-rates}{%
\section{Observational data: estimates of past migration
rates}\label{observational-data-estimates-of-past-migration-rates}}

We used estimates of migration rates from paleo-records of European
forest expansion after the Last Glacial Maximum (LGM) for the parameter
optimization of 17 major European tree species implemented in LPJ-GM.
Upper and lower boundaries for the range values of migration rates were
derived from different studies based on the method employed for their
estimation.

\textbf{Table 1}. Estimates of maximum post-glacial migration rates in
meters year\(^{-1}\), dispersal syndromes, and expected competition
during post-glacial expansion for 17 major European tree species. Lower
and upper boundaries of migration rates correspond to \texttt{OBS\_MIN}
and \texttt{OBS\_MAX}, respectively, in \texttt{Input\_EVA.csv} and
\texttt{Input\_KA.csv}.

\begin{longtable}[]{@{}llll@{}}
\toprule
Species (LPJ-GM notation) & Migration rates & Dispersal syndrome(e) & Competitor(f) \\
\midrule
\endhead
Abies alba (Abi\_alb) & 250(a) -- 300(b) & W & Bet\_pen \& C3G \\
Betula pendula (Bet\_pen) & 540(c) -- 800(a) & W, Wa, B & Bet\_pub \&
C3G \\
Betula pubescens (Bet\_pub) & 540(c) -- 800(a) & W, Wa, B & Bet\_pen \&
C3G \\
Carpinus betulus (Car\_bet) & 500(a) -- 1000(b) & W, Wa, B, SA &
Bet\_pen \& C3G \\
Corylus avellana (Cor\_ave) & 1000(a) -- 1500(b) & B, SA & Bet\_pen \&
C3G \\
Fagus sylvatica (Fag\_syl) & 200(b) -- 300(b) & SA, LA & Bet\_pen \&
C3G \\
Fraxinus excelsior (Fra\_exc) & 200(b) -- 500(b) & W, Wa, B, LA &
Bet\_pen \& C3G \\
Picea abies (Pic\_abi) & 150(d) -- 500(b) & W, Wa, B, LA & Bet\_pen \&
C3G \\
Picea sitchensis (Pic\_sit) & 150(d) -- 500(b) & W & Bet\_pen \& C3G \\
Pinus sylvestris (Pin\_syl) & 600(a) -- 1500(b) & W, Wa & Bet\_pen \&
C3G \\
Pinus halepensis (Pin\_syl) & 600(a) -- 1500(b) & W & Bet\_pen \& C3G \\
Quercus coccifera (Que\_coc) & 300(d) -- 500(b) & SA & Bet\_pen \&
C3G \\
Quercus ilex (Que\_ile) & 300(d) -- 500(b) & SA & Bet\_pen \& C3G \\
Quercus pubescens (Que\_pub) & 300(d) -- 500(b) & SA & Bet\_pen \&
C3G \\
Quercus robur (Que\_rob) & 300(d) -- 500(b) & SA & Bet\_pen \& C3G \\
Tilia cordata (Til\_cor) & 150(b) -- 500(b) & SA & Bet\_pen \& C3G \\
Ulmus glabra (Ulm\_gla) & 550(d) -- 1000(b) & W, Wa & Bet\_pen \& C3G \\
\bottomrule
\end{longtable}

\begin{enumerate}
\def\labelenumi{(\alph{enumi})}
\tightlist
\item
  Estimates of maximum migration rates by
  \href{https://doi.org/10.1007/s00334-017-0640-0}{Giesecke and Brewer
  (2018)} with pollen analysis corrected by phylogeographic studies\\
\item
  Estimates of maximum migration rates by
  \href{https://doi.org/10.1017/S0079497X00007660}{Huntley and Birks
  (1983)} with pollen analysis\\
\item
  Estimates of maximum migration rates by
  \href{https://doi.org/10.1371/journal.pone.0071797}{Feurdean et
  al.~(2013)} with fossil records, assuming spread from southern refugia
  (40-45ºN latitude)\\
\item
  Estimates of overall migration rates by
  \href{https://doi.org/10.1111/jbi.12974}{Giesecke et al.~(2017)}
  derived from the increase in area of presence from interpolated pollen
  maps and threshold values for pollen presence\\
\item
  Dispersal syndromes as reported by
  \href{https://doi.org/10.1007/s00035-007-0797-8}{Vittoz and Engler
  (2007)} and TRY Database
  (\href{https://doi.org/10.1111/j.1365-2486.2011.02451.x}{Kattge et
  al., 2011}): W = wind; Wa = water; B = bird; LA = large mammal (deer,
  badger, cattle); SA = small animal (e.g.~hoarding by rodents)\\
\item
  Competitor in model simulations: Bet\_pen / Bet\_pub = Betula pendula
  / Betula pubescens; C3G = boreal/temperate grasses (C3 photosynthesis
  pathway).
\end{enumerate}

    \hypertarget{model-lpj-gm}{%
\section{Model: LPJ-GM}\label{model-lpj-gm}}

LPJ-GM (\href{https://doi.org/10.5194/gmd-12-893-2019}{Lehsten et al.,
2019}) couples a dynamic migration module to the widely-used DGVM,
LPJ-GUESS (where LPJ-GM is short for LPJ-GUESS-MIGRATION). LPJ-GUESS
employs a gap model approach for the simulation of ecophysiological
processes and the structural dynamics of forests, including species
composition and vertical and horizontal heterogeneity
(\href{https://www.jstor.org/stable/3182691}{Smith et al.~2001}). Thus,
the migration module of LPJ-GM simulates local vegetation dynamics and
allows species to disperse simultaneously while interacting with each
other. Following the TreeMig model implementation
(\href{https://doi.org/10.1016/j.ecolmodel.2006.05.005}{Lischke and
Löffler (2006)}), LPJ-GM simulates migration at an yearly time-step
through four main processes: - \textbf{seed production}. The number of
seeds produced \(S\) is the product of maximum fecundity (\(FEC_{max}\))
and the proportion of current leaf area (\(LAI_{ind}\)) to the maximum
(\(LAI_{max}\)):

\[S = FEC_{max} \times \frac{LAI_{ind}}{LAI_{max}}\]

\begin{itemize}
\tightlist
\item
  \textbf{seed dispersal}. The seeds \(S(x',y')\) produced at a location
  (\(x',y'\)) then are distributed according to a probability density
  function (pdf), i.e.~the seed dispersal kernel \(k_s\), so that the
  seed input \(S_d\) (\(x,y\)) in location \(x,y\) is obtained by
  integrating over all other locations \(x’,y’\). The dispersal kernel
  \(k_s\) is a linear combination of two pdfs for short- (SDD) and
  long-distance dispersal (LDD), where \(LDD_p\) is the proportion of
  LDD, \(SDD_d\) and \(LDD_d\) are the average distances for SDD and
  LDD, respectively. In the default setting of LPJ-GM, the pdfs for both
  SDD and LDD components are negative exponentials.
\end{itemize}

\[S_d(x,y)= \int S(x',y') \times k_s(x-x',y-y')dx'dy'\]
\[k_s = (1-LDD_p)\times pdf(z,SDD_d) + LDD_p \times pdf(z,LDD_d)\]

\begin{itemize}
\tightlist
\item
  \textbf{seed bank dynamics}. Seed bank dynamics are defined by the
  yearly change of dormant seeds in the soil \(S_{sb}\) that can
  germinate in the following years. \(S_{sb}\) increases by the seed
  input \(S_d\) and decreases by the number of germinated seeds (where
  \(GERM_p\) is the rate of germination), or by loss of seeds
  (\(μ_s = 0.8\) as annual rate):
\end{itemize}

\[S_{sb,t+1} = S_{sb,t+1} \times (1-GERM_p)\times(1-μ_s) \]
\[S_{sb,t+1} = S_{sb,t}+S_{d,t+1}\]

\begin{itemize}
\tightlist
\item
  \textbf{seedling establishment}. The probability of seedling
  establishment in a certain year \(EST_p\) depends on the number of
  available seeds for germination (\(S_{sb}\)) and on the germination
  rate. The established seedlings grow, compete, and die according to
  the LPJ-GUESS approach. After reaching maturity, established saplings
  start producing seeds according the \(S\) formula.
\end{itemize}

\[EST_p = 0.01 \times S_{sb} \times GERM_p \]

At the end of the simulation, the species-specific migration rate
(meters year\(^{-1}\)) is calculated as the migration distance divided
by migration time, i.e.~simulation time elapsed since when trees are
allowed to perform seed dispersal. Migration distance is obtained by the
direct output of LPJ-GM, leaf area index (LAI), as the distance between
the starting point of migration and the \(95^{th}\) percentile farthest
point in the terrain where LAI exceeds 0.5.

\hypertarget{simulation-settings}{%
\subsection{Simulation settings}\label{simulation-settings}}

Simulations were performed for a total of 500 years and over an area of
201 x 201 cells with corridors each 200 km (for a total of 1,197 grid
cells), where tree species were allowed to establish freely in the
upper-left corner of the simulation landscape (the starting point of
migration). We applied a static suitable climate for all species and an
entirely permeable terrain to all grid cells and across all simulation
years in order to reproduce optimal environmental conditions for each
species' spread. We used the Fast Fourier transform method (FFTM) to
enhance the computational efficiency of seed dispersal, as described in
\href{https://doi.org/10.5194/gmd-12-893-2019}{Lehsten et al., 2019}.


\begin{table}[ht]
\centering
\resizebox{\textwidth}{!}{\begin{tabular}{lll}
\toprule
Parameter & Value & Description \\
\midrule
vegmode & ``cohort'' & simulation mode, either ``cohort'',
``individual'' or ``population'' \\
nyear\_spinup & 53 & number of years to spin up the simulation for \\
ifcalcsla & 1 & whether to calculate SLA from leaf longevity \\
ifcalccton & 1 & whether to calculate leaf C:N min from leaf
longevity \\
firemodel & ``NOFIRE'' & whether to implement fire (BLAZE, GLOBFIRM) or
not (NOFIRE) \\
weathergenerator & ``GWGEN'' & whether to generate climate at a smaller
scale or interpolate it \\
npatch & 1 & number of replicate patches to simulate \\
npatch\_secondarystand & 1 & number of replicate patches to simulate in
secondary stands \\
reduce\_all\_stands & 0 & whether to reduce equal percentage of all
stands of a stand type at land cover change \\
age\_limit\_reduce & 5 & Minimum age of stands to reduce at land cover
change \\
patcharea & 1000 & patch area (m2) \\
estinterval & 5 & years between establishment events in cohort mode \\
ifdisturb & 1 & whether generic patch-destroying disturbances enabled \\
distinterval & 400 & average return time for generic patch-destroying
disturbances \\
ifbgestab & 1 & whether background establishment enabled \\
ifsme & 1 & whether spatial mass effect enabled \\
ifstochestab & 0 & whether establishment stochastic \\
ifstochmort & 0 & whether mortality stochastic \\
ifcdebt & 1 & whether to allow vegetation C storage (1) or not (0) \\
wateruptake & ``rootdist'' & ``wcont'', ``rootdist'', ``smart'' or
``speciesspecific'' \\
rootdistribution & ``jackson'' & how to parameterise root distribution.
Alternatives are ``fixed'' or ``jackson'' \\
textured\_soil & 1 & whether to use silt/sand fractions specific to
soiltype \\
ifcentury & 1 & whether to use CENTURY SOM dynamics (mandatory for N
cycling) \\
ifnlim & 1 & whether plant growth limited by available N \\
freenyears & 100 & number of years to spin up without N limitation
(needed to build up a N pool) \\
nfix\_a & 0.102 & first term in N fixation eqn (Conservative 0.102,
Central 0.234, Upper 0.367) \\
nfix\_b & 0.524 & second term in N fixation eqn (Conservative 0.524,
Central -0.172, Upper -0.754) \\
nrelocfrac & 0.5 & fraction of N retranslocated prior to leaf and root
shedding \\
ifsmoothgreffmort & 1 & whether to vary mort\_greff smoothly with growth
efficiency (1) or to use the standard step-function (0) \\
ifdroughtlimitedestab & 0 & whether establishment is limited by growing
season drought \\
ifrainonwetdaysonly & 1 & whether to rain on wet days only (1), or to
rain a bit every day (0) \\
ifbvoc & 0 & whether to include BVOC calculations (1) or not (0) \\
searchradius\_soil & 0.01 & search for soil data in up to X degrees
around the EMDI coordinates \\
\bottomrule
\end{tabular}}
\end{table} 


\begin{table}[ht]
\centering
\resizebox{\textwidth}{!}{\begin{tabular}{lll}
\toprule
Parameter & Value & Description \\
\midrule
years\_total & 500 & total number of simulation years \\
domain & 11, 49, 0.01, 0.01 & coordindates of north-west corner and
longitude, latitude increments \\
subdomains & 201, 201, 1, 1 & size of the domain and number of
subdomains in lat-/long-itudinal direction \\
dispersal\_patchsize & 0.99 & patch size for dispersal calculations
(km2) \\
dispersal & ``fft'' & whether to use the Fast Fourier transform method
for seed dispersal \\
stochastic\_seed\_est\_scaler & 0.01 & scaler for stochastic seedling
establishment from dispersed seed \\
log\_stochastic\_seed\_est\_scaler & 0 & if larger than 0 no log
stochastic distribution for stochastic seedling establishment from
dispersed seeds \\
output\_interval & 1 & number of years between each output-year should
be larger or equal to 1 \\
EDGE\_CELLS & 40 & number of gridcells to fold into the central array of
dispersed seeds to avoid a torus effect \\
\bottomrule
\end{tabular}}
\end{table} 

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{3}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{c+c1}{\PYZsh{}\PYZsh{} Simulation domain}
\PY{n}{f}\PY{p}{,} \PY{n}{ax} \PY{o}{=} \PY{n}{plt}\PY{o}{.}\PY{n}{subplots}\PY{p}{(}\PY{p}{)}
\PY{n}{f}\PY{o}{.}\PY{n}{set\PYZus{}figheight}\PY{p}{(}\PY{l+m+mf}{3.54}\PY{p}{)}
\PY{n}{f}\PY{o}{.}\PY{n}{set\PYZus{}figwidth}\PY{p}{(}\PY{l+m+mf}{3.54}\PY{p}{)}
\PY{n}{f}\PY{o}{.}\PY{n}{dpi} \PY{o}{=} \PY{l+m+mi}{300}

\PY{c+c1}{\PYZsh{} Initialize the spatial domain (201x2001 grid cells)}
\PY{n}{sim\PYZus{}domain} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{zeros}\PY{p}{(}\PY{p}{(}\PY{l+m+mi}{201}\PY{p}{,} \PY{l+m+mi}{201}\PY{p}{)}\PY{p}{,} \PY{n+nb}{int}\PY{p}{)}

\PY{c+c1}{\PYZsh{} Add corridors as major diagonals and perimeter}
\PY{n}{np}\PY{o}{.}\PY{n}{fill\PYZus{}diagonal}\PY{p}{(}\PY{n}{sim\PYZus{}domain}\PY{p}{,} \PY{l+m+mi}{1}\PY{p}{)}
\PY{n}{np}\PY{o}{.}\PY{n}{fill\PYZus{}diagonal}\PY{p}{(}\PY{n}{np}\PY{o}{.}\PY{n}{fliplr}\PY{p}{(}\PY{n}{sim\PYZus{}domain}\PY{p}{)}\PY{p}{,} \PY{l+m+mi}{1}\PY{p}{)}
\PY{n}{sim\PYZus{}domain}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{,}\PY{p}{:}\PY{p}{]} \PY{o}{=} \PY{l+m+mi}{1}
\PY{n}{sim\PYZus{}domain}\PY{p}{[}\PY{p}{:}\PY{p}{,}\PY{l+m+mi}{0}\PY{p}{]} \PY{o}{=} \PY{l+m+mi}{1}
\PY{n}{sim\PYZus{}domain}\PY{p}{[}\PY{l+m+mi}{200}\PY{p}{,}\PY{p}{:}\PY{p}{]} \PY{o}{=} \PY{l+m+mi}{1}
\PY{n}{sim\PYZus{}domain}\PY{p}{[}\PY{p}{:}\PY{p}{,}\PY{l+m+mi}{200}\PY{p}{]} \PY{o}{=} \PY{l+m+mi}{1}

\PY{c+c1}{\PYZsh{} Plot}
\PY{n}{ax}\PY{o}{.}\PY{n}{imshow}\PY{p}{(}\PY{n}{sim\PYZus{}domain}\PY{p}{,} \PY{n}{cmap}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Reds}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{interpolation}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{nearest}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}

\PY{c+c1}{\PYZsh{} Add refugium}
\PY{n}{ax}\PY{o}{.}\PY{n}{scatter}\PY{p}{(}\PY{l+m+mi}{0}\PY{p}{,}\PY{l+m+mi}{0}\PY{p}{,} \PY{n}{s}\PY{o}{=}\PY{l+m+mi}{25}\PY{p}{,} \PY{n}{edgecolor}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{white}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{facecolor}\PY{o}{=}\PY{p}{(}\PY{l+m+mi}{1}\PY{p}{,} \PY{l+m+mi}{1}\PY{p}{,} \PY{l+m+mi}{0}\PY{p}{,} \PY{l+m+mf}{0.5}\PY{p}{)}\PY{p}{)}

\PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}frame\PYZus{}on}\PY{p}{(}\PY{k+kc}{False}\PY{p}{)}
\PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}ylabel}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Distance from refugia in km}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}xlabel}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Distance from refugia in km}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}title}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Simulation domain}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{n}{fontweight}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{bold}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}

\PY{c+c1}{\PYZsh{} Export figure   }
\PY{n}{plt}\PY{o}{.}\PY{n}{savefig}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Figure\PYZus{}S1.png}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{bbox\PYZus{}inches}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{tight}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{dpi}\PY{o}{=}\PY{l+m+mi}{300}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{show}\PY{p}{(}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}

    \begin{center}
    \adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{output_7_0.png}
    \end{center}
    { \hspace*{\fill} \\}
    
    \hypertarget{migration-parameters}{%
\section{Migration parameters}\label{migration-parameters}}

Since the underlying framework, LPJ-GUESS, has been already extensively
validated for different metrics of vegetation composition and structure
(e.g.~\href{https://doi.org/10.1002/jgrg.20035}{Pappas et al.~2013}), we
focused our calibration effort on the newly-added migration parameters:
\(FEC_{max}\), \(GERM_p\), \(SDD_d\) and \(LDD_d\). Range values of each
parameter were compiled by reviewing research articles and public
databases as indicated in \textbf{Table 2}. We identified the minimum
and maximum values per parameter as the lower and upper bounds,
respectively, and calculated the mean along with the \(25^{th}\) and
\(75^{th}\) percentiles, assuming a normal distribution (see
\texttt{Table\ B1} in the main text and \texttt{SA\_input} in this
notebook for species-specific values:
\texttt{Default},\texttt{Min},\texttt{25th},\texttt{Mean},\texttt{75th},\texttt{Max},
where default parameters correspond to the values reported by
\href{https://doi.org/10.1016/j.ecolmodel.2006.05.005}{Lischke and
Löffler (2006)}). \texttt{var\%} indicates the normalized variability of
species-specific parameters, in percentage:
\(\frac{x_{max}-x_{min}}{x_{max}} \times 100\).

\textbf{Table 2}. Description of the migration parameters and data
source: a =
\href{https://doi.org/10.1016/j.ecolmodel.2006.05.005}{Lischke and
Löffler (2006)}; b = TRY database
(\href{https://doi.org/10.1111/j.1365-2486.2011.02451.x}{Kattge et al.,
2011}); c = Royal Botanic Gardens Kew Seed Information Database
(\href{https://data.kew.org/sid/}{SID}); d =
\href{https://doi.org/10.1007/s00035-007-0797-8}{Vittoz and Engler
(2007)}; e = \href{https://doi.org/10.1890/13-1000.1}{Tamme et
al.~(2014)}.

\begin{longtable}[]{@{}llll@{}}
\toprule
Parameter & Notation & Unit & References \\
\midrule
\endhead
Maximum fecundity per tree and year & FEC\_max & no.seeds (in 100) & a,
b, c \\
Seed germination rate & GERM\_p & \% & a, b, c \\
Average short dispersal distance & SDD\_d & meters & a, b, d \\
Average long dispersal distance (1\%) & LDD\_d & meters & a, b, d, e \\
\bottomrule
\end{longtable}

    \hypertarget{helper-functions}{%
\section{Helper functions}\label{helper-functions}}

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{4}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{c+c1}{\PYZsh{} Scale values from 0 to 1}
\PY{k}{def} \PY{n+nf}{scaler\PYZus{}0\PYZus{}1}\PY{p}{(}\PY{n}{df}\PY{p}{)}\PY{p}{:}
    \PY{k}{return} \PY{p}{(}\PY{n}{df} \PY{o}{\PYZhy{}} \PY{n}{np}\PY{o}{.}\PY{n}{min}\PY{p}{(}\PY{n}{df}\PY{p}{)}\PY{p}{)} \PY{o}{/} \PY{p}{(}\PY{n}{np}\PY{o}{.}\PY{n}{max}\PY{p}{(}\PY{n}{df}\PY{p}{)} \PY{o}{\PYZhy{}} \PY{n}{np}\PY{o}{.}\PY{n}{min}\PY{p}{(}\PY{n}{df}\PY{p}{)}\PY{p}{)}

\PY{c+c1}{\PYZsh{} Mean normalization}
\PY{c+c1}{\PYZsh{} i.e. centers around 0 while keeping positive and negative values}
\PY{k}{def} \PY{n+nf}{mean\PYZus{}norm}\PY{p}{(}\PY{n}{data}\PY{p}{)}\PY{p}{:}
    \PY{k}{return} \PY{p}{(}\PY{n}{data} \PY{o}{\PYZhy{}} \PY{n}{np}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{n}{data}\PY{p}{)}\PY{p}{)} \PY{o}{/} \PY{p}{(}\PY{n+nb}{max}\PY{p}{(}\PY{n}{data}\PY{p}{)} \PY{o}{\PYZhy{}} \PY{n+nb}{min}\PY{p}{(}\PY{n}{data}\PY{p}{)}\PY{p}{)}

\PY{c+c1}{\PYZsh{} Calculate RMSE}
\PY{k}{def} \PY{n+nf}{rmse\PYZus{}perc}\PY{p}{(}\PY{n}{sim}\PY{p}{,}\PY{n}{obs}\PY{p}{,}\PY{n}{obs\PYZus{}mean}\PY{p}{)}\PY{p}{:}
    \PY{n}{MSE} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{square}\PY{p}{(}\PY{n}{np}\PY{o}{.}\PY{n}{subtract}\PY{p}{(}\PY{n}{sim}\PY{p}{,}\PY{n}{obs}\PY{p}{)}\PY{p}{)}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{p}{)} 
    \PY{n}{RMSE} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{sqrt}\PY{p}{(}\PY{n}{MSE}\PY{p}{)}
    \PY{k}{return} \PY{p}{(}\PY{l+m+mi}{100} \PY{o}{/} \PY{n}{obs\PYZus{}mean}\PY{p}{)} \PY{o}{*} \PY{n}{RMSE}

\PY{c+c1}{\PYZsh{} Calculate standard error}
\PY{n}{f\PYZus{}ste} \PY{o}{=} \PY{k}{lambda} \PY{n}{x} \PY{p}{:} \PY{n}{x}\PY{o}{.}\PY{n}{std}\PY{p}{(}\PY{p}{)} \PY{o}{/} \PY{n}{np}\PY{o}{.}\PY{n}{sqrt}\PY{p}{(} \PY{n}{x}\PY{o}{.}\PY{n}{count}\PY{p}{(}\PY{p}{)} \PY{p}{)}
\PY{n}{f\PYZus{}ste}\PY{o}{.}\PY{n+nv+vm}{\PYZus{}\PYZus{}name\PYZus{}\PYZus{}} \PY{o}{=} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ste}\PY{l+s+s1}{\PYZsq{}}

\PY{c+c1}{\PYZsh{} Find minimum residuals}
\PY{k}{def} \PY{n+nf}{min\PYZus{}residual}\PY{p}{(}\PY{n}{group}\PY{p}{)} \PY{p}{:}
    \PY{n}{residuals} \PY{o}{=} \PY{n}{group}\PY{o}{.}\PY{n}{residuals\PYZus{}abs}
    \PY{n}{output} \PY{o}{=} \PY{n}{group}\PY{p}{[}\PY{n}{residuals} \PY{o}{==} \PY{n}{residuals}\PY{o}{.}\PY{n}{min}\PY{p}{(}\PY{p}{)}\PY{p}{]}
    \PY{k}{if} \PY{p}{(}\PY{n}{output}\PY{o}{.}\PY{n}{shape}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]} \PY{o}{\PYZgt{}} \PY{l+m+mi}{1}\PY{p}{)} \PY{p}{:}
        \PY{n}{output} \PY{o}{=} \PY{n}{output}\PY{o}{.}\PY{n}{head}\PY{p}{(}\PY{l+m+mi}{1}\PY{p}{)}
    \PY{k}{return} \PY{n}{output}
\end{Verbatim}
\end{tcolorbox}

    \hypertarget{load-data}{%
\section{Load data}\label{load-data}}

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{5}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{c+c1}{\PYZsh{} Load data (\PYZbs{}\PYZbs{} for Windows)}
\PY{n}{SA\PYZus{}input} \PY{o}{=} \PY{n}{pd}\PY{o}{.}\PY{n}{read\PYZus{}table}\PY{p}{(}\PY{n}{datapath}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+se}{\PYZbs{}\PYZbs{}}\PY{l+s+s1}{Input\PYZus{}SA.csv}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{n}{header}\PY{o}{=}\PY{l+m+mi}{0}\PY{p}{,}\PY{n}{delimiter}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{;}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n}{EVA\PYZus{}input} \PY{o}{=} \PY{n}{pd}\PY{o}{.}\PY{n}{read\PYZus{}table}\PY{p}{(}\PY{n}{datapath}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+se}{\PYZbs{}\PYZbs{}}\PY{l+s+s1}{Input\PYZus{}EVA.csv}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{n}{header}\PY{o}{=}\PY{l+m+mi}{0}\PY{p}{,}\PY{n}{delimiter}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{;}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n}{KA\PYZus{}input} \PY{o}{=} \PY{n}{pd}\PY{o}{.}\PY{n}{read\PYZus{}table}\PY{p}{(}\PY{n}{datapath}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+se}{\PYZbs{}\PYZbs{}}\PY{l+s+s1}{Input\PYZus{}KA.csv}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{n}{header}\PY{o}{=}\PY{l+m+mi}{0}\PY{p}{,}\PY{n}{delimiter}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{;}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n}{SA\PYZus{}fatkernels\PYZus{}input} \PY{o}{=} \PY{n}{pd}\PY{o}{.}\PY{n}{read\PYZus{}table}\PY{p}{(}\PY{n}{datapath}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+se}{\PYZbs{}\PYZbs{}}\PY{l+s+s1}{Input\PYZus{}SA\PYZus{}model2.csv}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{n}{header}\PY{o}{=}\PY{l+m+mi}{0}\PY{p}{,}\PY{n}{delimiter}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{;}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{6}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{SA\PYZus{}input}\PY{o}{.}\PY{n}{iloc}\PY{p}{[}\PY{p}{:}\PY{p}{,}\PY{l+m+mi}{0}\PY{p}{:}\PY{l+m+mi}{10}\PY{p}{]}\PY{o}{.}\PY{n}{to\PYZus{}csv}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Table\PYZus{}B1.csv}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{sep}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{;}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{index}\PY{o}{=}\PY{k+kc}{False}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}

    \hypertarget{evaluation-of-parameter-uncertainty}{%
\section{Evaluation of parameter
uncertainty}\label{evaluation-of-parameter-uncertainty}}

\hypertarget{local-sensitivity-analysis-lsa}{%
\subsection{Local Sensitivity Analysis
(LSA)}\label{local-sensitivity-analysis-lsa}}

As a first step, we applied a species-specific local sensitivity
analysis (LSA). We followed the approach by
\href{https://doi.org/10.1080/00401706.1985.10488032}{Downing et
al.~(1985)} and applied a 5-points one-at-a-time sensitivity analysis,
where one parameter is adjusted to its minimum, mean, maximum,
\(25^{th}\) and \(75^{th}\) percentile values, while the others are kept
at their default values (\texttt{Table\ S1}). We quantified the response
of the model to each parameter in terms of directionality, linearity and
magnitude by four summary statistics: the Sensitivity Index (SI), two
Importance Indexes (II1 and II2), and the Linearity Index (LI)
(\href{https://doi.org/10.1080/00401706.1985.10488032}{Downing et
al.~(1985)}; \href{https://doi.org/10.1007/BF00547132}{Hamby, 1995}):

\[SI= \frac{\Delta y}{\Delta x_i} \]

where \(\Delta y\) is the average of the differences of the output
values for the 5-points, and \(\Delta x_i\) is the corresponding 25\%
value change for each input parameter \(x_i\).

The first Importance Index \(II_{1,i}\) of parameter \(i\) is the
product between the uncertainty of parameter \(i\) (\(UI_i\)) and its
effect on the model ouput \(SI_i\):

\[II_{1,i}=UI_i \times SI_i\]

\[UI=\frac{x_{max}-x_{min}}{x_{max}}\]

where the uncertainty \(UI_i\) of parameter \(i\) is its scaled range
from its minimum to its maximum.

The second Importance Index \(II_{2,i}\) of parameter \(i\) is
calculated as the percentage difference of the output \(y\)
(i.e.~migration rate) when varying the input parameter \(x_i\) from its
minimum to its maximum:

\[II_{2,i}=\frac{y_{max}-y_{min}}{y_{max}}\]

The Linearity Index \(LI_i\) indicates whether the relationship between
each input parameter and the model output approach linearity:

\[LI_i= \frac{y_{max}-y_{min}}{\sqrt{s^2}}\]

where \(s^2\) is the sample variance of the model output and an exact
linear relationship between model output and parameter corresponds to
\(LI_i=1\).

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{7}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{c+c1}{\PYZsh{} Calculate parameter uncertainty (UI)}
\PY{n}{SA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{UI}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n}{SA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Max}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{\PYZhy{}} \PY{n}{SA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Min}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}

\PY{c+c1}{\PYZsh{} Print UI statistics }
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter uncertainty mean:}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n+nb}{print}\PY{p}{(}\PY{n}{SA\PYZus{}input}\PY{p}{[}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameters}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{UI}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{]}\PY{o}{.}\PY{n}{groupby}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameters}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{p}{)}\PY{p}{)} 
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter uncertainty standard deviation:}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n+nb}{print}\PY{p}{(}\PY{n}{SA\PYZus{}input}\PY{p}{[}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameters}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{UI}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{]}\PY{o}{.}\PY{n}{groupby}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameters}\PY{l+s+s1}{\PYZsq{}}\P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q{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{SI3}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{SI4}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{]}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{n}{axis}\PY{o}{=}\PY{l+m+mi}{1}\PY{p}{)}

\PY{c+c1}{\PYZsh{} Calculate Importance Index (II1)}
\PY{c+c1}{\PYZsh{} product of sensitivity and normalized [0\PYZhy{}1] parameter uncertainty}
\PY{n}{UI\PYZus{}norm} \PY{o}{=} \PY{p}{(}\PY{n}{SA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Max}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{\PYZhy{}} \PY{n}{SA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Min}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{)} \PY{o}{/} \PY{n}{SA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Max}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} 
\PY{n}{SA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{II1}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n}{UI\PYZus{}norm} \PY{o}{*} \PY{n}{SA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{SI}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}

\PY{c+c1}{\PYZsh{} Calculate Importance Index (II2)}
\PY{c+c1}{\PYZsh{} output percentage difference}
\PY{n}{SA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{II2}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{p}{(}\PY{n}{SA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{MigRate\PYZus{}Max}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{\PYZhy{}} \PY{n}{SA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{MigRate\PYZus{}Min}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{)} \PY{o}{/} \PY{n}{SA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{MigRate\PYZus{}Max}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}

\PY{c+c1}{\PYZsh{} Calculate the Linearity Index (LI)}
\PY{c+c1}{\PYZsh{} ratio between output range and ca. standard deviation of parameter range}
\PY{n}{SA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{LI}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{p}{(}\PY{n}{SA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{MigRate\PYZus{}Max}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{\PYZhy{}} \PY{n}{SA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{MigRate\PYZus{}Min}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{)} \PY{o}{/} \PY{p}{(}\PY{p}{(}\PY{n}{SA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Max}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{\PYZhy{}} \PY{n}{SA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Min}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{)} \PY{o}{/} \PY{l+m+mi}{2}\PY{p}{)}

\PY{c+c1}{\PYZsh{} Calculate summary statistic}
\PY{n}{SA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{SA\PYZus{}total}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n}{SA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{SI}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{+} \PY{n}{SA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{II1}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{+} \PY{n}{SA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{II2}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{+} \PY{n}{SA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{LI}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}

\PY{c+c1}{\PYZsh{} Export Supplement Table 1}
\PY{n}{Supplement\PYZus{}Table\PYZus{}S1} \PY{o}{=} \PY{n}{SA\PYZus{}input}\PY{p}{[}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameters}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{UI}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{SI}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{II1}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{II2}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{LI}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{]}

\PY{c+c1}{\PYZsh{} Save table}
\PY{n}{Supplement\PYZus{}Table\PYZus{}S1}\PY{o}{.}\PY{n}{to\PYZus{}csv}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Table\PYZus{}S1.csv}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{sep}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{;}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{index}\PY{o}{=}\PY{k+kc}{False}\PY{p}{)}

\PY{c+c1}{\PYZsh{} Summary statistics}
\PY{n}{Supplement\PYZus{}Table\PYZus{}S1}\PY{o}{.}\PY{n}{groupby}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameters}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}\PY{o}{.}\PY{n}{describe}\PY{p}{(}\PY{p}{)}

\PY{c+c1}{\PYZsh{} Plot Figure 1}
\PY{n}{SI\PYZus{}df} \PY{o}{=} \PY{n}{SA\PYZus{}input}\PY{o}{.}\PY{n}{groupby}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameters}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}\PY{o}{.}\PY{n}{agg}\PY{p}{(}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{mean}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{n}{f\PYZus{}ste}\PY{p}{]}\PY{p}{)}\PY{o}{.}\PY{n}{T}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{SI}\PY{l+s+s1}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s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{II1\PYZus{}mean}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{II1\PYZus{}ste}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{II2\PYZus{}mean}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{II2\PYZus{}ste}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{LI\PYZus{}mean}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{LI\PYZus{}ste}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}
                    \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{SA\PYZus{}tot\PYZus{}mean}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{SA\PYZus{}tot\PYZus{}ste}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}
\PY{n}{SA\PYZus{}toPlot} \PY{o}{=} \PY{n}{SA\PYZus{}toPlot}\PY{o}{.}\PY{n}{sort\PYZus{}values}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{SA\PYZus{}tot\PYZus{}mean}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{n}{ascending}\PY{o}{=}\PY{k+kc}{False}\PY{p}{)}
\PY{n}{labels} \PY{o}{=} \PY{n}{SA\PYZus{}toPlot}\PY{o}{.}\PY{n}{index}
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+se}{\PYZbs{}n}\PY{l+s+s1}{Ranked parameters across species: }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n+nb}{str}\PY{p}{(}\PY{n}{labels}\PY{o}{.}\PY{n}{values}\PY{o}{.}\PY{n}{tolist}\PY{p}{(}\PY{p}{)}\PY{p}{)}\PY{p}{)}
\PY{n}{labels} \PY{o}{=} \PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{SDD\PYZdl{}\PYZus{}d\PYZdl{}}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{LDD\PYZdl{}\PYZus{}d\PYZdl{}}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{FEC\PYZdl{}\PYZus{}}\PY{l+s+si}{\PYZob{}max\PYZcb{}}\PY{l+s+s1}{\PYZdl{}}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{GERM\PYZdl{}\PYZus{}p\PYZdl{}}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}

\PY{n}{x} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{arange}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{labels}\PY{p}{)}\PY{p}{)} \PY{c+c1}{\PYZsh{} the label locations}
\PY{n}{width} \PY{o}{=} \PY{l+m+mf}{0.2}  \PY{c+c1}{\PYZsh{} the width of the bars}

\PY{n}{f}\PY{p}{,} \PY{n}{ax} \PY{o}{=} \PY{n}{plt}\PY{o}{.}\PY{n}{subplots}\PY{p}{(}\PY{p}{)}
\PY{n}{f}\PY{o}{.}\PY{n}{set\PYZus{}figheight}\PY{p}{(}\PY{l+m+mf}{3.54}\PY{p}{)}
\PY{n}{f}\PY{o}{.}\PY{n}{set\PYZus{}figwidth}\PY{p}{(}\PY{l+m+mf}{3.54}\PY{p}{)}
\PY{n}{f}\PY{o}{.}\PY{n}{dpi} \PY{o}{=} \PY{l+m+mi}{300}

\PY{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p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{II2\PYZus{}mean}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{,} \PY{n}{width}\PY{p}{,} \PY{n}{yerr}\PY{o}{=}\PY{n}{SA\PYZus{}toPlot}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{II2\PYZus{}ste}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{,} \PY{n}{label}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{II2}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n}{rects4} \PY{o}{=} \PY{n}{ax}\PY{o}{.}\PY{n}{bar}\PY{p}{(}\PY{n}{x} \PY{o}{+} \PY{n}{width}\PY{p}{,} \PY{n}{SA\PYZus{}toPlot}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{LI\PYZus{}mean}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{,} \PY{n}{width}\PY{p}{,} \PY{n}{yerr}\PY{o}{=}\PY{n}{SA\PYZus{}toPlot}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{LI\PYZus{}ste}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{,} \PY{n}{label}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{LI}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}

\PY{c+c1}{\PYZsh{} Add some text for labels, title and custom x\PYZhy{}axis tick labels, etc.}
\PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}ylabel}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Sensitivity Analysis Index}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}xticks}\PY{p}{(}\PY{n}{x}\PY{p}{)}
\PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}xticklabels}\PY{p}{(}\PY{n}{labels}\PY{p}{)}
\PY{n}{ax}\PY{o}{.}\PY{n}{legend}\PY{p}{(}\PY{n}{frameon}\PY{o}{=}\PY{k+kc}{False}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{xticks}\PY{p}{(}\PY{n}{rotation}\PY{o}{=}\PY{l+m+mi}{45}\PY{p}{)}

\PY{c+c1}{\PYZsh{} Export figure   }
\PY{n}{plt}\PY{o}{.}\PY{n}{savefig}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Figure\PYZus{}1.png}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{bbox\PYZus{}inches}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{tight}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{dpi}\PY{o}{=}\PY{l+m+mi}{300}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}

    \begin{Verbatim}[commandchars=\\\{\}]
Parameter uncertainty mean:
                     UI
Parameters
FEC\_max     3470.823529
GERM\_p        27.294118
LDD\_d        775.352941
SDD\_d         61.521765
Parameter uncertainty standard deviation:
                     UI
Parameters
FEC\_max     9339.379083
GERM\_p        19.639771
LDD\_d       1627.992166
SDD\_d         34.656158

Ranked parameters across species: ['SDD\_d', 'LDD\_d', 'FEC\_max', 'GERM\_p']
    \end{Verbatim}

    \begin{center}
    \adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{output_15_1.png}
    \end{center}
    { \hspace*{\fill} \\}
    
    \hypertarget{species-specific-parameter-ranking}{%
\subsubsection{Species-specific parameter
ranking}\label{species-specific-parameter-ranking}}

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{8}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{c+c1}{\PYZsh{} Calculate a summary index as the summation of all others}
\PY{n}{SA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{SA\PYZus{}total}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n}{SA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{SI}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{+} \PY{n}{SA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{II1}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{+} \PY{n}{SA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{II2}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{+} \PY{n}{SA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{LI}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}

\PY{n}{species} \PY{o}{=} \PY{n}{SA\PYZus{}input}\PY{o}{.}\PY{n}{Species}\PY{o}{.}\PY{n}{unique}\PY{p}{(}\PY{p}{)}
\PY{k}{for} \PY{n}{sp} \PY{o+ow}{in} \PY{n}{species} \PY{p}{:}
    \PY{n}{sub\PYZus{}sp} \PY{o}{=} \PY{n}{SA\PYZus{}input}\PY{p}{[}\PY{n}{SA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{==}\PY{n}{sp}\PY{p}{]}
    \PY{n}{sub\PYZus{}sp} \PY{o}{=} \PY{n}{sub\PYZus{}sp}\PY{o}{.}\PY{n}{sort\PYZus{}values}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{SA\PYZus{}total}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{n}{ascending}\PY{o}{=}\PY{k+kc}{False}\PY{p}{)}
    \PY{n}{labels} \PY{o}{=} \PY{n}{sub\PYZus{}sp}\PY{o}{.}\PY{n}{Parameters}
    \PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species: }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n+nb}{str}\PY{p}{(}\PY{n}{sp}\PY{p}{)}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ \PYZhy{}\PYZhy{}\PYZgt{} Ranks 1: }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n}{labels}\PY{o}{.}\PY{n}{values}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{o}{+}
          \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ | 2: }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n}{labels}\PY{o}{.}\PY{n}{values}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ | 2: }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n}{labels}\PY{o}{.}\PY{n}{values}\PY{p}{[}\PY{l+m+mi}{2}\PY{p}{]}\PY{o}{+}
          \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ | 3: }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n}{labels}\PY{o}{.}\PY{n}{values}\PY{p}{[}\PY{l+m+mi}{3}\PY{p}{]}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}

    \begin{Verbatim}[commandchars=\\\{\}]
Species: Abi\_alb --> Ranks 1: SDD\_d | 2: FEC\_max | 2: LDD\_d | 3: GERM\_p
Species: Bet\_pen --> Ranks 1: GERM\_p | 2: SDD\_d | 2: LDD\_d | 3: FEC\_max
Species: Bet\_pub --> Ranks 1: GERM\_p | 2: SDD\_d | 2: LDD\_d | 3: FEC\_max
Species: Car\_bet --> Ranks 1: SDD\_d | 2: LDD\_d | 2: GERM\_p | 3: FEC\_max
Species: Cor\_ave --> Ranks 1: FEC\_max | 2: SDD\_d | 2: LDD\_d | 3: GERM\_p
Species: Fag\_syl --> Ranks 1: SDD\_d | 2: FEC\_max | 2: LDD\_d | 3: GERM\_p
Species: Fra\_exc --> Ranks 1: SDD\_d | 2: LDD\_d | 2: GERM\_p | 3: FEC\_max
Species: Pic\_abi --> Ranks 1: LDD\_d | 2: SDD\_d | 2: GERM\_p | 3: FEC\_max
Species: Pic\_sit --> Ranks 1: SDD\_d | 2: LDD\_d | 2: GERM\_p | 3: FEC\_max
Species: Pin\_syl --> Ranks 1: FEC\_max | 2: SDD\_d | 2: LDD\_d | 3: GERM\_p
Species: Pin\_hal --> Ranks 1: LDD\_d | 2: FEC\_max | 2: GERM\_p | 3: SDD\_d
Species: Que\_coc --> Ranks 1: LDD\_d | 2: SDD\_d | 2: FEC\_max | 3: GERM\_p
Species: Que\_ile --> Ranks 1: LDD\_d | 2: FEC\_max | 2: SDD\_d | 3: GERM\_p
Species: Que\_pub --> Ranks 1: FEC\_max | 2: SDD\_d | 2: GERM\_p | 3: LDD\_d
Species: Que\_rob --> Ranks 1: LDD\_d | 2: FEC\_max | 2: SDD\_d | 3: GERM\_p
Species: Til\_cor --> Ranks 1: SDD\_d | 2: LDD\_d | 2: GERM\_p | 3: FEC\_max
Species: Ulm\_gla --> Ranks 1: SDD\_d | 2: LDD\_d | 2: GERM\_p | 3: FEC\_max
    \end{Verbatim}

    \hypertarget{species-specific-linear-regression-statistics}{%
\subsubsection{Species-specific linear regression
statistics}\label{species-specific-linear-regression-statistics}}

Additionally, we conducted species-specific linear regression analyses
of the type \(y\sim x_i\), such that every change of one parameter
\(x_i\) unit translates to a change of migration rate (\(y\)) given by
the slope coefficient of the regression (i.e.~a slope value of 1 should
correspond to \(LI_i\sim1\)).

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{9}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{c+c1}{\PYZsh{} Calculate linear regression statistics}
\PY{k}{def} \PY{n+nf}{lm\PYZus{}slope}\PY{p}{(}\PY{n}{group}\PY{p}{)}\PY{p}{:}
    \PY{n}{x} \PY{o}{=} \PY{n}{group}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{value}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}
    \PY{n}{y} \PY{o}{=} \PY{n}{group}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{MigRates}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}
    \PY{n}{slope}\PY{p}{,} \PY{n}{intercept}\PY{p}{,} \PY{n}{r}\PY{p}{,} \PY{n}{p}\PY{p}{,} \PY{n}{se} \PY{o}{=} \PY{n}{stats}\PY{o}{.}\PY{n}{linregress}\PY{p}{(}\PY{n}{x}\PY{p}{,} \PY{n}{y}\PY{p}{)}
    \PY{k}{return} \PY{n}{slope}

\PY{k}{def} \PY{n+nf}{lm\PYZus{}intercept}\PY{p}{(}\PY{n}{group}\PY{p}{)}\PY{p}{:}
    \PY{n}{x} \PY{o}{=} \PY{n}{group}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{value}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}
    \PY{n}{y} \PY{o}{=} \PY{n}{group}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{MigRates}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}
    \PY{n}{slope}\PY{p}{,} \PY{n}{intercept}\PY{p}{,} \PY{n}{r}\PY{p}{,} \PY{n}{p}\PY{p}{,} \PY{n}{se} \PY{o}{=} \PY{n}{stats}\PY{o}{.}\PY{n}{linregress}\PY{p}{(}\PY{n}{x}\PY{p}{,} \PY{n}{y}\PY{p}{)}
    \PY{k}{return} \PY{n}{intercept}

\PY{k}{def} \PY{n+nf}{lm\PYZus{}r}\PY{p}{(}\PY{n}{group}\PY{p}{)}\PY{p}{:}
    \PY{n}{x} \PY{o}{=} \PY{n}{group}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{value}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}
    \PY{n}{y} \PY{o}{=} \PY{n}{group}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{MigRates}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}
    \PY{n}{slope}\PY{p}{,} \PY{n}{intercept}\PY{p}{,} \PY{n}{r}\PY{p}{,} \PY{n}{p}\PY{p}{,} \PY{n}{se} \PY{o}{=} \PY{n}{stats}\PY{o}{.}\PY{n}{linregress}\PY{p}{(}\PY{n}{x}\PY{p}{,} \PY{n}{y}\PY{p}{)}
    \PY{k}{return} \PY{n}{r}

\PY{k}{def} \PY{n+nf}{lm\PYZus{}pvalue}\PY{p}{(}\PY{n}{group}\PY{p}{)}\PY{p}{:}
    \PY{n}{x} \PY{o}{=} \PY{n}{group}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{value}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}
    \PY{n}{y} \PY{o}{=} \PY{n}{group}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{MigRates}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}
    \PY{n}{slope}\PY{p}{,} \PY{n}{intercept}\PY{p}{,} \PY{n}{r}\PY{p}{,} \PY{n}{p}\PY{p}{,} \PY{n}{se} \PY{o}{=} \PY{n}{stats}\PY{o}{.}\PY{n}{linregress}\PY{p}{(}\PY{n}{x}\PY{p}{,} \PY{n}{y}\PY{p}{)}
    \PY{k}{return} \PY{n}{p}

\PY{c+c1}{\PYZsh{} Format table to longer format (from 5\PYZhy{}points)}
\PY{n}{long\PYZus{}df} \PY{o}{=} \PY{n}{SA\PYZus{}input}\PY{p}{[}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Y{n}{lm\PYZus{}stats\PYZus{}df} \PY{o}{=} \PY{n}{long\PYZus{}df}\PY{o}{.}\PY{n}{groupby}\PY{p}{(}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameters}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{)}\PY{p}{[}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{value}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{MigRates}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{]}\PY{o}{.}\PY{n}{apply}\PY{p}{(}\PY{n}{lm\PYZus{}slope}\PY{p}{)}
\PY{n}{lm\PYZus{}stats\PYZus{}df} \PY{o}{=} \PY{n}{lm\PYZus{}stats\PYZus{}df}\PY{o}{.}\PY{n}{reset\PYZus{}index}\PY{p}{(}\PY{p}{)}

\PY{n}{intercepts} \PY{o}{=} \PY{n}{long\PYZus{}df}\PY{o}{.}\PY{n}{groupby}\PY{p}{(}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameters}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{)}\PY{p}{[}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{value}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{MigRates}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{]}\PY{o}{.}\PY{n}{apply}\PY{p}{(}\PY{n}{lm\PYZus{}intercept}\PY{p}{)}
\PY{n}{intercepts} \PY{o}{=} \PY{n}{intercepts}\PY{o}{.}\PY{n}{reset\PYZus{}index}\PY{p}{(}\PY{p}{)}

\PY{n}{r\PYZus{}coeffs} \PY{o}{=} \PY{n}{long\PYZus{}df}\PY{o}{.}\PY{n}{groupby}\PY{p}{(}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameters}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{)}\PY{p}{[}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{value}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{MigRates}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{]}\PY{o}{.}\PY{n}{apply}\PY{p}{(}\PY{n}{lm\PYZus{}r}\PY{p}{)}
\PY{n}{r\PYZus{}coeffs} \PY{o}{=} \PY{n}{r\PYZus{}coeffs}\PY{o}{.}\PY{n}{reset\PYZus{}index}\PY{p}{(}\PY{p}{)}

\PY{n}{pvalues} \PY{o}{=} \PY{n}{long\PYZus{}df}\PY{o}{.}\PY{n}{groupby}\PY{p}{(}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameters}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{)}\PY{p}{[}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{value}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{MigRates}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{]}\PY{o}{.}\PY{n}{apply}\PY{p}{(}\PY{n}{lm\PYZus{}pvalue}\PY{p}{)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}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameters}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{p}{)}

\PY{c+c1}{\PYZsh{} Print results}
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Linear regression summary:}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n}{lm\PYZus{}stats\PYZus{}df}\PY{o}{.}\PY{n}{groupby}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameters}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}\PY{o}{.}\PY{n}{describe}\PY{p}{(}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}

    \begin{Verbatim}[commandchars=\\\{\}]
Linear regression summary:
    \end{Verbatim}

            \begin{tcolorbox}[breakable, size=fbox, boxrule=.5pt, pad at break*=1mm, opacityfill=0]
\prompt{Out}{outcolor}{9}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
           slope                                                              \textbackslash{}
           count      mean       std       min       25\%       50\%       75\%
Parameters
FEC\_max     17.0  0.199839  0.287580 -0.168000  0.000085  0.083333  0.341935
GERM\_p      17.0  0.084665  0.365090 -0.640000  0.000000  0.000000  0.266667
LDD\_d       17.0  0.298626  0.206200  0.000000  0.156023  0.256000  0.409231
SDD\_d       17.0  0.580878  0.306906  0.041365  0.388151  0.555311  0.848000

                     intercept             {\ldots}        r2           pvalue  \textbackslash{}
                 max     count       mean  {\ldots}       75\%       max  count
Parameters                                 {\ldots}
FEC\_max     0.918919      17.0  39.734360  {\ldots}  0.798913  0.874379   17.0
GERM\_p      0.740000      17.0  47.836903  {\ldots}  0.541535  0.925926   17.0
LDD\_d       0.848000      17.0 -14.141041  {\ldots}  0.945202  0.991966   17.0
SDD\_d       1.111644      17.0  -5.000152  {\ldots}  0.858112  0.892193   17.0

                                                                        \textbackslash{}
                mean       std       min       25\%       50\%       75\%
Parameters
FEC\_max     0.260878  0.294861  0.019661  0.040866  0.181690  0.303056
GERM\_p      0.402671  0.400843  0.008754  0.156318  0.181690  1.000000
LDD\_d       0.099438  0.238192  0.000306  0.005536  0.013064  0.074067
SDD\_d       0.143831  0.216615  0.015539  0.023730  0.068449  0.122752


                 max
Parameters
FEC\_max     1.000000
GERM\_p      1.000000
LDD\_d       1.000000
SDD\_d       0.789803

[4 rows x 32 columns]
\end{Verbatim}
\end{tcolorbox}
        
    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{10}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{c+c1}{\PYZsh{} Plot relationships migration rate vs. parameter values at the species level}
\PY{n}{f}\PY{p}{,} \PY{n}{axes} \PY{o}{=} \PY{n}{plt}\PY{o}{.}\PY{n}{subplots}\PY{p}{(}\PY{l+m+mi}{2}\PY{p}{,} \PY{l+m+mi}{2}\PY{p}{,} \PY{n}{sharex}\PY{o}{=}\PY{k+kc}{True}\PY{p}{,} \PY{n}{sharey}\PY{o}{=}\PY{k+kc}{True}\PY{p}{)}
\PY{p}{(}\PY{n}{ax1}\PY{p}{,} \PY{n}{ax2}\PY{p}{)}\PY{p}{,} \PY{p}{(}\PY{n}{ax3}\PY{p}{,} \PY{n}{ax4}\PY{p}{)} \PY{o}{=} \PY{n}{axes}
\PY{n}{f}\PY{o}{.}\PY{n}{set\PYZus{}figheight}\PY{p}{(}\PY{l+m+mf}{7.25}\PY{o}{*}\PY{l+m+mf}{1.5}\PY{o}{/}\PY{l+m+mf}{1.6}\PY{p}{)}
\PY{n}{f}\PY{o}{.}\PY{n}{set\PYZus{}figwidth}\PY{p}{(}\PY{l+m+mf}{7.25}\PY{o}{*}\PY{l+m+mf}{1.5}\PY{p}{)}
\PY{n}{f}\PY{o}{.}\PY{n}{dpi} \PY{o}{=} \PY{l+m+mi}{300}

\PY{n}{headers} \PY{o}{=} \PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{SDD\PYZus{}d}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{LDD\PYZus{}d}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{FEC\PYZus{}max}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{GERM\PYZus{}p}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}

\PY{k}{for} \PY{n}{header}\PY{p}{,}\PY{n}{ax} \PY{o+ow}{in} \PY{n+nb}{zip}\PY{p}{(}\PY{n}{headers}\PY{p}{,}\PY{n}{axes}\PY{o}{.}\PY{n}{flatten}\PY{p}{(}\PY{p}{)}\PY{p}{)}\PY{p}{:}
    \PY{n}{lm\PYZus{}sub} \PY{o}{=} \PY{n}{lm\PYZus{}stats\PYZus{}df}\PY{p}{[}\PY{n}{lm\PYZus{}stats\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameters}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{==}\PY{n}{header}\PY{p}{]} 
    
    \PY{n}{labels} \PY{o}{=} \PY{n}{lm\PYZus{}sub}\PY{o}{.}\PY{n}{Species}\PY{o}{.}\PY{n}{unique}\PY{p}{(}\PY{p}{)}
    \PY{n}{x} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{arange}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{labels}\PY{p}{)}\PY{p}{)} 
    \PY{n}{width} \PY{o}{=} \PY{l+m+mf}{0.375}
    
    \PY{n}{rects1} \PY{o}{=} \PY{n}{ax}\PY{o}{.}\PY{n}{bar}\PY{p}{(}\PY{n}{x} \PY{o}{\PYZhy{}} \PY{n}{width}\PY{o}{/}\PY{l+m+mi}{2}\PY{p}{,} \PY{n}{lm\PYZus{}sub}\PY{o}{.}\PY{n}{slope}\PY{p}{,} \PY{n}{width}\PY{p}{,} \PY{n}{label}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{slope}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
    \PY{n}{rects2} \PY{o}{=} \PY{n}{ax}\PY{o}{.}\PY{n}{bar}\PY{p}{(}\PY{n}{x} \PY{o}{+} \PY{n}{width}\PY{o}{/}\PY{l+m+mi}{2}\PY{p}{,} \PY{n}{lm\PYZus{}sub}\PY{o}{.}\PY{n}{r2}\PY{p}{,} \PY{n}{width}\PY{p}{,} \PY{n}{label}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{r\PYZdl{}\PYZca{}2\PYZdl{}}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
    
    \PY{c+c1}{\PYZsh{} Add asterisks for significance}
    \PY{n}{sig\PYZus{}label} \PY{o}{=} \PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{*}\PY{l+s+s1}{\PYZsq{}} \PY{k}{if} \PY{p}{(}\PY{n}{e} \PY{o}{\PYZlt{}} \PY{l+m+mf}{0.05}\PY{p}{)} \PY{k}{else} \PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{**}\PY{l+s+s1}{\PYZsq{}} \PY{k}{if} \PY{p}{(}\PY{n}{e} \PY{o}{\PYZlt{}} \PY{l+m+mf}{0.01}\PY{p}{)} \PY{k}{else} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)} \PY{k}{for} \PY{n}{e} \PY{o+ow}{in} \PY{n}{lm\PYZus{}sub}\PY{o}{.}\PY{n}{pvalue}\PY{p}{]}
    \PY{n}{ax}\PY{o}{.}\PY{n}{bar\PYZus{}label}\PY{p}{(}\PY{n}{rects1}\PY{p}{,} \PY{n}{labels}\PY{o}{=}\PY{n}{sig\PYZus{}label}\PY{p}{,} \PY{n}{padding}\PY{o}{=}\PY{l+m+mi}{3}\PY{p}{)}
    \PY{n}{ax}\PY{o}{.}\PY{n}{axhline}\PY{p}{(}\PY{n}{y}\PY{o}{=}\PY{l+m+mi}{1}\PY{p}{,} \PY{n}{color}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{r}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{linestyle}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{\PYZhy{}\PYZhy{}}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
    
    \PY{c+c1}{\PYZsh{} Add headers}
    \PY{k}{if} \PY{n}{header} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{SDD\PYZus{}d}\PY{l+s+s1}{\PYZsq{}} \PY{p}{:}
        \PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}title}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{SDD\PYZdl{}\PYZus{}d\PYZdl{}}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)} 
        \PY{n}{ax}\PY{o}{.}\PY{n}{legend}\PY{p}{(}\PY{n}{frameon}\PY{o}{=}\PY{k+kc}{False}\PY{p}{)}
    \PY{k}{if} \PY{n}{header} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{LDD\PYZus{}d}\PY{l+s+s1}{\PYZsq{}} \PY{p}{:}
        \PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}title}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{LDD\PYZdl{}\PYZus{}d\PYZdl{}}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)} 
    \PY{k}{if} \PY{n}{header} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{FEC\PYZus{}max}\PY{l+s+s1}{\PYZsq{}} \PY{p}{:}
        \PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}title}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{FEC\PYZdl{}\PYZus{}}\PY{l+s+si}{\PYZob{}max\PYZcb{}}\PY{l+s+s1}{\PYZdl{}}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
        \PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}xticks}\PY{p}{(}\PY{n}{x}\PY{p}{)}
        \PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}xticklabels}\PY{p}{(}\PY{n}{labels}\PY{p}{)}
        \PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}xticklabels}\PY{p}{(}\PY{n}{labels}\PY{p}{,} \PY{n}{rotation}\PY{o}{=}\PY{l+m+mi}{90}\PY{p}{)}
    \PY{k}{if} \PY{n}{header} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{GERM\PYZus{}p}\PY{l+s+s1}{\PYZsq{}} \PY{p}{:}
        \PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}title}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{GERM\PYZdl{}\PYZus{}p\PYZdl{}}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)} 
        \PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}xticks}\PY{p}{(}\PY{n}{x}\PY{p}{)}
        \PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}xticklabels}\PY{p}{(}\PY{n}{labels}\PY{p}{)}
        \PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}xticklabels}\PY{p}{(}\PY{n}{labels}\PY{p}{,} \PY{n}{rotation}\PY{o}{=}\PY{l+m+mi}{90}\PY{p}{)}
\PY{n}{f}\PY{o}{.}\PY{n}{subplots\PYZus{}adjust}\PY{p}{(}\PY{n}{wspace}\PY{o}{=}\PY{l+m+mf}{0.1}\PY{p}{)}

\PY{n}{plt}\PY{o}{.}\PY{n}{savefig}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Figure\PYZus{}S2.png}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{bbox\PYZus{}inches}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{tight}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{dpi}\PY{o}{=}\PY{l+m+mi}{300}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}

    \begin{center}
    \adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{output_20_0.png}
    \end{center}
    { \hspace*{\fill} \\}
    
    \hypertarget{species-specific-relationship-of-migration-rate-vs.-parameter-values}{%
\subsubsection{Species-specific relationship of migration rate
vs.~parameter
values}\label{species-specific-relationship-of-migration-rate-vs.-parameter-values}}

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{11}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{k}{def} \PY{n+nf}{scatter\PYZus{}plot\PYZus{}par}\PY{p}{(}\PY{n}{par\PYZus{}df}\PY{p}{,} \PY{n}{sub\PYZus{}plot}\PY{p}{)}\PY{p}{:}
    \PY{n}{species} \PY{o}{=} \PY{n}{par\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}
    \PY{k}{for} \PY{n}{sp} \PY{o+ow}{in} \PY{n}{species} \PY{p}{:}
        \PY{c+c1}{\PYZsh{} Normalize parameter values}
        \PY{n}{sp\PYZus{}sub} \PY{o}{=} \PY{n}{par\PYZus{}sub}\PY{p}{[}\PY{n}{par\PYZus{}sub}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{==}\PY{n}{sp}\PY{p}{]} 
        \PY{n}{norm\PYZus{}value} \PY{o}{=} \PY{n}{preprocessing}\PY{o}{.}\PY{n}{normalize}\PY{p}{(}\PY{p}{[}\PY{n}{sp\PYZus{}sub}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{value}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{]}\PY{p}{)}
        \PY{n}{x}\PY{p}{,} \PY{n}{y} \PY{o}{=} \PY{n}{norm\PYZus{}value}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{,} \PY{n}{sp\PYZus{}sub}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{MigRates}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}
        \PY{n}{sub\PYZus{}plot}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{x}\PY{p}{,} \PY{n}{y}\PY{p}{,} \PY{n}{marker}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{o}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{linestyle}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{markeredgecolor}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{white}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
        \PY{n}{slope}\PY{p}{,} \PY{n}{intercept} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{polyfit}\PY{p}{(}\PY{n}{x}\PY{p}{,} \PY{n}{y}\PY{p}{,} \PY{l+m+mi}{1}\PY{p}{)}
        \PY{n}{sub\PYZus{}plot}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{x}\PY{p}{,} \PY{n}{slope}\PY{o}{*}\PY{n}{x}\PY{o}{+}\PY{n}{intercept}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{\PYZhy{}\PYZhy{}}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{color}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{grey}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{linewidth}\PY{o}{=}\PY{l+m+mi}{1}\PY{p}{)} 
        
        \PY{c+c1}{\PYZsh{} Add headers}
        \PY{k}{if} \PY{n}{header} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{SDD\PYZus{}d}\PY{l+s+s1}{\PYZsq{}} \PY{p}{:}
            \PY{n}{sub\PYZus{}plot}\PY{o}{.}\PY{n}{set\PYZus{}title}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{SDD\PYZdl{}\PYZus{}d\PYZdl{}}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)} 
            \PY{n}{sub\PYZus{}plot}\PY{o}{.}\PY{n}{set\PYZus{}ylabel}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Migration rate [m \PYZdl{}yr\PYZca{}}\PY{l+s+s1}{\PYZob{}}\PY{l+s+s1}{\PYZhy{}1\PYZcb{}\PYZdl{}]}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
        \PY{k}{if} \PY{n}{header} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{LDD\PYZus{}d}\PY{l+s+s1}{\PYZsq{}} \PY{p}{:}
            \PY{n}{sub\PYZus{}plot}\PY{o}{.}\PY{n}{set\PYZus{}title}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{LDD\PYZdl{}\PYZus{}d\PYZdl{}}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)} 
        \PY{k}{if} \PY{n}{header} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{FEC\PYZus{}max}\PY{l+s+s1}{\PYZsq{}} \PY{p}{:}
            \PY{n}{sub\PYZus{}plot}\PY{o}{.}\PY{n}{set\PYZus{}title}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{FEC\PYZdl{}\PYZus{}}\PY{l+s+si}{\PYZob{}max\PYZcb{}}\PY{l+s+s1}{\PYZdl{}}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)} 
            \PY{n}{sub\PYZus{}plot}\PY{o}{.}\PY{n}{set\PYZus{}xlabel}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Normalized parameter value}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
            \PY{n}{sub\PYZus{}plot}\PY{o}{.}\PY{n}{set\PYZus{}ylabel}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Migration rate [m \PYZdl{}yr\PYZca{}}\PY{l+s+s1}{\PYZob{}}\PY{l+s+s1}{\PYZhy{}1\PYZcb{}\PYZdl{}}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
        \PY{k}{if} \PY{n}{header} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{GERM\PYZus{}p}\PY{l+s+s1}{\PYZsq{}} \PY{p}{:}
            \PY{n}{sub\PYZus{}plot}\PY{o}{.}\PY{n}{set\PYZus{}title}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{GERM\PYZdl{}\PYZus{}p\PYZdl{}}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)} 
            \PY{n}{sub\PYZus{}plot}\PY{o}{.}\PY{n}{set\PYZus{}xlabel}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Normalized parameter value}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}

\PY{n}{f}\PY{p}{,} \PY{n}{ax} \PY{o}{=} \PY{n}{plt}\PY{o}{.}\PY{n}{subplots}\PY{p}{(}\PY{p}{)}
\PY{n}{f}\PY{o}{.}\PY{n}{set\PYZus{}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)}\PY{p}{)}
\PY{n}{plot4} \PY{o}{=} \PY{n}{plt}\PY{o}{.}\PY{n}{subplot2grid}\PY{p}{(}\PY{p}{(}\PY{l+m+mi}{2}\PY{p}{,} \PY{l+m+mi}{2}\PY{p}{)}\PY{p}{,} \PY{p}{(}\PY{l+m+mi}{1}\PY{p}{,} \PY{l+m+mi}{1}\PY{p}{)}\PY{p}{)}

\PY{n}{headers} \PY{o}{=} \PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{SDD\PYZus{}d}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{LDD\PYZus{}d}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{FEC\PYZus{}max}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{GERM\PYZus{}p}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}

\PY{c+c1}{\PYZsh{} SDD}
\PY{n}{par\PYZus{}sub} \PY{o}{=} \PY{n}{long\PYZus{}df}\PY{p}{[}\PY{n}{long\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameters}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{==}\PY{n}{headers}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{]} 
\PY{n}{header} \PY{o}{=} \PY{n}{headers}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}
\PY{n}{scatter\PYZus{}plot\PYZus{}par}\PY{p}{(}\PY{n}{par\PYZus{}sub}\PY{p}{,} \PY{n}{plot1}\PY{p}{)}

\PY{c+c1}{\PYZsh{} LDD}
\PY{n}{par\PYZus{}sub} \PY{o}{=} \PY{n}{long\PYZus{}df}\PY{p}{[}\PY{n}{long\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameters}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{==}\PY{n}{headers}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{]} 
\PY{n}{header} \PY{o}{=} \PY{n}{headers}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}
\PY{n}{scatter\PYZus{}plot\PYZus{}par}\PY{p}{(}\PY{n}{par\PYZus{}sub}\PY{p}{,} \PY{n}{plot2}\PY{p}{)}

\PY{c+c1}{\PYZsh{} FEC\PYZus{}max}
\PY{n}{par\PYZus{}sub} \PY{o}{=} \PY{n}{long\PYZus{}df}\PY{p}{[}\PY{n}{long\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameters}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{==}\PY{n}{headers}\PY{p}{[}\PY{l+m+mi}{2}\PY{p}{]}\PY{p}{]} 
\PY{n}{header} \PY{o}{=} \PY{n}{headers}\PY{p}{[}\PY{l+m+mi}{2}\PY{p}{]}
\PY{n}{scatter\PYZus{}plot\PYZus{}par}\PY{p}{(}\PY{n}{par\PYZus{}sub}\PY{p}{,} \PY{n}{plot3}\PY{p}{)}

\PY{c+c1}{\PYZsh{} GERM\PYZus{}p}
\PY{n}{par\PYZus{}sub} \PY{o}{=} \PY{n}{long\PYZus{}df}\PY{p}{[}\PY{n}{long\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameters}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{==}\PY{n}{headers}\PY{p}{[}\PY{l+m+mi}{3}\PY{p}{]}\PY{p}{]} 
\PY{n}{header} \PY{o}{=} \PY{n}{headers}\PY{p}{[}\PY{l+m+mi}{3}\PY{p}{]}
\PY{n}{scatter\PYZus{}plot\PYZus{}par}\PY{p}{(}\PY{n}{par\PYZus{}sub}\PY{p}{,} \PY{n}{plot4}\PY{p}{)}

\PY{n}{f}\PY{o}{.}\PY{n}{subplots\PYZus{}adjust}\PY{p}{(}\PY{n}{wspace}\PY{o}{=}\PY{l+m+mf}{0.1}\PY{p}{)}

\PY{n}{plt}\PY{o}{.}\PY{n}{savefig}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Figure\PYZus{}S3.png}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{bbox\PYZus{}inches}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{tight}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{dpi}\PY{o}{=}\PY{l+m+mi}{300}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}

    \begin{center}
    \adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{output_22_0.png}
    \end{center}
    { \hspace*{\fill} \\}
    
    \hypertarget{extreme-value-analysis-eva}{%
\subsection{Extreme Value Analysis
(EVA)}\label{extreme-value-analysis-eva}}

We fixed all influential parameters at their minimum (\(all\_MIN\)) and
maximum (\(all\_MAX\)) values and calculated the corresponding errors
with respect to observational data for each species. Species-specific
performance was calculated with residuals (\(res\)) across the whole
confidence range of observational values:

\[res=\frac{100}{\overline{obs}}\times(sim-obs)\]

where \(obs\) indicates all integer values from the lower to the upper
boundary of migration rates estimates, and \(\overline{obs}\) their
average per species (Table 1).

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{12}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{c+c1}{\PYZsh{} Function to calculate overall RMSE and species\PYZhy{}specific residuals of observations vs. simulated migration values}
\PY{k}{def} \PY{n+nf}{f\PYZus{}rmse\PYZus{}residuals}\PY{p}{(}\PY{n}{df\PYZus{}input}\PY{p}{)} \PY{p}{:}
    
    \PY{c+c1}{\PYZsh{} Calculate species\PYZhy{}specific residuals}
    \PY{n}{Species} \PY{o}{=} \PY{n}{df\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{.}\PY{n}{unique}\PY{p}{(}\PY{p}{)}
    \PY{n}{Parameter\PYZus{}combo} \PY{o}{=} \PY{n}{df\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{.}\PY{n}{unique}\PY{p}{(}\PY{p}{)}
    \PY{k}{if} \PY{p}{(}\PY{n}{Parameter\PYZus{}combo}\PY{p}{[}\PY{l+m+mi}{2}\PY{p}{]} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{all\PYZus{}MAX\PYZus{}opt}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}\PY{p}{:}
        \PY{n}{Parameter\PYZus{}combo} \PY{o}{=} \PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{all\PYZus{}MAX}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{all\PYZus{}MIN}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}
    \PY{n}{residuals\PYZus{}df} \PY{o}{=} \PY{n}{pd}\PY{o}{.}\PY{n}{DataFrame}\PY{p}{(}\PY{p}{)}

    \PY{k}{for} \PY{n}{sp} \PY{o+ow}{in} \PY{n}{Species} \PY{p}{:}
        \PY{n}{df\PYZus{}sp} \PY{o}{=} \PY{n}{df\PYZus{}input}\PY{p}{[}\PY{n}{df\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{==}\PY{n}{sp}\PY{p}{]}
        \PY{n}{column\PYZus{}names} \PY{o}{=} \PY{n}{df\PYZus{}sp}\PY{o}{.}\PY{n}{columns}\PY{o}{.}\PY{n}{values}\PY{o}{.}\PY{n}{tolist}\PY{p}{(}\PY{p}{)}
        \PY{n}{all\PYZus{}obs} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{arange}\PY{p}{(}\PY{n}{df\PYZus{}sp}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{OBS\PYZus{}MIN}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{.}\PY{n}{unique}\PY{p}{(}\PY{p}{)}\PY{p}{,}\PY{n}{df\PYZus{}sp}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{OBS\PYZus{}MAX}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{.}\PY{n}{unique}\PY{p}{(}\PY{p}{)}\PY{p}{,}\PY{l+m+mi}{1}\PY{p}{)}
        \PY{n}{mean\PYZus{}obs} \PY{o}{=} \PY{n}{all\PYZus{}obs}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{p}{)}
        \PY{k}{for} \PY{n}{par} \PY{o+ow}{in} \PY{n}{Parameter\PYZus{}combo} \PY{p}{:}
            \PY{n}{par\PYZus{}df} \PY{o}{=} \PY{n}{df\PYZus{}sp}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{n}{df\PYZus{}sp}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{==}\PY{n}{par}\PY{p}{]}
            \PY{n}{sim} \PY{o}{=} \PY{n}{par\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{SIM}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}
            \PY{n}{check\PYZus{}na} \PY{o}{=} \PY{n}{pd}\PY{o}{.}\PY{n}{isna}\PY{p}{(}\PY{n}{sim}\PY{p}{)}
            \PY{k}{if} \PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{sim}\PY{p}{)} \PY{o}{!=} \PY{l+m+mi}{1}\PY{p}{)}\PY{p}{:}
                \PY{n}{sim} \PY{o}{=} \PY{n}{sim}\PY{o}{.}\PY{n}{reset\PYZus{}index}\PY{p}{(}\PY{p}{)}
                \PY{n}{sim} \PY{o}{=} \PY{n}{sim}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{SIM}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}
            \PY{k}{if} \PY{p}{(}\PY{n}{check\PYZus{}na}\PY{o}{.}\PY{n}{any}\PY{p}{(}\PY{p}{)}\PY{p}{)} \PY{p}{:}
                \PY{n}{sim} \PY{o}{=} \PY{n}{sim}
            \PY{k}{else} \PY{p}{:}
                \PY{n}{sim} \PY{o}{=} \PY{n+nb}{int}\PY{p}{(}\PY{n}{sim}\PY{p}{)}
            \PY{n}{df} \PY{o}{=} \PY{n}{pd}\PY{o}{.}\PY{n}{DataFrame}\PY{p}{(}\PY{n}{index}\PY{o}{=}\PY{n}{np}\PY{o}{.}\PY{n}{arange}\PY{p}{(}\PY{l+m+mi}{0}\PY{p}{,}\PY{n+nb}{len}\PY{p}{(}\PY{n}{all\PYZus{}obs}\PY{p}{)}\PY{p}{,}\PY{l+m+mi}{1}\PY{p}{)}\PY{p}{)}
            \PY{k}{if} \PY{p}{(}\PY{n}{column\PYZus{}names}\PY{p}{[}\PY{l+m+mi}{2}\PY{p}{]} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{shape\PYZus{}par}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)} \PY{p}{:}
                \PY{n}{df}\PY{o}{.}\PY{n}{insert}\PY{p}{(}\PY{l+m+mi}{0}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{n}{sp}\PY{p}{)}
                \PY{n}{df}\PY{o}{.}\PY{n}{insert}\PY{p}{(}\PY{l+m+mi}{1}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{n}{par}\PY{p}{)}             
                \PY{n}{df}\PY{o}{.}\PY{n}{insert}\PY{p}{(}\PY{l+m+mi}{2}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{shape\PYZus{}par}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{n+nb}{float}\PY{p}{(}\PY{n}{par\PYZus{}df}\PY{o}{.}\PY{n}{shape\PYZus{}par}\PY{o}{.}\PY{n}{unique}\PY{p}{(}\PY{p}{)}\PY{p}{)}\PY{p}{)}
                \PY{n}{df}\PY{o}{.}\PY{n}{insert}\PY{p}{(}\PY{l+m+mi}{3}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{sim}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{n}{sim}\PY{p}{)}
                \PY{n}{df}\PY{o}{.}\PY{n}{insert}\PY{p}{(}\PY{l+m+mi}{4}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{obs}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{n}{all\PYZus{}obs}\PY{p}{)}
            \PY{k}{else} \PY{p}{:}
                \PY{n}{df}\PY{o}{.}\PY{n}{insert}\PY{p}{(}\PY{l+m+mi}{0}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{n}{sp}\PY{p}{)}
                \PY{n}{df}\PY{o}{.}\PY{n}{insert}\PY{p}{(}\PY{l+m+mi}{1}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{n}{par}\PY{p}{)}
                \PY{n}{df}\PY{o}{.}\PY{n}{insert}\PY{p}{(}\PY{l+m+mi}{2}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{sim}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{n}{sim}\PY{p}{)}
                \PY{n}{df}\PY{o}{.}\PY{n}{insert}\PY{p}{(}\PY{l+m+mi}{3}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{obs}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{n}{all\PYZus{}obs}\PY{p}{)}
            \PY{n}{df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{residuals}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{l+m+mi}{100}\PY{o}{/}\PY{n}{mean\PYZus{}obs} \PY{o}{*} \PY{p}{(}\PY{n}{df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{sim}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{\PYZhy{}}\PY{n}{df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{obs}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{)}
            \PY{n}{residuals\PYZus{}df} \PY{o}{=} \PY{n}{pd}\PY{o}{.}\PY{n}{concat}\PY{p}{(}\PY{p}{[}\PY{n}{residuals\PYZus{}df}\PY{p}{,}\PY{n}{df}\PY{p}{]}\PY{p}{)}
            
    \PY{c+c1}{\PYZsh{} Calculate average and standard deviation of residuals}
    \PY{k}{if} \PY{p}{(}\PY{n}{column\PYZus{}names}\PY{p}{[}\PY{l+m+mi}{2}\PY{p}{]} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{shape\PYZus{}par}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)} \PY{p}{:}
        \PY{n}{df\PYZus{}output} \PY{o}{=} \PY{n}{residuals\PYZus{}df}\PY{p}{[}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{shape\PYZus{}par}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{residuals}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{]}\PY{o}{.}\PY{n}{groupby}\PY{p}{(}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{shape\PYZus{}par}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{)}\PY{o}{.}\PY{n}{agg}\PY{p}{(}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{mean}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{std}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{)}\PY{o}{.}\PY{n}{reset\PYZus{}index}\PY{p}{(}\PY{p}{)}
        \PY{n}{df\PYZus{}output}\PY{o}{.}\PY{n}{columns} \PY{o}{=} \PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{shape\PYZus{}par}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{residuals\PYZus{}mean}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{residuals\PYZus{}std}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}
    \PY{k}{else} \PY{p}{:}
        \PY{n}{df\PYZus{}output} \PY{o}{=} \PY{n}{residuals\PYZus{}df}\PY{p}{[}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{residuals}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{]}\PY{o}{.}\PY{n}{groupby}\PY{p}{(}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{)}\PY{o}{.}\PY{n}{agg}\PY{p}{(}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{mean}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{std}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{)}\PY{o}{.}\PY{n}{reset\PYZus{}index}\PY{p}{(}\PY{p}{)}
        \PY{n}{df\PYZus{}output}\PY{o}{.}\PY{n}{columns} \PY{o}{=} \PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{residuals\PYZus{}mean}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{residuals\PYZus{}std}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}

    \PY{k}{return} \PY{p}{[}\PY{n}{df\PYZus{}output}\PY{p}{,} \PY{n}{residuals\PYZus{}df}\PY{p}{]}

\PY{c+c1}{\PYZsh{} Function to make a violinplot of species\PYZhy{}specific residuals}
\PY{c+c1}{\PYZsh{} input dataframe should be formatted with f\PYZus{}rmse\PYZus{}residuals()}
\PY{k}{def} \PY{n+nf}{make\PYZus{}plot}\PY{p}{(}\PY{n}{residuals\PYZus{}df}\PY{p}{)} \PY{p}{:}     
    \PY{n}{fig} \PY{o}{=} \PY{n}{plt}\PY{o}{.}\PY{n}{figure}\PY{p}{(}\PY{n}{figsize}\PY{o}{=}\PY{p}{(}\PY{l+m+mf}{7.5}\PY{p}{,}\PY{l+m+mf}{4.5}\PY{p}{)}\PY{p}{)}
    \PY{n}{fig}\PY{o}{.}\PY{n}{dpi} \PY{o}{=} \PY{l+m+mi}{300}
    \PY{n}{fig} \PY{o}{=} \PY{n}{plt}\PY{o}{.}\PY{n}{axes}\PY{p}{(}\PY{p}{)}
    \PY{n}{plt}\PY{o}{.}\PY{n}{xticks}\PY{p}{(}\PY{n}{rotation}\PY{o}{=}\PY{l+m+mi}{45}\PY{p}{)}
    \PY{k}{if} \PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{residuals\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{.}\PY{n}{unique}\PY{p}{(}\PY{p}{)}\PY{p}{)}\PY{o}{==}\PY{l+m+mi}{2}\PY{p}{)} \PY{p}{:}
        \PY{n}{fig} \PY{o}{=} \PY{n}{sns}\PY{o}{.}\PY{n}{violinplot}\PY{p}{(}\PY{n}{x}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{y}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{residuals}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{hue}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{data}\PY{o}{=}\PY{n}{residuals\PYZus{}df}\PY{p}{,}  
                             \PY{n}{bw}\PY{o}{=}\PY{l+m+mf}{1.}\PY{p}{,} \PY{n}{width}\PY{o}{=}\PY{l+m+mf}{0.5}\PY{p}{,} \PY{n}{linewidth}\PY{o}{=}\PY{l+m+mf}{0.5}\PY{p}{,} \PY{n}{split}\PY{o}{=}\PY{k+kc}{True}\PY{p}{,} \PY{n}{dropna}\PY{o}{=}\PY{k+kc}{True}\PY{p}{)}
    \PY{k}{else} \PY{p}{:}
        \PY{n}{standard\PYZus{}pal} \PY{o}{=} \PY{n}{sns}\PY{o}{.}\PY{n}{color\PYZus{}palette}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{tab10}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,}\PY{l+m+mi}{5}\PY{p}{)}
        \PY{n}{standard\PYZus{}pal}\PY{p}{[}\PY{l+m+mi}{4}\PY{p}{]} \PY{o}{=} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{\PYZsh{}95a5a6}\PY{l+s+s2}{\PYZdq{}}
        \PY{n}{fig} \PY{o}{=} \PY{n}{sns}\PY{o}{.}\PY{n}{violinplot}\PY{p}{(}\PY{n}{x}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{y}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{residuals}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{hue}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{bw}\PY{o}{=}\PY{l+m+mf}{1.}\PY{p}{,} \PY{n}{palette}\PY{o}{=}\PY{n}{standard\PYZus{}pal}\PY{p}{,}
                             \PY{n}{data}\PY{o}{=}\PY{n}{residuals\PYZus{}df}\PY{p}{,}  \PY{n}{width}\PY{o}{=}\PY{l+m+mf}{0.65}\PY{p}{,} \PY{n}{linewidth}\PY{o}{=}\PY{l+m+mf}{0.}\PY{p}{,} \PY{n}{dropna}\PY{o}{=}\PY{k+kc}{True}\PY{p}{)}
    \PY{n}{fig}\PY{o}{.}\PY{n}{legend}\PY{p}{(}\PY{n}{frameon}\PY{o}{=}\PY{k+kc}{False}\PY{p}{)}
    \PY{n}{fig}\PY{o}{.}\PY{n}{legend\PYZus{}}\PY{o}{.}\PY{n}{set\PYZus{}title}\PY{p}{(}\PY{k+kc}{None}\PY{p}{)}
    \PY{n}{fig}\PY{o}{.}\PY{n}{set\PYZus{}xlabel}\PY{p}{(}\PY{k+kc}{None}\PY{p}{)}
    \PY{n}{fig}\PY{o}{.}\PY{n}{set\PYZus{}ylabel}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Residuals [}\PY{l+s+s1}{\PYZpc{}}\PY{l+s+s1}{]}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
    \PY{n}{fig}\PY{o}{.}\PY{n}{axhline}\PY{p}{(}\PY{l+m+mi}{0}\PY{p}{,} \PY{n}{color}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{black}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{ls}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{\PYZhy{}\PYZhy{}}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{linewidth}\PY{o}{=}\PY{l+m+mf}{0.9}\PY{p}{)}
    \PY{n}{fig\PYZus{}out} \PY{o}{=} \PY{n}{fig}\PY{o}{.}\PY{n}{get\PYZus{}figure}\PY{p}{(}\PY{p}{)}
    \PY{n}{plt}\PY{o}{.}\PY{n}{tight\PYZus{}layout}\PY{p}{(}\PY{p}{)}
    \PY{k}{return} \PY{n}{fig\PYZus{}out}

\PY{c+c1}{\PYZsh{} Make dataframe with RMSE and species\PYZhy{}specific residuals (mean and standard deviation)}
\PY{n}{df\PYZus{}output} \PY{o}{=} \PY{n}{f\PYZus{}rmse\PYZus{}residuals}\PY{p}{(}\PY{n}{EVA\PYZus{}input}\PY{p}{)}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}    
\PY{n}{residuals\PYZus{}df} \PY{o}{=} \PY{n}{f\PYZus{}rmse\PYZus{}residuals}\PY{p}{(}\PY{n}{EVA\PYZus{}input}\PY{p}{)}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}

\PY{c+c1}{\PYZsh{} Export to CSV}
\PY{n}{df\PYZus{}output}\PY{o}{.}\PY{n}{to\PYZus{}csv}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Table\PYZus{}S2.csv}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{sep}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{;}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{index}\PY{o}{=}\PY{k+kc}{False}\PY{p}{)}
             
\PY{c+c1}{\PYZsh{} Make figure}
\PY{n}{fig\PYZus{}out} \PY{o}{=} \PY{n}{make\PYZus{}plot}\PY{p}{(}\PY{n}{residuals\PYZus{}df}\PY{p}{)}

\PY{c+c1}{\PYZsh{} Export figure    }
\PY{n}{fig\PYZus{}out}\PY{o}{.}\PY{n}{savefig}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Figure\PYZus{}2.png}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{dpi}\PY{o}{=}\PY{l+m+mi}{300}\PY{p}{,} \PY{n+nb}{format}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{png}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}

    \begin{center}
    \adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{output_24_0.png}
    \end{center}
    { \hspace*{\fill} \\}
    
    \hypertarget{overall-error-of-all_min-and-all_max}{%
\subsubsection{Overall error of all\_MIN and
all\_MAX}\label{overall-error-of-all_min-and-all_max}}

Error across species was calculated as root-mean-square-error (RMSE) was
used to quantify the model performance across species:

\[RMSE=\frac{100}{\overline{obs}}\times \sqrt{\frac{\sum_{i=1}^{n}(sim_i-obs_i)^2}{n}}\]

where \(n\) is the number of species, \(obs\) is the \(75^{th}\)
percentile value in the confidence range of observational values, and
\(\overline{obs}\) is the average across species.

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{13}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{allMIN\PYZus{}df} \PY{o}{=} \PY{n}{EVA\PYZus{}input}\PY{p}{[}\PY{n}{EVA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{==}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{all\PYZus{}MIN}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}
\PY{n}{allMIN\PYZus{}RMSE\PYZus{}perc} \PY{o}{=} \PY{n}{rmse\PYZus{}perc}\PY{p}{(}\PY{n}{allMIN\PYZus{}df}\PY{o}{.}\PY{n}{SIM}\PY{p}{,}\PY{n}{allMIN\PYZus{}df}\PY{o}{.}\PY{n}{OBS\PYZus{}75ile}\PY{p}{,}\PY{n}{allMIN\PYZus{}df}\PY{o}{.}\PY{n}{OBS\PYZus{}50ile}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{p}{)}\PY{p}{)}

\PY{n}{allMAX\PYZus{}df} \PY{o}{=} \PY{n}{EVA\PYZus{}input}\PY{p}{[}\PY{n}{EVA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{==}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{all\PYZus{}MAX}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}
\PY{n}{allMAX\PYZus{}RMSE\PYZus{}perc} \PY{o}{=} \PY{n}{rmse\PYZus{}perc}\PY{p}{(}\PY{n}{allMAX\PYZus{}df}\PY{o}{.}\PY{n}{SIM}\PY{p}{,}\PY{n}{allMAX\PYZus{}df}\PY{o}{.}\PY{n}{OBS\PYZus{}75ile}\PY{p}{,}\PY{n}{allMAX\PYZus{}df}\PY{o}{.}\PY{n}{OBS\PYZus{}50ile}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{p}{)}\PY{p}{)}

\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{Root Mean Square Error for all\PYZus{}MIN: }\PY{l+s+s2}{\PYZdq{}}\PY{o}{+}\PY{n+nb}{str}\PY{p}{(}\PY{n+nb}{round}\PY{p}{(}\PY{n}{allMIN\PYZus{}RMSE\PYZus{}perc}\PY{p}{,}\PY{l+m+mi}{2}\PY{p}{)}\PY{p}{)}\PY{p}{)}
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{Root Mean Square Error for all\PYZus{}MAX: }\PY{l+s+s2}{\PYZdq{}}\PY{o}{+}\PY{n+nb}{str}\PY{p}{(}\PY{n+nb}{round}\PY{p}{(}\PY{n}{allMAX\PYZus{}RMSE\PYZus{}perc}\PY{p}{,}\PY{l+m+mi}{2}\PY{p}{)}\PY{p}{)}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}

    \begin{Verbatim}[commandchars=\\\{\}]
Root Mean Square Error for all\_MIN: 125.2
Root Mean Square Error for all\_MAX: 111.01
    \end{Verbatim}

    \hypertarget{species-specific-overundergood-estimations}{%
\subsubsection{Species-specific over/under/good
estimations}\label{species-specific-overundergood-estimations}}

Good estimations correspond to residuals within 10 m/yr from the average
of observed migration speed (\texttt{residuals\_mean}), over- and
under-estimations correspond to positive and negative residuals outside
of the 10 m/yr range, respectively.

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{14}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{good\PYZus{}est} \PY{o}{=} \PY{n}{df\PYZus{}output}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{p}{(}\PY{n}{df\PYZus{}output}\PY{o}{.}\PY{n}{residuals\PYZus{}mean} \PY{o}{\PYZlt{}} \PY{l+m+mf}{10.}\PY{p}{)} \PY{o}{\PYZam{}} \PY{p}{(}\PY{n}{df\PYZus{}output}\PY{o}{.}\PY{n}{residuals\PYZus{}mean} \PY{o}{\PYZgt{}} \PY{o}{\PYZhy{}}\PY{l+m+mf}{10.}\PY{p}{)}\PY{p}{]}
\PY{n}{bad\PYZus{}est} \PY{o}{=} \PY{n}{df\PYZus{}output}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{p}{(}\PY{n}{df\PYZus{}output}\PY{o}{.}\PY{n}{residuals\PYZus{}mean} \PY{o}{\PYZgt{}} \PY{l+m+mf}{10.}\PY{p}{)} \PY{o}{|} \PY{p}{(}\PY{n}{df\PYZus{}output}\PY{o}{.}\PY{n}{residuals\PYZus{}mean} \PY{o}{\PYZlt{}} \PY{o}{\PYZhy{}}\PY{l+m+mf}{10.}\PY{p}{)}\PY{p}{]}
\PY{n}{over\PYZus{}est} \PY{o}{=} \PY{n}{bad\PYZus{}est}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{n}{bad\PYZus{}est}\PY{o}{.}\PY{n}{residuals\PYZus{}mean} \PY{o}{\PYZgt{}} \PY{l+m+mf}{0.}\PY{p}{]}
\PY{n}{under\PYZus{}est} \PY{o}{=} \PY{n}{bad\PYZus{}est}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{n}{bad\PYZus{}est}\PY{o}{.}\PY{n}{residuals\PYZus{}mean} \PY{o}{\PYZlt{}} \PY{l+m+mf}{0.}\PY{p}{]}

\PY{n}{good\PYZus{}sp} \PY{o}{=} \PY{n}{good\PYZus{}est}\PY{o}{.}\PY{n}{Species}\PY{o}{.}\PY{n}{unique}\PY{p}{(}\PY{p}{)}
\PY{k}{for} \PY{n}{sp} \PY{o+ow}{in} \PY{n}{good\PYZus{}sp} \PY{p}{:}
    \PY{n}{sp\PYZus{}sub} \PY{o}{=} \PY{n}{good\PYZus{}est}\PY{p}{[}\PY{n}{good\PYZus{}est}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{n}{sp}\PY{p}{]}
    \PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Good estimates: }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n}{sp}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ for }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n+nb}{str}\PY{p}{(}\PY{n}{sp\PYZus{}sub}\PY{o}{.}\PY{n}{Parameter\PYZus{}combo}\PY{o}{.}\PY{n}{values}\PY{o}{.}\PY{n}{tolist}\PY{p}{(}\PY{p}{)}\PY{p}{)}\PY{p}{)}

\PY{n}{over\PYZus{}sp} \PY{o}{=} \PY{n}{over\PYZus{}est}\PY{o}{.}\PY{n}{Species}\PY{o}{.}\PY{n}{unique}\PY{p}{(}\PY{p}{)}
\PY{k}{for} \PY{n}{sp} \PY{o+ow}{in} \PY{n}{over\PYZus{}sp} \PY{p}{:}
    \PY{n}{sp\PYZus{}sub} \PY{o}{=} \PY{n}{over\PYZus{}est}\PY{p}{[}\PY{n}{over\PYZus{}est}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{n}{sp}\PY{p}{]}
    \PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Over\PYZhy{}estimations: }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n}{sp}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ for }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n+nb}{str}\PY{p}{(}\PY{n}{sp\PYZus{}sub}\PY{o}{.}\PY{n}{Parameter\PYZus{}combo}\PY{o}{.}\PY{n}{values}\PY{o}{.}\PY{n}{tolist}\PY{p}{(}\PY{p}{)}\PY{p}{)}\PY{p}{)}
    
\PY{n}{under\PYZus{}sp} \PY{o}{=} \PY{n}{under\PYZus{}est}\PY{o}{.}\PY{n}{Species}\PY{o}{.}\PY{n}{unique}\PY{p}{(}\PY{p}{)}
\PY{k}{for} \PY{n}{sp} \PY{o+ow}{in} \PY{n}{under\PYZus{}sp} \PY{p}{:}
    \PY{n}{sp\PYZus{}sub} \PY{o}{=} \PY{n}{under\PYZus{}est}\PY{p}{[}\PY{n}{under\PYZus{}est}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{n}{sp}\PY{p}{]}
    \PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Under\PYZhy{}estimations: }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n}{sp}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ for }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n+nb}{str}\PY{p}{(}\PY{n}{sp\PYZus{}sub}\PY{o}{.}\PY{n}{Parameter\PYZus{}combo}\PY{o}{.}\PY{n}{values}\PY{o}{.}\PY{n}{tolist}\PY{p}{(}\PY{p}{)}\PY{p}{)}\PY{p}{)}

\PY{c+c1}{\PYZsh{} Calculate overall underestimation error (RMSE\PYZpc{})}
\PY{n}{mean\PYZus{}MIN} \PY{o}{=} \PY{n}{under\PYZus{}est}\PY{p}{[}\PY{n}{under\PYZus{}est}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{all\PYZus{}MIN}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{.}\PY{n}{residuals\PYZus{}mean}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{p}{)}
\PY{n}{std\PYZus{}MIN} \PY{o}{=} \PY{n}{under\PYZus{}est}\PY{p}{[}\PY{n}{under\PYZus{}est}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{all\PYZus{}MIN}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{.}\PY{n}{residuals\PYZus{}mean}\PY{o}{.}\PY{n}{std}\PY{p}{(}\PY{p}{)}
\PY{n}{mean\PYZus{}MAX} \PY{o}{=} \PY{n}{under\PYZus{}est}\PY{p}{[}\PY{n}{under\PYZus{}est}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{all\PYZus{}MAX}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{.}\PY{n}{residuals\PYZus{}mean}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{p}{)}
\PY{n}{std\PYZus{}MAX} \PY{o}{=} \PY{n}{under\PYZus{}est}\PY{p}{[}\PY{n}{under\PYZus{}est}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{all\PYZus{}MAX}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{.}\PY{n}{residuals\PYZus{}mean}\PY{o}{.}\PY{n}{std}\PY{p}{(}\PY{p}{)}

\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+se}{\PYZbs{}n}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Overall under\PYZhy{}estimation errors: }\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{all\PYZus{}MIN | average error: }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n+nb}{str}\PY{p}{(}\PY{n+nb}{round}\PY{p}{(}\PY{n}{mean\PYZus{}MIN}\PY{p}{,}\PY{l+m+mi}{2}\PY{p}{)}\PY{p}{)}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ with S.D.: }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n+nb}{str}\PY{p}{(}\PY{n+nb}{round}\PY{p}{(}\PY{n}{std\PYZus{}MIN}\PY{p}{,}\PY{l+m+mi}{2}\PY{p}{)}\PY{p}{)}\PY{p}{)}
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{all\PYZus{}MAX | average error: }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n+nb}{str}\PY{p}{(}\PY{n+nb}{round}\PY{p}{(}\PY{n}{mean\PYZus{}MAX}\PY{p}{,}\PY{l+m+mi}{2}\PY{p}{)}\PY{p}{)}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ with S.D.: }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n+nb}{str}\PY{p}{(}\PY{n+nb}{round}\PY{p}{(}\PY{n}{std\PYZus{}MAX}\PY{p}{,}\PY{l+m+mi}{2}\PY{p}{)}\PY{p}{)}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}

    \begin{Verbatim}[commandchars=\\\{\}]
Over-estimations: Abi\_alb for ['all\_MAX']
Over-estimations: Pic\_abi for ['all\_MAX']
Under-estimations: Abi\_alb for ['all\_MIN']
Under-estimations: Bet\_pen for ['all\_MAX', 'all\_MIN']
Under-estimations: Bet\_pub for ['all\_MAX', 'all\_MIN']
Under-estimations: Car\_bet for ['all\_MAX', 'all\_MIN']
Under-estimations: Cor\_ave for ['all\_MAX', 'all\_MIN']
Under-estimations: Fag\_syl for ['all\_MAX', 'all\_MIN']
Under-estimations: Fra\_exc for ['all\_MAX', 'all\_MIN']
Under-estimations: Pic\_abi for ['all\_MIN']
Under-estimations: Pic\_sit for ['all\_MAX', 'all\_MIN']
Under-estimations: Pin\_hal for ['all\_MAX', 'all\_MIN']
Under-estimations: Pin\_syl for ['all\_MAX', 'all\_MIN']
Under-estimations: Que\_coc for ['all\_MAX', 'all\_MIN']
Under-estimations: Que\_ile for ['all\_MAX', 'all\_MIN']
Under-estimations: Que\_pub for ['all\_MAX', 'all\_MIN']
Under-estimations: Que\_rob for ['all\_MAX', 'all\_MIN']
Under-estimations: Til\_cor for ['all\_MAX', 'all\_MIN']
Under-estimations: Ulm\_gla for ['all\_MAX', 'all\_MIN']


Overall under-estimation errors:
all\_MIN | average error: -91.5 with S.D.: 6.57
all\_MAX | average error: -70.99 with S.D.: 21.19
    \end{Verbatim}

    \hypertarget{species-specific-all_min-vs.-all_max}{%
\subsubsection{Species-specific all\_MIN
vs.~all\_MAX}\label{species-specific-all_min-vs.-all_max}}

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{15}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{c+c1}{\PYZsh{} Check significance for the difference all\PYZus{}MAX vs. all\PYZus{}MIN per species}
\PY{c+c1}{\PYZsh{} Mann\PYZhy{}Whitney U Test}
\PY{n}{species} \PY{o}{=} \PY{n}{EVA\PYZus{}input}\PY{o}{.}\PY{n}{Species}\PY{o}{.}\PY{n}{unique}\PY{p}{(}\PY{p}{)}\PY{o}{.}\PY{n}{tolist}\PY{p}{(}\PY{p}{)}
\PY{n}{best\PYZus{}EVA\PYZus{}df} \PY{o}{=} \PY{n}{pd}\PY{o}{.}\PY{n}{DataFrame}\PY{p}{(}\PY{p}{)}

\PY{c+c1}{\PYZsh{} Store p\PYZhy{}values for Bonferroni corrections}
\PY{n}{p\PYZus{}values} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{zeros}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{species}\PY{p}{)}\PY{p}{)}
\PY{n}{pos} \PY{o}{=} \PY{l+m+mi}{0}
\PY{k}{for} \PY{n}{sp} \PY{o+ow}{in} \PY{n}{species} \PY{p}{:}
    \PY{n}{best\PYZus{}EVA\PYZus{}sp} \PY{o}{=} \PY{n}{pd}\PY{o}{.}\PY{n}{DataFrame}\PY{p}{(}\PY{p}{)}
    \PY{n}{best\PYZus{}EVA\PYZus{}sp}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n}{sp}
    \PY{n}{sp\PYZus{}sub} \PY{o}{=} \PY{n}{residuals\PYZus{}df}\PY{p}{[}\PY{n}{residuals\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{==}\PY{n}{sp}\PY{p}{]}
    \PY{n}{all\PYZus{}min} \PY{o}{=} \PY{n}{sp\PYZus{}sub}\PY{p}{[}\PY{n}{sp\PYZus{}sub}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{==}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{all\PYZus{}MIN}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}
    \PY{n}{all\PYZus{}max} \PY{o}{=} \PY{n}{sp\PYZus{}sub}\PY{p}{[}\PY{n}{sp\PYZus{}sub}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{==}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{all\PYZus{}MAX}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}

    \PY{c+c1}{\PYZsh{} Get p\PYZhy{}values from Mann\PYZhy{}Whitney U Test}
    \PY{n}{\PYZus{}}\PY{p}{,} \PY{n}{p} \PY{o}{=} \PY{n}{mannwhitneyu}\PY{p}{(}\PY{n}{all\PYZus{}min}\PY{o}{.}\PY{n}{residuals}\PY{p}{,} \PY{n}{all\PYZus{}max}\PY{o}{.}\PY{n}{residuals}\PY{p}{)} 
    \PY{n}{p\PYZus{}values}\PY{p}{[}\PY{n}{pos}\PY{p}{]} \PY{o}{=} \PY{n}{p}
    \PY{n}{pos} \PY{o}{=} \PY{n}{pos}\PY{o}{+}\PY{l+m+mi}{1}

\PY{c+c1}{\PYZsh{} Apply Bonferroni corrections for multiple comparison}
\PY{n}{p\PYZus{}adjusted} \PY{o}{=} \PY{n}{multipletests}\PY{p}{(}\PY{n}{p\PYZus{}values}\PY{p}{,} \PY{n}{method}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{bonferroni}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}

\PY{c+c1}{\PYZsh{} all\PYZus{}MIN vs. all\PYZus{}MAX based on corrected p\PYZhy{}values}
\PY{n}{pos} \PY{o}{=} \PY{l+m+mi}{0}
\PY{k}{for} \PY{n}{sp} \PY{o+ow}{in} \PY{n}{species} \PY{p}{:}
    \PY{n}{best\PYZus{}EVA\PYZus{}sp} \PY{o}{=} \PY{n}{pd}\PY{o}{.}\PY{n}{DataFrame}\PY{p}{(}\PY{p}{)}
    \PY{n}{best\PYZus{}EVA\PYZus{}sp}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n}{sp}
    \PY{n}{sp\PYZus{}sub} \PY{o}{=} \PY{n}{residuals\PYZus{}df}\PY{p}{[}\PY{n}{residuals\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{==}\PY{n}{sp}\PY{p}{]}
    \PY{n}{all\PYZus{}min} \PY{o}{=} \PY{n}{sp\PYZus{}sub}\PY{p}{[}\PY{n}{sp\PYZus{}sub}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{==}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{all\PYZus{}MIN}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}
    \PY{n}{all\PYZus{}max} \PY{o}{=} \PY{n}{sp\PYZus{}sub}\PY{p}{[}\PY{n}{sp\PYZus{}sub}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{==}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{all\PYZus{}MAX}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}
    \PY{n}{max\PYZus{}opt} \PY{o}{=} \PY{n}{EVA\PYZus{}input}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{p}{(}\PY{n}{EVA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{==}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{all\PYZus{}MAX\PYZus{}opt}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)} \PY{o}{\PYZam{}} \PY{p}{(}\PY{n}{EVA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{==}\PY{n}{sp}\PY{p}{)}\PY{p}{]}

    \PY{c+c1}{\PYZsh{} Compare all\PYZus{}MIN and all\PYZus{}MAX}
    \PY{n}{all\PYZus{}max\PYZus{}res} \PY{o}{=} \PY{n+nb}{abs}\PY{p}{(}\PY{n}{np}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{n}{all\PYZus{}max}\PY{o}{.}\PY{n}{residuals}\PY{p}{)}\PY{p}{)}
    \PY{n}{all\PYZus{}min\PYZus{}res} \PY{o}{=} \PY{n+nb}{abs}\PY{p}{(}\PY{n}{np}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{n}{all\PYZus{}min}\PY{o}{.}\PY{n}{residuals}\PY{p}{)}\PY{p}{)} 
    \PY{k}{if} \PY{p}{(}\PY{n}{all\PYZus{}max\PYZus{}res} \PY{o}{\PYZlt{}}\PY{o}{=} \PY{n}{all\PYZus{}min\PYZus{}res}\PY{p}{)} \PY{p}{:}
        \PY{n}{best\PYZus{}sp} \PY{o}{=} \PY{n}{all\PYZus{}max}
    \PY{k}{else} \PY{p}{:}
        \PY{n}{best\PYZus{}sp} \PY{o}{=} \PY{n}{all\PYZus{}min}
    
    \PY{c+c1}{\PYZsh{} Check significance with low threshold}
    \PY{n}{p} \PY{o}{=} \PY{n}{p\PYZus{}adjusted}\PY{p}{[}\PY{n}{pos}\PY{p}{]}
    \PY{n}{pos} \PY{o}{=} \PY{n}{pos}\PY{o}{+}\PY{l+m+mi}{1}
    \PY{n}{alpha} \PY{o}{=} \PY{l+m+mf}{1e\PYZhy{}3}
    \PY{k}{if} \PY{n}{p} \PY{o}{\PYZgt{}} \PY{n}{alpha}\PY{p}{:}
        \PY{n+nb}{print}\PY{p}{(}\PY{n}{sp}\PY{o}{+} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ \PYZhy{}\PYZhy{}\PYZgt{} p\PYZhy{}value: }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n+nb}{str}\PY{p}{(}\PY{n+nb}{round}\PY{p}{(}\PY{n}{p}\PY{p}{,}\PY{l+m+mi}{5}\PY{p}{)}\PY{p}{)}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ \PYZhy{}\PYZhy{}\PYZgt{} NOT\PYZhy{}significant difference}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
    \PY{k}{else}\PY{p}{:}
        \PY{n+nb}{print}\PY{p}{(}\PY{n}{sp}\PY{o}{+} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ \PYZhy{}\PYZhy{}\PYZgt{} p\PYZhy{}value: }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n+nb}{str}\PY{p}{(}\PY{n+nb}{round}\PY{p}{(}\PY{n}{p}\PY{p}{,}\PY{l+m+mi}{5}\PY{p}{)}\PY{p}{)}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ \PYZhy{}\PYZhy{}\PYZgt{} significant difference}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
    
    \PY{c+c1}{\PYZsh{} Select optimized set of parameters when possible}
    \PY{k}{if} \PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{max\PYZus{}opt}\PY{p}{)} \PY{o}{\PYZgt{}} \PY{l+m+mi}{0}\PY{p}{)}\PY{p}{:}
        \PY{n}{max\PYZus{}opt} \PY{o}{=} \PY{n}{max\PYZus{}opt}\PY{o}{.}\PY{n}{copy}\PY{p}{(}\PY{p}{)}
        \PY{n}{max\PYZus{}opt}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{res}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n+nb}{abs}\PY{p}{(}\PY{n}{max\PYZus{}opt}\PY{o}{.}\PY{n}{OBS\PYZus{}75ile} \PY{o}{\PYZhy{}} \PY{n}{max\PYZus{}opt}\PY{o}{.}\PY{n}{SIM}\PY{p}{)}
        \PY{n}{best\PYZus{}sp} \PY{o}{=} \PY{n}{max\PYZus{}opt}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{n}{max\PYZus{}opt}\PY{o}{.}\PY{n}{res} \PY{o}{==} \PY{n+nb}{min}\PY{p}{(}\PY{n}{max\PYZus{}opt}\PY{o}{.}\PY{n}{res}\PY{p}{)}\PY{p}{]}
    
    \PY{c+c1}{\PYZsh{} Select best parameter setting and corresponding simulated values}
    \PY{n}{best\PYZus{}EVA\PYZus{}sp}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n}{best\PYZus{}sp}\PY{o}{.}\PY{n}{Parameter\PYZus{}combo}\PY{o}{.}\PY{n}{unique}\PY{p}{(}\PY{p}{)}
    \PY{k}{if} \PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{max\PYZus{}opt}\PY{p}{)} \PY{o}{\PYZgt{}} \PY{l+m+mi}{0}\PY{p}{)}\PY{p}{:}
        \PY{n}{best\PYZus{}EVA\PYZus{}sp}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{sim}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n}{best\PYZus{}sp}\PY{o}{.}\PY{n}{SIM}\PY{o}{.}\PY{n}{unique}\PY{p}{(}\PY{p}{)}
        \PY{n}{best\PYZus{}EVA\PYZus{}sp}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{obs\PYZus{}75ile}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n}{best\PYZus{}sp}\PY{o}{.}\PY{n}{OBS\PYZus{}75ile}\PY{o}{.}\PY{n}{unique}\PY{p}{(}\PY{p}{)}    
    \PY{k}{else} \PY{p}{:}
        \PY{n}{best\PYZus{}EVA\PYZus{}sp}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{sim}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n}{best\PYZus{}sp}\PY{o}{.}\PY{n}{sim}\PY{o}{.}\PY{n}{unique}\PY{p}{(}\PY{p}{)}
        \PY{n}{best\PYZus{}EVA\PYZus{}sp}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{obs\PYZus{}75ile}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{percentile}\PY{p}{(}\PY{n}{best\PYZus{}sp}\PY{o}{.}\PY{n}{obs}\PY{p}{,} \PY{l+m+mi}{75}\PY{p}{)}
    \PY{n}{best\PYZus{}EVA\PYZus{}df} \PY{o}{=} \PY{n}{pd}\PY{o}{.}\PY{n}{concat}\PY{p}{(}\PY{p}{[}\PY{n}{best\PYZus{}EVA\PYZus{}df}\PY{p}{,}\PY{n}{best\PYZus{}EVA\PYZus{}sp}\PY{p}{]}\PY{p}{)}
\PY{n}{best\PYZus{}EVA\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n}{species}
\end{Verbatim}
\end{tcolorbox}

    \begin{Verbatim}[commandchars=\\\{\}]
Abi\_alb --> p-value: 0.0 --> significant difference
Bet\_pen --> p-value: 0.0 --> significant difference
Bet\_pub --> p-value: 0.0 --> significant difference
Car\_bet --> p-value: 0.0 --> significant difference
Cor\_ave --> p-value: 0.0 --> significant difference
Fag\_syl --> p-value: 0.0 --> significant difference
Fra\_exc --> p-value: 0.0 --> significant difference
Pic\_abi --> p-value: 0.0 --> significant difference
Pic\_sit --> p-value: 0.0 --> significant difference
Pin\_syl --> p-value: 0.0 --> significant difference
Pin\_hal --> p-value: 1.0 --> NOT-significant difference
Que\_coc --> p-value: 0.0 --> significant difference
Que\_ile --> p-value: 0.0 --> significant difference
Que\_pub --> p-value: 0.08281 --> NOT-significant difference
Que\_rob --> p-value: 0.0 --> significant difference
Til\_cor --> p-value: 0.0 --> significant difference
Ulm\_gla --> p-value: 0.0 --> significant difference
    \end{Verbatim}

    \hypertarget{best-performing-eva-setting-per-species}{%
\subsubsection{Best-performing EVA setting per
species}\label{best-performing-eva-setting-per-species}}

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{16}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{c+c1}{\PYZsh{} Calculate RMSE\PYZpc{}}
\PY{n}{rmse\PYZus{}mean} \PY{o}{=} \PY{n}{best\PYZus{}EVA\PYZus{}df}\PY{o}{.}\PY{n}{obs\PYZus{}75ile}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{p}{)}

\PY{c+c1}{\PYZsh{} Add migration parameters for all\PYZus{}MAX settings}
\PY{n}{best\PYZus{}EVA\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{rmse}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n}{best\PYZus{}EVA\PYZus{}df}\PY{o}{.}\PY{n}{apply}\PY{p}{(}\PY{k}{lambda} \PY{n}{row}\PY{p}{:} \PY{n}{rmse\PYZus{}perc}\PY{p}{(}\PY{n}{row}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{sim}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{,} \PY{n}{row}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{obs\PYZus{}75ile}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{,} \PY{n}{rmse\PYZus{}mean}\PY{p}{)}\PY{p}{,} \PY{n}{axis} \PY{o}{=} \PY{l+m+mi}{1}\PY{p}{)}
\PY{n}{best\PYZus{}EVA\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{FEC\PYZus{}max}\PY{l+s+s1}{\PYZsq{}}\PY{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PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{all\PYZus{}MAX}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{SDD\PYZus{}d}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{.}\PY{n}{to\PYZus{}list}\PY{p}{(}\PY{p}{)}
\PY{n}{best\PYZus{}EVA\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{LDD\PYZus{}d}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n}{EVA\PYZus{}input}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{n}{EVA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{all\PYZus{}MAX}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{LDD\PYZus{}d}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{.}\PY{n}{to\PYZus{}list}\PY{p}{(}\PY{p}{)}

\PY{c+c1}{\PYZsh{} Add migration parameters for all\PYZus{}MAX\PYZus{}opt species}
\PY{n}{sp\PYZus{}opt} \PY{o}{=} \PY{n}{best\PYZus{}EVA\PYZus{}df}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{n}{best\PYZus{}EVA\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{all\PYZus{}MAX\PYZus{}opt}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{.}\PY{n}{to\PYZus{}list}\PY{p}{(}\PY{p}{)}
\PY{k}{for} \PY{n}{sp} \PY{o+ow}{in} \PY{n}{sp\PYZus{}opt}\PY{p}{:}
    \PY{n}{best\PYZus{}sim} \PY{o}{=} \PY{n}{best\PYZus{}EVA\PYZus{}df}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{n}{best\PYZus{}EVA\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{n}{sp}\PY{p}{]}\PY{o}{.}\PY{n}{sim}
    \PY{n}{best\PYZus{}pars} \PY{o}{=} \PY{n}{EVA\PYZus{}input}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{p}{(}\PY{n}{EVA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{all\PYZus{}MAX\PYZus{}opt}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)} \PY{o}{\PYZam{}} \PY{p}{(}\PY{n}{EVA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{n}{sp}\PY{p}{)} 
                              \PY{o}{\PYZam{}} \PY{p}{(}\PY{n}{EVA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{SIM}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{n+nb}{int}\PY{p}{(}\PY{n}{best\PYZus{}sim}\PY{p}{)}\PY{p}{)}\PY{p}{]}
    \PY{n}{best\PYZus{}EVA\PYZus{}df}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{n}{best\PYZus{}EVA\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{n}{sp}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{FEC\PYZus{}max}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n+nb}{int}\PY{p}{(}\PY{n}{best\PYZus{}pars}\PY{o}{.}\PY{n}{FEC\PYZus{}max}\PY{p}{)}
    \PY{n}{best\PYZus{}EVA\PYZus{}df}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{n}{best\PYZus{}EVA\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{n}{sp}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{GERM\PYZus{}p}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n+nb}{int}\PY{p}{(}\PY{n}{best\PYZus{}pars}\PY{o}{.}\PY{n}{GERM\PYZus{}p}\PY{p}{)}
    \PY{n}{best\PYZus{}EVA\PYZus{}df}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{n}{best\PYZus{}EVA\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{n}{sp}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{SDD\PYZus{}d}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n+nb}{int}\PY{p}{(}\PY{n}{best\PYZus{}pars}\PY{o}{.}\PY{n}{SDD\PYZus{}d}\PY{p}{)}
    \PY{n}{best\PYZus{}EVA\PYZus{}df}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{n}{best\PYZus{}EVA\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{n}{sp}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{LDD\PYZus{}d}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n+nb}{int}\PY{p}{(}\PY{n}{best\PYZus{}pars}\PY{o}{.}\PY{n}{LDD\PYZus{}d}\PY{p}{)}
\PY{n}{best\PYZus{}EVA\PYZus{}df}
\end{Verbatim}
\end{tcolorbox}

            \begin{tcolorbox}[breakable, size=fbox, boxrule=.5pt, pad at break*=1mm, opacityfill=0]
\prompt{Out}{outcolor}{16}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
   Species Parameter\_combo  sim  obs\_75ile        rmse  FEC\_max  GERM\_p  \textbackslash{}
0  Abi\_alb     all\_MAX\_opt  305     287.50    2.663086       81      60
0  Bet\_pen         all\_MAX  179     734.25   84.495916    30000      30
0  Bet\_pub         all\_MAX  179     734.25   84.495916    30000      30
0  Car\_bet         all\_MAX  162     874.25  108.387602      705      80
0  Cor\_ave         all\_MAX  607    1374.25  116.757301       12      60
0  Fag\_syl         all\_MAX   63     274.25   32.147253       62      80
0  Fra\_exc         all\_MAX  312     424.25   17.081795       50      65
0  Pic\_abi     all\_MAX\_opt  352     412.50    9.206669      163      95
0  Pic\_sit         all\_MAX  125     411.75   43.636567       75      80
0  Pin\_syl         all\_MAX  116    1274.25  176.258252       43      95
0  Pin\_hal         all\_MAX   16    1274.25  191.475887       43      60
0  Que\_coc         all\_MAX  110     449.25   51.625825       10      75
0  Que\_ile         all\_MAX  111     449.25   51.473649       50      95
0  Que\_pub         all\_MAX   17     449.25   65.778225       50      90
0  Que\_rob         all\_MAX   85     449.25   55.430234       50      95
0  Til\_cor         all\_MAX  147     411.75   40.288687      720      55
0  Ulm\_gla         all\_MAX  153     886.75  111.659394      949      65

   SDD\_d  LDD\_d
0    100    710
0    200    475
0    200    475
0    100    425
0     25   1500
0     25    200
0    100    725
0    100    780
0    100    800
0    100    250
0    100    250
0     25    300
0     25    300
0     25    300
0     25    300
0    100    374
0    100    350
\end{Verbatim}
\end{tcolorbox}
        
    \hypertarget{evaluation-of-model-uncertainty}{%
\section{Evaluation of model
uncertainty}\label{evaluation-of-model-uncertainty}}

\hypertarget{implementation-of-fat-tailed-seed-dispersal-kernels}{%
\subsection{Implementation of fat-tailed seed dispersal
kernels}\label{implementation-of-fat-tailed-seed-dispersal-kernels}}

We implemented five additional fat-tailed kernels into the dispersal
sub-model of LPJ-GM and run simulations with the best set of migration
parameters found by EVA, while varying the shape parameter \(b\) in a
meaningful range for each kernel.

\textbf{Table 3}. Probability density functions (pdf) for the default
dispersal kernel in LPJ-GM (negative exponential) and five additional
kernels. d = mean distance (in meters); a = scale parameter as a
function of distance; b = shape parameter range to search for better
representation of LDD events. Range boundaries are defined by the values
for which pdf are mathematically significant and the corresponding tail
is fat (Nathan et al., 2012). Table adapted from
\href{https://doi.org/10.1111/1365-2745.12666}{Bullock et al.~(2017)}.

\begin{table}[ht]
\centering
\resizebox{\textwidth}{!}{\begin{tabular}{llllr}
\toprule
Kernel family & Probability density function & Scale parameter (a) & Shape parameter (b) & Weight of the tail \\
\midrule
Negative exponential & \(\frac{1}{2\pi a^2}\exp(-\frac{d}{a})\) &
\(\frac{d}{2}\) & - & Exponentially bounded \\
Exponential power &
\(\frac{b}{2\pi a^2 \Gamma(\frac{2}{b})} \exp(-\frac{d^b}{a^b})\) &
\(\frac{\Gamma(\frac{2}{b})}{\Gamma(\frac{3}{b})}\) & \(0 - 1\) &
Fat-tailed (for \(b < 1\)) non-power law \\
Weibull & \(\frac{b}{2\pi a^2} d^{b-2} \exp(-\frac{d^b}{a^b})\) &
\(\frac{b}{\Gamma(\frac{1}{b})} d\) & \(0 - 2.5\) & Fat-tailed non-power
law \\
twoDt & \(\frac{b-1}{\pi a^2} (1 + \frac{d^2}{a^2}^{-b})\) &
\(\frac{2}{\pi} \frac{\Gamma(b-1)}{\Gamma(b - \frac{3}{2})} d\) &
\(1 - 5\) & Fat-tailed power law \\
Logistic &
\(\frac{b}{2\pi a^2 \Gamma(1 - \frac{2}{b})} (1 + \frac{d^b}{a^b})^{-1}\)
&
\(\frac{\Gamma(\frac{2}{b}) \Gamma(1 - \frac{2}{b})}{\Gamma(\frac{3}{b}) \Gamma(1 - \frac{3}{b})} d\)
& \(2 - 5\) & Fat-tailed power law \\
Log-hyperbolic secant &
\(\frac{1}{\pi^2 b d^2} (\frac{d}{a}^{\frac{1}{b}} + \frac{d}{a}^{-\frac{1}{b}})^{-1}\)
& \(d\) & \(0 - 1\) & Fat-tailed power law \\
\bottomrule
\end{tabular}}
\end{table} 

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{17}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{f}\PY{p}{,} \PY{n}{axes} \PY{o}{=} \PY{n}{plt}\PY{o}{.}\PY{n}{subplots}\PY{p}{(}\PY{l+m+mi}{2}\PY{p}{,} \PY{l+m+mi}{3}\PY{p}{,} \PY{n}{sharex}\PY{o}{=}\PY{k+kc}{True}\PY{p}{,} \PY{n}{sharey}\PY{o}{=}\PY{k+kc}{True}\PY{p}{)}
\PY{p}{(}\PY{n}{ax1}\PY{p}{,} \PY{n}{ax2}\PY{p}{,} \PY{n}{ax3}\PY{p}{)}\PY{p}{,} \PY{p}{(}\PY{n}{ax4}\PY{p}{,} \PY{n}{ax5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{o}{.}\PY{n}{flatten}\PY{p}{(}\PY{p}{)}\PY{p}{)}\PY{p}{:}
    \PY{k}{if} \PY{n}{kernel}\PY{o}{==}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{NegExp}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:}
        \PY{k}{def} \PY{n+nf}{neg\PYZus{}exponential}\PY{p}{(}\PY{n}{dist}\PY{p}{,} \PY{n}{dd}\PY{p}{)} \PY{p}{:}
            \PY{n}{a} \PY{o}{=} \PY{n}{dd} \PY{o}{/} \PY{l+m+mi}{2}
            \PY{k}{if} \PY{p}{(}\PY{n}{a} \PY{o}{\PYZlt{}}\PY{o}{=} \PY{l+m+mi}{0}\PY{p}{)}\PY{p}{:}
                \PY{k}{return} \PY{n}{np}\PY{o}{.}\PY{n}{zeros}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{dist}\PY{p}{)}\PY{p}{)}
            \PY{n}{dist\PYZus{}prob} \PY{o}{=} \PY{l+m+mi}{1} \PY{o}{/} \PY{p}{(}\PY{l+m+mi}{2} \PY{o}{*} \PY{n}{np}\PY{o}{.}\PY{n}{pi} \PY{o}{*} \PY{n}{a}\PY{o}{*}\PY{o}{*}\PY{l+m+mi}{2}\PY{p}{)} \PY{o}{*} \PY{n}{np}\PY{o}{.}\PY{n}{exp}\PY{p}{(}\PY{o}{\PYZhy{}}\PY{n}{dist} \PY{o}{/} \PY{n}{a}\PY{p}{)}
            \PY{k}{return} \PY{n}{scaler\PYZus{}0\PYZus{}1}\PY{p}{(}\PY{n}{dist\PYZus{}prob}\PY{p}{)}
        \PY{n}{x} \PY{o}{=} \PY{n}{neg\PYZus{}exponential}\PY{p}{(}\PY{n}{distance\PYZus{}range}\PY{p}{,} \PY{n}{dd}\PY{p}{)}
    
    \PY{k}{if} \PY{n}{kernel}\PY{o}{==}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ExpPow}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:}
        \PY{k}{def} \PY{n+nf}{exp\PYZus{}power}\PY{p}{(}\PY{n}{dist}\PY{p}{,} \PY{n}{dd}\PY{p}{,} \PY{n}{b}\PY{p}{)} \PY{p}{:}
            \PY{n}{a} \PY{o}{=} \PY{p}{(}\PY{n}{gamma}\PY{p}{(}\PY{l+m+mi}{2}\PY{o}{/}\PY{n}{b}\PY{p}{)} \PY{o}{/} \PY{n}{gamma}\PY{p}{(}\PY{l+m+mi}{3}\PY{o}{/}\PY{n}{b}\PY{p}{)}\PY{p}{)} \PY{o}{*} \PY{n}{dd}
            \PY{k}{if} \PY{p}{(}\PY{n}{a} \PY{o}{==} \PY{l+m+mf}{0.} \PY{o+ow}{or} \PY{n}{b} \PY{o}{\PYZlt{}}\PY{o}{=} \PY{l+m+mf}{0.}\PY{p}{)}\PY{p}{:}
                \PY{k}{return} \PY{n}{np}\PY{o}{.}\PY{n}{zeros}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{dist}\PY{p}{)}\PY{p}{)}
            \PY{n}{dist\PYZus{}prob} \PY{o}{=} \PY{n}{b} \PY{o}{/} \PY{p}{(}\PY{l+m+mi}{2} \PY{o}{*} \PY{n}{np}\PY{o}{.}\PY{n}{pi} \PY{o}{*} \PY{n}{a}\PY{o}{*}\PY{o}{*}\PY{l+m+mi}{2} \PY{o}{*} \PY{n}{gamma}\PY{p}{(}\PY{l+m+mi}{2}\PY{o}{/}\PY{n}{b}\PY{p}{)}\PY{p}{)} \PY{o}{*} \PY{n}{np}\PY{o}{.}\PY{n}{exp}\PY{p}{(}\PY{o}{\PYZhy{}}\PY{p}{(}\PY{n}{dist}\PY{o}{*}\PY{o}{*}\PY{n}{b} \PY{o}{/} \PY{n}{a}\PY{o}{*}\PY{o}{*}\PY{n}{b}\PY{p}{)}\PY{p}{)}
            \PY{k}{return} \PY{n}{scaler\PYZus{}0\PYZus{}1}\PY{p}{(}\PY{n}{dist\PYZus{}prob}\PY{p}{)}
        \PY{n}{x1} \PY{o}{=} \PY{n}{exp\PYZus{}power}\PY{p}{(}\PY{n}{distance\PYZus{}range}\PY{p}{,} \PY{n}{dd}\PY{p}{,} \PY{l+m+mf}{0.15}\PY{p}{)}
        \PY{n}{x2} \PY{o}{=} \PY{n}{exp\PYZus{}power}\PY{p}{(}\PY{n}{distance\PYZus{}range}\PY{p}{,} \PY{n}{dd}\PY{p}{,} \PY{l+m+mf}{0.25}\PY{p}{)}
        \PY{n}{x3} \PY{o}{=} \PY{n}{exp\PYZus{}power}\PY{p}{(}\PY{n}{distance\PYZus{}range}\PY{p}{,} \PY{n}{dd}\PY{p}{,} \PY{l+m+mf}{0.5}\PY{p}{)}
        \PY{n}{x4} \PY{o}{=} \PY{n}{exp\PYZus{}power}\PY{p}{(}\PY{n}{distance\PYZus{}range}\PY{p}{,} \PY{n}{dd}\PY{p}{,} \PY{l+m+mf}{0.75}\PY{p}{)}
    
    \PY{k}{if} \PY{n}{kernel}\PY{o}{==}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Weibull}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:}
        \PY{k}{def} \PY{n+nf}{weibull}\PY{p}{(}\PY{n}{dist}\PY{p}{,} \PY{n}{dd}\PY{p}{,} \PY{n}{b}\PY{p}{)} \PY{p}{:}
            \PY{n}{a} \PY{o}{=} \PY{p}{(}\PY{n}{b} \PY{o}{/} \PY{n}{gamma}\PY{p}{(}\PY{l+m+mi}{1}\PY{o}{/}\PY{n}{b}\PY{p}{)}\PY{p}{)} \PY{o}{*} \PY{n}{dd}
            \PY{k}{if} \PY{p}{(}\PY{n}{a} \PY{o}{\PYZlt{}}\PY{o}{=} \PY{l+m+mf}{0.} \PY{o+ow}{or} \PY{n}{b} \PY{o}{\PYZlt{}}\PY{o}{=} \PY{l+m+mf}{0.}\PY{p}{)}\PY{p}{:}
                \PY{k}{return} \PY{n}{np}\PY{o}{.}\PY{n}{zeros}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{dist}\PY{p}{)}\PY{p}{)}
            \PY{n}{dist\PYZus{}prob} \PY{o}{=} \PY{n}{b} \PY{o}{/} \PY{p}{(}\PY{l+m+mi}{2} \PY{o}{*} \PY{n}{np}\PY{o}{.}\PY{n}{pi} \PY{o}{*} \PY{n}{a}\PY{o}{*}\PY{o}{*}\PY{l+m+mi}{2}\PY{p}{)} \PY{o}{*} \PY{n}{dist}\PY{o}{*}\PY{o}{*}\PY{p}{(}\PY{n}{b} \PY{o}{\PYZhy{}} \PY{l+m+mi}{2}\PY{p}{)} \PY{o}{*} \PY{n}{np}\PY{o}{.}\PY{n}{exp}\PY{p}{(}\PY{o}{\PYZhy{}}\PY{n}{dist}\PY{o}{*}\PY{o}{*}\PY{n}{b} \PY{o}{/} \PY{n}{a}\PY{o}{*}\PY{o}{*}\PY{n}{b}\PY{p}{)}
            \PY{k}{return} \PY{n}{scaler\PYZus{}0\PYZus{}1}\PY{p}{(}\PY{n}{dist\PYZus{}prob}\PY{p}{)}
        \PY{n}{x1} \PY{o}{=} \PY{n}{weibull}\PY{p}{(}\PY{n}{distance\PYZus{}range}\PY{p}{,} \PY{n}{dd}\PY{p}{,} \PY{l+m+mf}{1.75}\PY{p}{)}
        \PY{n}{x2} \PY{o}{=} \PY{n}{weibull}\PY{p}{(}\PY{n}{distance\PYZus{}range}\PY{p}{,} \PY{n}{dd}\PY{p}{,} \PY{l+m+mf}{2.}\PY{p}{)}
        \PY{n}{x3} \PY{o}{=} \PY{n}{weibull}\PY{p}{(}\PY{n}{distance\PYZus{}range}\PY{p}{,} \PY{n}{dd}\PY{p}{,} \PY{l+m+mf}{2.25}\PY{p}{)}
        \PY{n}{x4} \PY{o}{=} \PY{n}{weibull}\PY{p}{(}\PY{n}{distance\PYZus{}range}\PY{p}{,} \PY{n}{dd}\PY{p}{,} \PY{l+m+mf}{2.5}\PY{p}{)}
        
    \PY{k}{if} \PY{n}{kernel}\PY{o}{==}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{twoDt}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:}
        \PY{k}{def} \PY{n+nf}{twoDt}\PY{p}{(}\PY{n}{dist}\PY{p}{,} \PY{n}{dd}\PY{p}{,} \PY{n}{b}\PY{p}{)} \PY{p}{:}
            \PY{n}{a} \PY{o}{=} \PY{p}{(}\PY{n}{gamma}\PY{p}{(}\PY{n}{b} \PY{o}{\PYZhy{}} \PY{l+m+mi}{1}\PY{p}{)} \PY{o}{/} \PY{n}{gamma}\PY{p}{(}\PY{n}{b} \PY{o}{\PYZhy{}} \PY{l+m+mi}{3}\PY{o}{/}\PY{l+m+mi}{2}\PY{p}{)}\PY{p}{)} \PY{o}{*} \PY{l+m+mi}{2}\PY{o}{/}\PY{n}{np}\PY{o}{.}\PY{n}{pi} \PY{o}{*} \PY{n}{dd}
            \PY{k}{if} \PY{p}{(}\PY{n}{a} \PY{o}{\PYZlt{}}\PY{o}{=} \PY{l+m+mf}{0.} \PY{o+ow}{or} \PY{n}{b} \PY{o}{\PYZlt{}}\PY{o}{=} \PY{l+m+mf}{1.}\PY{p}{)} \PY{p}{:}
                \PY{k}{return} \PY{n}{np}\PY{o}{.}\PY{n}{zeros}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{dist}\PY{p}{)}\PY{p}{)}
            \PY{n}{dist\PYZus{}prob} \PY{o}{=} \PY{p}{(}\PY{n}{b} \PY{o}{\PYZhy{}} \PY{l+m+mi}{1}\PY{p}{)} \PY{o}{/} \PY{p}{(}\PY{n}{np}\PY{o}{.}\PY{n}{pi} \PY{o}{*} \PY{n}{a}\PY{o}{*}\PY{o}{*}\PY{l+m+mi}{2}\PY{p}{)} \PY{o}{*} \PY{p}{(}\PY{l+m+mi}{1} \PY{o}{+} \PY{n}{dist}\PY{o}{*}\PY{o}{*}\PY{l+m+mi}{2} \PY{o}{/} \PY{n}{a}\PY{o}{*}\PY{o}{*}\PY{l+m+mi}{2}\PY{p}{)}\PY{o}{*}\PY{o}{*}\PY{p}{(}\PY{o}{\PYZhy{}}\PY{n}{b}\PY{p}{)}
            \PY{k}{return} \PY{n}{scaler\PYZus{}0\PYZus{}1}\PY{p}{(}\PY{n}{dist\PYZus{}prob}\PY{p}{)}
        \PY{n}{x1} \PY{o}{=} \PY{n}{twoDt}\PY{p}{(}\PY{n}{distance\PYZus{}range}\PY{p}{,} \PY{n}{dd}\PY{p}{,} \PY{l+m+mf}{2.}\PY{p}{)}
        \PY{n}{x2} \PY{o}{=} \PY{n}{twoDt}\PY{p}{(}\PY{n}{distance\PYZus{}range}\PY{p}{,} \PY{n}{dd}\PY{p}{,} \PY{l+m+mf}{3.}\PY{p}{)}
        \PY{n}{x3} \PY{o}{=} \PY{n}{twoDt}\PY{p}{(}\PY{n}{distance\PYZus{}range}\PY{p}{,} \PY{n}{dd}\PY{p}{,} \PY{l+m+mf}{4.}\PY{p}{)}
        \PY{n}{x4} \PY{o}{=} \PY{n}{twoDt}\PY{p}{(}\PY{n}{distance\PYZus{}range}\PY{p}{,} \PY{n}{dd}\PY{p}{,} \PY{l+m+mf}{5.}\PY{p}{)}
        
    \PY{k}{if} \PY{n}{kernel}\PY{o}{==}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Logistic}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:}
        \PY{k}{def} \PY{n+nf}{logistic}\PY{p}{(}\PY{n}{dist}\PY{p}{,} \PY{n}{dd}\PY{p}{,} \PY{n}{b}\PY{p}{)} \PY{p}{:}
            \PY{n}{a} \PY{o}{=} \PY{p}{(}\PY{n}{gamma}\PY{p}{(}\PY{l+m+mi}{2}\PY{o}{/}\PY{n}{b}\PY{p}{)} \PY{o}{*} \PY{n}{gamma}\PY{p}{(}\PY{l+m+mi}{1} \PY{o}{\PYZhy{}} \PY{l+m+mi}{2}\PY{o}{/}\PY{n}{b}\PY{p}{)} \PY{o}{/} \PY{n}{gamma}\PY{p}{(}\PY{l+m+mi}{3}\PY{o}{/}\PY{n}{b}\PY{p}{)} \PY{o}{*} \PY{n}{gamma}\PY{p}{(}\PY{l+m+mi}{1} \PY{o}{\PYZhy{}} \PY{l+m+mi}{3}\PY{o}{/}\PY{n}{b}\PY{p}{)}\PY{p}{)} \PY{o}{*} \PY{n}{dd}
            \PY{k}{if} \PY{p}{(}\PY{n}{a} \PY{o}{\PYZlt{}}\PY{o}{=} \PY{l+m+mf}{0.} \PY{o+ow}{or} \PY{n}{b} \PY{o}{\PYZlt{}}\PY{o}{=} \PY{l+m+mf}{2.}\PY{p}{)} \PY{p}{:}
                \PY{k}{return} \PY{n}{np}\PY{o}{.}\PY{n}{zeros}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{dist}\PY{p}{)}\PY{p}{)}
            \PY{n}{dist\PYZus{}prob} \PY{o}{=} \PY{n}{b} \PY{o}{/} \PY{p}{(}\PY{l+m+mi}{2} \PY{o}{*} \PY{n}{np}\PY{o}{.}\PY{n}{pi} \PY{o}{*} \PY{n}{a}\PY{o}{*}\PY{o}{*}\PY{l+m+mi}{2} \PY{o}{*} \PY{n}{gamma}\PY{p}{(}\PY{l+m+mi}{2}\PY{o}{/}\PY{n}{b}\PY{p}{)} \PY{o}{*} \PY{n}{gamma}\PY{p}{(}\PY{l+m+mi}{1} \PY{o}{\PYZhy{}} \PY{l+m+mi}{2}\PY{o}{/}\PY{n}{b}\PY{p}{)}\PY{p}{)} \PY{o}{*} \PY{p}{(}\PY{l+m+mi}{1} \PY{o}{+} \PY{n}{dist}\PY{o}{*}\PY{o}{*}\PY{n}{b} \PY{o}{/} \PY{n}{a}\PY{o}{*}\PY{o}{*}\PY{n}{b}\PY{p}{)}\PY{o}{*}\PY{o}{*}\PY{o}{\PYZhy{}}\PY{l+m+mi}{1}
            \PY{k}{return} \PY{n}{scaler\PYZus{}0\PYZus{}1}\PY{p}{(}\PY{n}{dist\PYZus{}prob}\PY{p}{)}
        \PY{n}{x1} \PY{o}{=} \PY{n}{logistic}\PY{p}{(}\PY{n}{distance\PYZus{}range}\PY{p}{,} \PY{n}{dd}\PY{p}{,} \PY{l+m+mf}{3.5}\PY{p}{)}
        \PY{n}{x2} \PY{o}{=} \PY{n}{logistic}\PY{p}{(}\PY{n}{distance\PYZus{}range}\PY{p}{,} \PY{n}{dd}\PY{p}{,} \PY{l+m+mf}{4.}\PY{p}{)}
        \PY{n}{x3} \PY{o}{=} \PY{n}{logistic}\PY{p}{(}\PY{n}{distance\PYZus{}range}\PY{p}{,} \PY{n}{dd}\PY{p}{,} \PY{l+m+mf}{4.5}\PY{p}{)}
        \PY{n}{x4} \PY{o}{=} \PY{n}{logistic}\PY{p}{(}\PY{n}{distance\PYZus{}range}\PY{p}{,} \PY{n}{dd}\PY{p}{,} \PY{l+m+mf}{5.}\PY{p}{)}

    \PY{k}{if} \PY{n}{kernel}\PY{o}{==}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{LogSec}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:}
        \PY{k}{def} \PY{n+nf}{log\PYZus{}sech}\PY{p}{(}\PY{n}{dist}\PY{p}{,} \PY{n}{dd}\PY{p}{,} \PY{n}{b}\PY{p}{)} \PY{p}{:}
            \PY{n}{a} \PY{o}{=} \PY{n}{dd}
            \PY{k}{if} \PY{p}{(}\PY{n}{a} \PY{o}{\PYZlt{}}\PY{o}{=} \PY{l+m+mf}{0.} \PY{o+ow}{or} \PY{n}{b} \PY{o}{\PYZlt{}}\PY{o}{=} \PY{l+m+mf}{0.}\PY{p}{)} \PY{p}{:}
                \PY{k}{return} \PY{n}{np}\PY{o}{.}\PY{n}{zeros}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{dist}\PY{p}{)}\PY{p}{)}
            \PY{n}{dist\PYZus{}prob} \PY{o}{=} \PY{l+m+mi}{1} \PY{o}{/} \PY{p}{(}\PY{n}{np}\PY{o}{.}\PY{n}{pi}\PY{o}{*}\PY{o}{*}\PY{l+m+mi}{2} \PY{o}{*} \PY{n}{b} \PY{o}{*} \PY{n}{dist}\PY{o}{*}\PY{o}{*}\PY{l+m+mi}{2}\PY{p}{)} \PY{o}{/} \PY{p}{(}\PY{p}{(}\PY{n}{dist} \PY{o}{/} \PY{n}{a}\PY{p}{)}\PY{o}{*}\PY{o}{*}\PY{p}{(}\PY{l+m+mi}{1} \PY{o}{/} \PY{n}{b}\PY{p}{)} \PY{o}{+} \PY{p}{(}\PY{n}{dist} \PY{o}{/} \PY{n}{a}\PY{p}{)}\PY{o}{*}\PY{o}{*}\PY{p}{(}\PY{o}{\PYZhy{}}\PY{l+m+mi}{1} \PY{o}{/} \PY{n}{b}\PY{p}{)}\PY{p}{)}
            \PY{k}{return} \PY{n}{scaler\PYZus{}0\PYZus{}1}\PY{p}{(}\PY{n}{dist\PYZus{}prob}\PY{p}{)}
        \PY{n}{x1} \PY{o}{=} \PY{n}{log\PYZus{}sech}\PY{p}{(}\PY{n}{distance\PYZus{}range}\PY{p}{,} \PY{n}{dd}\PY{p}{,} \PY{l+m+mf}{0.1}\PY{p}{)}
        \PY{n}{x2} \PY{o}{=} \PY{n}{log\PYZus{}sech}\PY{p}{(}\PY{n}{distance\PYZus{}range}\PY{p}{,} \PY{n}{dd}\PY{p}{,} \PY{l+m+mf}{0.25}\PY{p}{)}
        \PY{n}{x3} \PY{o}{=} \PY{n}{log\PYZus{}sech}\PY{p}{(}\PY{n}{distance\PYZus{}range}\PY{p}{,} \PY{n}{dd}\PY{p}{,} \PY{l+m+mf}{0.35}\PY{p}{)}
        \PY{n}{x4} \PY{o}{=} \PY{n}{log\PYZus{}sech}\PY{p}{(}\PY{n}{distance\PYZus{}range}\PY{p}{,} \PY{n}{dd}\PY{p}{,} \PY{l+m+mf}{0.5}\PY{p}{)}

    \PY{k}{if} \PY{n}{kernel}\PY{o}{==}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{NegExp}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:}
        \PY{n}{ax}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{distance\PYZus{}range}\PY{p}{,}\PY{n}{x}\PY{p}{,}\PY{n}{color}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{black}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{n}{ls}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{\PYZhy{}\PYZhy{}}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
        \PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}title}\PY{p}{(}\PY{n}{kernel}\PY{p}{)}
        \PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}xlim}\PY{p}{(}\PY{o}{\PYZhy{}}\PY{l+m+mf}{0.05}\PY{p}{,}\PY{n}{distance\PYZus{}range}\PY{o}{.}\PY{n}{max}\PY{p}{(}\PY{p}{)}\PY{p}{)}
        \PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}ylim}\PY{p}{(}\PY{o}{\PYZhy{}}\PY{l+m+mf}{0.05}\PY{p}{,}\PY{l+m+mf}{1.05}\PY{p}{)}
    \PY{k}{else} \PY{p}{:}
        \PY{n}{ax}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{distance\PYZus{}range}\PY{p}{,}\PY{n}{x1}\PY{p}{)}
        \PY{n}{ax}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{distance\PYZus{}range}\PY{p}{,}\PY{n}{x2}\PY{p}{)}
        \PY{n}{ax}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{distance\PYZus{}range}\PY{p}{,}\PY{n}{x3}\PY{p}{)}
        \PY{n}{ax}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{distance\PYZus{}range}\PY{p}{,}\PY{n}{x4}\PY{p}{)}
        \PY{k}{if} \PY{n}{kernel}\PY{o}{==}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ExpPow}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:}
            \PY{n}{ax}\PY{o}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+s+s1}{0.35}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{0.5}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{,} \PY{n}{frameon}\PY{o}{=}\PY{k+kc}{False}\PY{p}{)}
    
    \PY{n}{ax}\PY{o}{.}\PY{n}{grid}\PY{p}{(}\PY{k+kc}{False}\PY{p}{)}
    \PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}xlim}\PY{p}{(}\PY{o}{\PYZhy{}}\PY{l+m+mf}{0.05}\PY{p}{,}\PY{n}{distance\PYZus{}range}\PY{o}{.}\PY{n}{max}\PY{p}{(}\PY{p}{)}\PY{p}{)}
    \PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}ylim}\PY{p}{(}\PY{o}{\PYZhy{}}\PY{l+m+mf}{0.05}\PY{p}{,}\PY{l+m+mf}{1.05}\PY{p}{)}
    \PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}title}\PY{p}{(}\PY{n}{kernel}\PY{p}{)}

\PY{n}{ax4}\PY{o}{.}\PY{n}{set\PYZus{}xlabel}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Dispersal distance [m]}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n}{ax5}\PY{o}{.}\PY{n}{set\PYZus{}xlabel}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Dispersal distance [m]}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n}{ax6}\PY{o}{.}\PY{n}{set\PYZus{}xlabel}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Dispersal distance [m]}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n}{ax1}\PY{o}{.}\PY{n}{set\PYZus{}ylabel}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Dispersal probability}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n}{ax4}\PY{o}{.}\PY{n}{set\PYZus{}ylabel}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Dispersal probability}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n}{f}\PY{o}{.}\PY{n}{subplots\PYZus{}adjust}\PY{p}{(}\PY{n}{wspace}\PY{o}{=}\PY{l+m+mf}{0.1}\PY{p}{)}

\PY{n}{plt}\PY{o}{.}\PY{n}{savefig}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Figure\PYZus{}3.png}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{bbox\PYZus{}inches}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{tight}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{dpi}\PY{o}{=}\PY{l+m+mi}{300}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}

    \begin{center}
    \adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{output_34_0.png}
    \end{center}
    { \hspace*{\fill} \\}
    
    \hypertarget{species-specific-performance-for-different-shape-parameters}{%
\subsection{Species-specific performance for different shape
parameters}\label{species-specific-performance-for-different-shape-parameters}}

We explored species- and kernel-specific parameter space of the shape
parameter b by looking at the mean-normalized residuals of simulated
migration rates with respect to the 75th percentiles of observed values.

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{18}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{c+c1}{\PYZsh{} Calculate residuals to the 75th percentile observations}
\PY{n}{KA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{residuals\PYZus{}75ile}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=}  \PY{n}{KA\PYZus{}input}\PY{o}{.}\PY{n}{SIM} \PY{o}{\PYZhy{}} \PY{n}{KA\PYZus{}input}\PY{o}{.}\PY{n}{OBS\PYZus{}75ile}
\PY{n}{newkernels\PYZus{}df} \PY{o}{=} \PY{n}{KA\PYZus{}input}\PY{o}{.}\PY{n}{copy}\PY{p}{(}\PY{p}{)}

\PY{c+c1}{\PYZsh{} Scale residuals at the species\PYZhy{}level}
\PY{n}{species} \PY{o}{=} \PY{n}{newkernels\PYZus{}df}\PY{o}{.}\PY{n}{Species}\PY{o}{.}\PY{n}{unique}\PY{p}{(}\PY{p}{)}
\PY{n}{res\PYZus{}mean\PYZus{}norm\PYZus{}df} \PY{o}{=} \PY{n}{pd}\PY{o}{.}\PY{n}{DataFrame}\PY{p}{(}\PY{p}{)}
\PY{k}{for} \PY{n}{sp} \PY{o+ow}{in} \PY{n}{species} \PY{p}{:}
    \PY{n}{sp\PYZus{}df} \PY{o}{=} \PY{n}{newkernels\PYZus{}df}\PY{p}{[}\PY{n}{newkernels\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{n}{sp}\PY{p}{]}
    \PY{n}{res\PYZus{}mean\PYZus{}norm} \PY{o}{=} \PY{n}{mean\PYZus{}norm}\PY{p}{(}\PY{n}{sp\PYZus{}df}\PY{o}{.}\PY{n}{residuals\PYZus{}75ile}\PY{p}{)}
    \PY{n}{res\PYZus{}mean\PYZus{}norm} \PY{o}{=} \PY{n}{pd}\PY{o}{.}\PY{n}{DataFrame}\PY{p}{(}\PY{n}{res\PYZus{}mean\PYZus{}norm}\PY{p}{)}
    \PY{n}{res\PYZus{}mean\PYZus{}norm\PYZus{}df} \PY{o}{=} \PY{n}{pd}\PY{o}{.}\PY{n}{concat}\PY{p}{(}\PY{p}{[}\PY{n}{res\PYZus{}mean\PYZus{}norm\PYZus{}df}\PY{p}{,}\PY{n}{res\PYZus{}mean\PYZus{}norm}\PY{p}{]}\PY{p}{)}
\PY{n}{newkernels\PYZus{}df} \PY{o}{=} \PY{n}{newkernels\PYZus{}df}\PY{o}{.}\PY{n}{copy}\PY{p}{(}\PY{p}{)}
\PY{n}{newkernels\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{residuals\PYZus{}scaled}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n}{res\PYZus{}mean\PYZus{}norm\PYZus{}df}\PY{o}{.}\PY{n}{values}

\PY{c+c1}{\PYZsh{} Merge labels of kernel function and shape parameter}
\PY{n}{newkernels\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{shape\PYZus{}par}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n+nb}{list}\PY{p}{(}\PY{n+nb}{map}\PY{p}{(}\PY{n+nb}{str}\PY{p}{,} \PY{n}{newkernels\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{shape\PYZus{}par}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{)}\PY{p}{)}
\PY{n}{newkernels\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{kernel\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n}{newkernels\PYZus{}df}\PY{o}{.}\PY{n}{kernel\PYZus{}fun}\PY{o}{.}\PY{n}{str}\PY{o}{.}\PY{n}{cat}\PY{p}{(}\PY{n}{newkernels\PYZus{}df}\PY{o}{.}\PY{n}{shape\PYZus{}par}\PY{p}{)}
\PY{n}{newkernels\PYZus{}df}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{n}{newkernels\PYZus{}df}\PY{o}{.}\PY{n}{kernel\PYZus{}fun} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{NegExp}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{kernel\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Default\PYZus{}NegExp}\PY{l+s+s1}{\PYZsq{}}

\PY{c+c1}{\PYZsh{} Select representetive shape parameter values to plot}
\PY{n}{ExpPow\PYZus{}df} \PY{o}{=} \PY{n}{newkernels\PYZus{}df}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{p}{(}\PY{n}{newkernels\PYZus{}df}\PY{o}{.}\PY{n}{kernel\PYZus{}fun} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ExpPow}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)} \PY{o}{\PYZam{}} 
                  \PY{p}{(}\PY{n}{newkernels\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{shape\PYZus{}par}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{.}\PY{n}{isin}\PY{p}{(}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{0.15}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{0.25}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{0.5}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{0.75}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{)}\PY{p}{)}\PY{p}{]}
\PY{n}{Weibull\PYZus{}df} \PY{o}{=} \PY{n}{newkernels\PYZus{}df}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{p}{(}\PY{n}{newkernels\PYZus{}df}\PY{o}{.}\PY{n}{kernel\PYZus{}fun} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Weibull}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)} \PY{o}{\PYZam{}} 
                  \PY{p}{(}\PY{n}{newkernels\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{shape\PYZus{}par}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{.}\PY{n}{isin}\PY{p}{(}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{1.75}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{2.0}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{2.25}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{2.5}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{)}\PY{p}{)}\PY{p}{]}
\PY{n}{twoDt\PYZus{}df} \PY{o}{=} \PY{n}{newkernels\PYZus{}df}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{p}{(}\PY{n}{newkernels\PYZus{}df}\PY{o}{.}\PY{n}{kernel\PYZus{}fun} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{twoDt}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)} \PY{o}{\PYZam{}} 
                  \PY{p}{(}\PY{n}{newkernels\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{shape\PYZus{}par}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{.}\PY{n}{isin}\PY{p}{(}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{2.0}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{3.0}\PY{l+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{}}\PY{l+s+s1}{LogSec}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)} \PY{o}{\PYZam{}} 
                  \PY{p}{(}\PY{n}{newkernels\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{shape\PYZus{}par}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{.}\PY{n}{isin}\PY{p}{(}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{0.1}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{0.25}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{0.35}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{0.5}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{)}\PY{p}{)}\PY{p}{]}
\PY{n}{NegExp\PYZus{}df} \PY{o}{=} \PY{n}{newkernels\PYZus{}df}\PY{p}{[}\PY{n}{newkernels\PYZus{}df}\PY{o}{.}\PY{n}{kernel\PYZus{}fun} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{NegExp}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}
\PY{n}{kernel\PYZus{}sel\PYZus{}df} \PY{o}{=} \PY{n}{pd}\PY{o}{.}\PY{n}{concat}\PY{p}{(}\PY{p}{[}\PY{n}{ExpPow\PYZus{}df}\PY{p}{,}\PY{n}{Weibull\PYZus{}df}\PY{p}{,}\PY{n}{twoDt\PYZus{}df}\PY{p}{,}\PY{n}{Logistic\PYZus{}df}\PY{p}{,}\PY{n}{LogSec\PYZus{}df}\PY{p}{,}\PY{n}{NegExp\PYZus{}df}\PY{p}{]}\PY{p}{)}

\PY{c+c1}{\PYZsh{} Make dataframe to plot}
\PY{n}{heatmap\PYZus{}df} \PY{o}{=} \PY{n}{pd}\PY{o}{.}\PY{n}{DataFrame}\PY{p}{(}\PY{p}{)} 
\PY{n}{heatmap\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n}{kernel\PYZus{}sel\PYZus{}df}\PY{o}{.}\PY{n}{Species}\PY{o}{.}\PY{n}{values}
\PY{n}{heatmap\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Kernel}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n}{kernel\PYZus{}sel\PYZus{}df}\PY{o}{.}\PY{n}{kernel\PYZus{}combo}\PY{o}{.}\PY{n}{values}
\PY{n}{heatmap\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Residuals}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n}{kernel\PYZus{}sel\PYZus{}df}\PY{o}{.}\PY{n}{residuals\PYZus{}scaled}\PY{o}{.}\PY{n}{values}
\PY{n}{heatmap\PYZus{}df}\PY{o}{.}\PY{n}{Residuals}\PY{o}{.}\PY{n}{astype}\PY{p}{(}\PY{n+nb}{float}\PY{p}{)}
\PY{n}{heatmap\PYZus{}df} \PY{o}{=} \PY{n}{heatmap\PYZus{}df}\PY{o}{.}\PY{n}{pivot}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Kernel}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Residuals}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}

\PY{c+c1}{\PYZsh{} Plot heatmap}
\PY{n}{f}\PY{p}{,} \PY{n}{ax} \PY{o}{=} \PY{n}{plt}\PY{o}{.}\PY{n}{subplots}\PY{p}{(}\PY{p}{)}
\PY{n}{f}\PY{o}{.}\PY{n}{set\PYZus{}figheight}\PY{p}{(}\PY{l+m+mf}{3.54}\PY{o}{*}\PY{l+m+mi}{2}\PY{p}{)}
\PY{n}{f}\PY{o}{.}\PY{n}{set\PYZus{}figwidth}\PY{p}{(}\PY{l+m+mf}{3.54}\PY{o}{*}\PY{l+m+mi}{2}\PY{p}{)}
\PY{n}{f}\PY{o}{.}\PY{n}{dpi} \PY{o}{=} \PY{l+m+mi}{300}
\PY{n}{heatmap} \PY{o}{=} \PY{n}{sns}\PY{o}{.}\PY{n}{heatmap}\PY{p}{(}\PY{n}{heatmap\PYZus{}df}\PY{p}{,} \PY{n}{cmap}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{seismic}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{center}\PY{o}{=}\PY{l+m+mf}{0.00}\PY{p}{,} \PY{n}{linewidths}\PY{o}{=}\PY{l+m+mf}{.5}\PY{p}{,} 
                      \PY{n}{cbar\PYZus{}kws}\PY{o}{=}\PY{p}{\PYZob{}}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{shrink}\PY{l+s+s2}{\PYZdq{}}\PY{p}{:} \PY{l+m+mf}{.82}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{label}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Normalized residuals}\PY{l+s+s1}{\PYZsq{}}\PY{p}{\PYZcb{}}\PY{p}{)}
\PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}ylabel}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}xlabel}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}

\PY{c+c1}{\PYZsh{} Export figure   }
\PY{n}{plt}\PY{o}{.}\PY{n}{savefig}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Figure\PYZus{}4.png}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{bbox\PYZus{}inches}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{tight}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{dpi}\PY{o}{=}\PY{l+m+mi}{300}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}

    \begin{center}
    \adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{output_36_0.png}
    \end{center}
    { \hspace*{\fill} \\}
    
    \hypertarget{best-fitted-shape-parameters}{%
\subsection{Best-fitted shape
parameters}\label{best-fitted-shape-parameters}}

We selected the species-specific shape parameter values that
significantly minimized residuals for each kernel function.

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{19}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{c+c1}{\PYZsh{} Calculate absolute residuals}
\PY{n}{newkernels\PYZus{}df} \PY{o}{=} \PY{n}{newkernels\PYZus{}df}\PY{p}{[}\PY{n}{newkernels\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{kernel\PYZus{}fun}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{!=} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{NegExp}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}
\PY{n}{newkernels\PYZus{}df} \PY{o}{=} \PY{n}{newkernels\PYZus{}df}\PY{o}{.}\PY{n}{copy}\PY{p}{(}\PY{p}{)}
\PY{n}{newkernels\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{residuals\PYZus{}abs}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n+nb}{abs}\PY{p}{(}\PY{n}{newkernels\PYZus{}df}\PY{o}{.}\PY{n}{residuals\PYZus{}75ile}\PY{p}{)}

\PY{c+c1}{\PYZsh{} Find the minimum residual per species per kernel}
\PY{n}{species} \PY{o}{=} \PY{n}{newkernels\PYZus{}df}\PY{o}{.}\PY{n}{Species}\PY{o}{.}\PY{n}{unique}\PY{p}{(}\PY{p}{)}
\PY{n}{bestfit\PYZus{}newkernels\PYZus{}df} \PY{o}{=} \PY{n}{newkernels\PYZus{}df}\PY{o}{.}\PY{n}{groupby}\PY{p}{(}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{kernel\PYZus{}fun}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{)}\PY{o}{.}\PY{n}{apply}\PY{p}{(}\PY{n}{min\PYZus{}residual}\PY{p}{)}

\PY{c+c1}{\PYZsh{} Format table for further analysis}
\PY{n}{bestfit\PYZus{}newkernels\PYZus{}df}\PY{o}{.}\PY{n}{drop}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{axis}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{columns}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{inplace}\PY{o}{=}\PY{k+kc}{True}\PY{p}{)}
\PY{n}{bestfit\PYZus{}newkernels\PYZus{}df}\PY{o}{.}\PY{n}{drop}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{kernel\PYZus{}fun}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{axis}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{columns}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{inplace}\PY{o}{=}\PY{k+kc}{True}\PY{p}{)}
\PY{n}{bestfit\PYZus{}newkernels\PYZus{}df} \PY{o}{=} \PY{n}{bestfit\PYZus{}newkernels\PYZus{}df}\PY{o}{.}\PY{n}{reset\PYZus{}index}\PY{p}{(}\PY{p}{)}
\PY{n}{bestfit\PYZus{}newkernels\PYZus{}df}\PY{o}{.}\PY{n}{drop}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{level\PYZus{}2}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{axis}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{columns}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{inplace}\PY{o}{=}\PY{k+kc}{True}\PY{p}{)}
\PY{n}{bestfit\PYZus{}newkernels\PYZus{}df}\PY{o}{.}\PY{n}{drop}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{residuals\PYZus{}scaled}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{axis}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{columns}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{inplace}\PY{o}{=}\PY{k+kc}{True}\PY{p}{)}
\PY{n}{bestfit\PYZus{}newkernels\PYZus{}df}\PY{o}{.}\PY{n}{drop}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{kernel\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{axis}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{columns}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{inplace}\PY{o}{=}\PY{k+kc}{True}\PY{p}{)}
\PY{n}{bestfit\PYZus{}newkernels\PYZus{}df}\PY{o}{.}\PY{n}{drop}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{residuals\PYZus{}abs}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{axis}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{columns}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{inplace}\PY{o}{=}\PY{k+kc}{True}\PY{p}{)}
\PY{n}{bestfit\PYZus{}newkernels\PYZus{}df} \PY{o}{=} \PY{n}{bestfit\PYZus{}newkernels\PYZus{}df}\PY{o}{.}\PY{n}{rename}\PY{p}{(}\PY{n}{columns}\PY{o}{=}\PY{p}{\PYZob{}}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{kernel\PYZus{}fun}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{\PYZcb{}}\PY{p}{)}

\PY{c+c1}{\PYZsh{} Save table}
\PY{n}{bestfit\PYZus{}newkernels\PYZus{}df}\PY{o}{.}\PY{n}{to\PYZus{}csv}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Table\PYZus{}S3.csv}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{sep}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{;}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{index}\PY{o}{=}\PY{k+kc}{False}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}

    \hypertarget{performance-evaluation-of-new-dispersal-kernels}{%
\subsection{Performance evaluation of new dispersal
kernels}\label{performance-evaluation-of-new-dispersal-kernels}}

We evaluated the performance of the new kernels by calculating the error
between simulated and observed migration rates for each species
(residuals) and across species (RMSE). Additionally, we conducted a
one-way ANOVA with post-hoc Tukey's HSD test among errors generated by
newly-added kernels to verify whether one or more fat-tailed kernels
improved the predictions across all species (RMSEs) or at the species
level (residuals).

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{20}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{c+c1}{\PYZsh{} Make dataframe with RMSE and average and standard deviation of species\PYZhy{}specific residuals}
\PY{n}{df\PYZus{}output} \PY{o}{=} \PY{n}{f\PYZus{}rmse\PYZus{}residuals}\PY{p}{(}\PY{n}{bestfit\PYZus{}newkernels\PYZus{}df}\PY{p}{)}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}    
\PY{n}{residuals\PYZus{}df} \PY{o}{=} \PY{n}{f\PYZus{}rmse\PYZus{}residuals}\PY{p}{(}\PY{n}{bestfit\PYZus{}newkernels\PYZus{}df}\PY{p}{)}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}

\PY{c+c1}{\PYZsh{} Export to CSV}
\PY{n}{df\PYZus{}output}\PY{o}{.}\PY{n}{to\PYZus{}csv}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Table\PYZus{}S4.csv}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{sep}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{;}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{index}\PY{o}{=}\PY{k+kc}{False}\PY{p}{)}

\PY{c+c1}{\PYZsh{}\PYZsh{} Species\PYZhy{}specific residuals for the best\PYZhy{}fitted shape parameter of each fat\PYZhy{}tailed kernel}
\PY{c+c1}{\PYZsh{} Make figure}
\PY{n}{fig\PYZus{}out} \PY{o}{=} \PY{n}{make\PYZus{}plot}\PY{p}{(}\PY{n}{residuals\PYZus{}df}\PY{p}{)}

\PY{c+c1}{\PYZsh{} Export figure    }
\PY{n}{fig\PYZus{}out}\PY{o}{.}\PY{n}{savefig}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Figure\PYZus{}5.png}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{dpi}\PY{o}{=}\PY{l+m+mi}{300}\PY{p}{,} \PY{n+nb}{format}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{png}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}

    \begin{center}
    \adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{output_40_0.png}
    \end{center}
    { \hspace*{\fill} \\}
    
    \hypertarget{overall-error-per-kernel-function}{%
\subsection{Overall error per kernel
function}\label{overall-error-per-kernel-function}}

Error across species was calculated as root-mean-square-error (RMSE) was
used to quantify the model performance across species:

\[RMSE=\frac{100}{\overline{obs}}\times \sqrt{\frac{\sum_{i=1}^{n}(sim_i-obs_i)^2}{n}}\]

where \(n\) is the number of species, \(obs\) is the \(75^{th}\)
percentile value in the confidence range of observational values, and
\(\overline{obs}\) is the average across species.

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{21}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{RMSE} \PY{o}{=} \PY{n}{rmse\PYZus{}perc}\PY{p}{(}\PY{n}{best\PYZus{}EVA\PYZus{}df}\PY{o}{.}\PY{n}{sim}\PY{p}{,}\PY{n}{best\PYZus{}EVA\PYZus{}df}\PY{o}{.}\PY{n}{obs\PYZus{}75ile}\PY{p}{,}\PY{n}{best\PYZus{}EVA\PYZus{}df}\PY{o}{.}\PY{n}{obs\PYZus{}75ile}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{p}{)}\PY{p}{)}
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{NegExp RMSE: }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n+nb}{str}\PY{p}{(}\PY{n+nb}{round}\PY{p}{(}\PY{n}{RMSE}\PY{p}{,}\PY{l+m+mi}{2}\PY{p}{)}\PY{p}{)}\PY{p}{)}

\PY{n}{kernels} \PY{o}{=} \PY{n}{bestfit\PYZus{}newkernels\PYZus{}df}\PY{o}{.}\PY{n}{Parameter\PYZus{}combo}\PY{o}{.}\PY{n}{unique}\PY{p}{(}\PY{p}{)}
\PY{k}{for} \PY{n}{kernel} \PY{o+ow}{in} \PY{n}{kernels}\PY{p}{:}
    \PY{n}{kernel\PYZus{}df} \PY{o}{=} \PY{n}{bestfit\PYZus{}newkernels\PYZus{}df}\PY{p}{[}\PY{n}{bestfit\PYZus{}newkernels\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{==}\PY{n}{kernel}\PY{p}{]}
    \PY{n}{RMSE} \PY{o}{=} \PY{n}{rmse\PYZus{}perc}\PY{p}{(}\PY{n}{kernel\PYZus{}df}\PY{o}{.}\PY{n}{SIM}\PY{p}{,}\PY{n}{kernel\PYZus{}df}\PY{o}{.}\PY{n}{OBS\PYZus{}75ile}\PY{p}{,}\PY{n}{kernel\PYZus{}df}\PY{o}{.}\PY{n}{OBS\PYZus{}75ile}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{p}{)}\PY{p}{)}
    \PY{n+nb}{print}\PY{p}{(}\PY{n}{kernel}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ RMSE: }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n+nb}{str}\PY{p}{(}\PY{n+nb}{round}\PY{p}{(}\PY{n}{RMSE}\PY{p}{,}\PY{l+m+mi}{2}\PY{p}{)}\PY{p}{)}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}

    \begin{Verbatim}[commandchars=\\\{\}]
NegExp RMSE: 89.94
ExpPow RMSE: 73.67
LogSec RMSE: 27.26
Logistic RMSE: 48.07
Weibull RMSE: 97.72
twoDt RMSE: 63.19
    \end{Verbatim}

    \hypertarget{select-best-fitted-kernel-per-species}{%
\subsection{Select best-fitted kernel per
species}\label{select-best-fitted-kernel-per-species}}

We selected the kernel function that significantly minimized residuals
for each species.

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{22}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{species} \PY{o}{=} \PY{n}{residuals\PYZus{}df}\PY{o}{.}\PY{n}{Species}\PY{o}{.}\PY{n}{unique}\PY{p}{(}\PY{p}{)}
\PY{n}{df\PYZus{}output}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{residuals\PYZus{}abs}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n}{df\PYZus{}output}\PY{o}{.}\PY{n}{residuals\PYZus{}mean}\PY{o}{.}\PY{n}{abs}\PY{p}{(}\PY{p}{)}

\PY{n}{rmse\PYZus{}all\PYZus{}df} \PY{o}{=} \PY{n}{pd}\PY{o}{.}\PY{n}{DataFrame}\PY{p}{(}\PY{p}{)}
\PY{k}{for} \PY{n}{sp} \PY{o+ow}{in} \PY{n}{species} \PY{p}{:} 
    \PY{n}{sp\PYZus{}res} \PY{o}{=} \PY{n}{df\PYZus{}output}\PY{p}{[}\PY{n}{df\PYZus{}output}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{n}{sp}\PY{p}{]}
    \PY{n}{sp\PYZus{}df} \PY{o}{=} \PY{n}{residuals\PYZus{}df}\PY{p}{[}\PY{n}{residuals\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{n}{sp}\PY{p}{]}
    
    \PY{c+c1}{\PYZsh{} RMSE\PYZpc{} of each kernel}
    \PY{n}{rmse\PYZus{}df} \PY{o}{=} \PY{n}{pd}\PY{o}{.}\PY{n}{DataFrame}\PY{p}{(}\PY{p}{)}
    \PY{n}{rmse\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n}{sp}
    \PY{n}{kernels} \PY{o}{=} \PY{n}{sp\PYZus{}res}\PY{o}{.}\PY{n}{Parameter\PYZus{}combo}
    \PY{n}{rmse\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{kernel}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n}{kernels}
    \PY{n}{rmse\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{shape\PYZus{}par}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n}{sp\PYZus{}res}\PY{o}{.}\PY{n}{shape\PYZus{}par}
    \PY{n}{rmse\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{rmse}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{l+m+mf}{0.}
    \PY{n}{rmse\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n}{sp}
    \PY{k}{for} \PY{n}{kernel} \PY{o+ow}{in} \PY{n}{kernels}\PY{p}{:}
        \PY{n}{kernel\PYZus{}df} \PY{o}{=} \PY{n}{sp\PYZus{}df}\PY{p}{[}\PY{n}{sp\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{n}{kernel}\PY{p}{]}
        \PY{n}{RMSE} \PY{o}{=} \PY{n}{rmse\PYZus{}perc}\PY{p}{(}\PY{n}{kernel\PYZus{}df}\PY{o}{.}\PY{n}{sim}\PY{p}{,}\PY{n}{kernel\PYZus{}df}\PY{o}{.}\PY{n}{obs}\PY{p}{,}\PY{n}{kernel\PYZus{}df}\PY{o}{.}\PY{n}{obs}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{p}{)}\PY{p}{)}
        \PY{n}{rmse\PYZus{}df}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{n}{rmse\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{kernel}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{n}{kernel}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{rmse}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n}{RMSE}

    \PY{n+nb}{print}\PY{p}{(}\PY{n}{sp}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ \PYZhy{} Kernel ranking [RMSE}\PY{l+s+s1}{\PYZpc{}}\PY{l+s+s1}{]}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}

    \PY{c+c1}{\PYZsh{} Rank kernel performance based on absolute residual value}
    \PY{n}{kernels\PYZus{}rank} \PY{o}{=} \PY{n}{sp\PYZus{}res}\PY{o}{.}\PY{n}{sort\PYZus{}values}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{residuals\PYZus{}abs}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{n}{ascending}\PY{o}{=}\PY{k+kc}{True}\PY{p}{)}\PY{o}{.}\PY{n}{reset\PYZus{}index}\PY{p}{(}\PY{n}{drop}\PY{o}{=}\PY{k+kc}{True}\PY{p}{)}\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mse\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{kernel}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{==}\PY{n}{kernels\PYZus{}rank}\PY{p}{[}\PY{l+m+mi}{3}\PY{p}{]}\PY{p}{]}\PY{o}{.}\PY{n}{rmse}\PY{o}{.}\PY{n}{values}\PY{o}{.}\PY{n}{round}\PY{p}{(}\PY{l+m+mi}{2}\PY{p}{)}\PY{p}{)}\PY{o}{+}
          \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ | 5: }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n+nb}{str}\PY{p}{(}\PY{n}{kernels\PYZus{}rank}\PY{p}{[}\PY{l+m+mi}{4}\PY{p}{]}\PY{p}{)}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n+nb}{str}\PY{p}{(}\PY{n}{rmse\PYZus{}df}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{n}{rmse\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{kernel}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{==}\PY{n}{kernels\PYZus{}rank}\PY{p}{[}\PY{l+m+mi}{4}\PY{p}{]}\PY{p}{]}\PY{o}{.}\PY{n}{rmse}\PY{o}{.}\PY{n}{values}\PY{o}{.}\PY{n}{round}\PY{p}{(}\PY{l+m+mi}{2}\PY{p}{)}\PY{p}{)}\PY{p}{)}    
    
    \PY{c+c1}{\PYZsh{} Select best kernel}
    \PY{n}{best\PYZus{}kernel\PYZus{}sp} \PY{o}{=} \PY{n}{rmse\PYZus{}df}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{n}{rmse\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{kernel}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{==}\PY{n}{kernels\PYZus{}rank}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{]}
    \PY{n}{sim\PYZus{}value} \PY{o}{=} \PY{n}{sp\PYZus{}df}\PY{p}{[}\PY{n}{sp\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{==}\PY{n}{kernels\PYZus{}rank}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{]}\PY{o}{.}\PY{n}{sim}\PY{o}{.}\PY{n}{unique}\PY{p}{(}\PY{p}{)}
    \PY{n}{obs\PYZus{}values} \PY{o}{=} \PY{n}{sp\PYZus{}df}\PY{p}{[}\PY{n}{sp\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{==}\PY{n}{kernels\PYZus{}rank}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{]}\PY{o}{.}\PY{n}{obs}
    \PY{n}{obs\PYZus{}75ile} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{percentile}\PY{p}{(}\PY{n}{obs\PYZus{}values}\PY{p}{,} \PY{l+m+mi}{75}\PY{p}{)}
    \PY{n}{best\PYZus{}kernel\PYZus{}sp} \PY{o}{=} \PY{n}{best\PYZus{}kernel\PYZus{}sp}\PY{o}{.}\PY{n}{copy}\PY{p}{(}\PY{p}{)}
    \PY{n}{best\PYZus{}kernel\PYZus{}sp}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{sim}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n+nb}{float}\PY{p}{(}\PY{n}{sim\PYZus{}value}\PY{p}{)}
    \PY{n}{best\PYZus{}kernel\PYZus{}sp}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{obs\PYZus{}75ile}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n+nb}{float}\PY{p}{(}\PY{n}{obs\PYZus{}75ile}\PY{p}{)}
    \PY{n}{rmse\PYZus{}all\PYZus{}df} \PY{o}{=} \PY{n}{pd}\PY{o}{.}\PY{n}{concat}\PY{p}{(}\PY{p}{[}\PY{n}{rmse\PYZus{}all\PYZus{}df}\PY{p}{,}\PY{n}{best\PYZus{}kernel\PYZus{}sp}\PY{p}{]}\PY{p}{)}
\PY{n}{rmse\PYZus{}all\PYZus{}df} \PY{o}{=} \PY{n}{rmse\PYZus{}all\PYZus{}df}\PY{o}{.}\PY{n}{reset\PYZus{}index}\PY{p}{(}\PY{p}{)}
\PY{n}{rmse\PYZus{}all\PYZus{}df}\PY{o}{.}\PY{n}{drop}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{index}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{axis}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{columns}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{inplace}\PY{o}{=}\PY{k+kc}{True}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}

    \begin{Verbatim}[commandchars=\\\{\}]
Abi\_alb - Kernel ranking [RMSE\%]
1: twoDt [7.99] | 2: LogSec [9.43] | 3: Logistic [14.98] | 4: ExpPow [65.97] |
5: Weibull [84.5]
Bet\_pen - Kernel ranking [RMSE\%]
1: LogSec [19.71] | 2: ExpPow [47.28] | 3: twoDt [52.81] | 4: Weibull [89.8] |
5: Logistic [121.58]
Bet\_pub - Kernel ranking [RMSE\%]
1: LogSec [19.71] | 2: ExpPow [44.82] | 3: twoDt [52.81] | 4: Weibull [89.8] |
5: Logistic [121.58]
Car\_bet - Kernel ranking [RMSE\%]
1: Logistic [19.63] | 2: LogSec [32.96] | 3: ExpPow [49.34] | 4: twoDt [80.98] |
5: Weibull [84.48]
Cor\_ave - Kernel ranking [RMSE\%]
1: LogSec [12.21] | 2: Logistic [12.21] | 3: ExpPow [17.51] | 4: twoDt [28.94] |
5: Weibull [59.52]
Fag\_syl - Kernel ranking [RMSE\%]
1: LogSec [14.19] | 2: Logistic [16.26] | 3: twoDt [18.03] | 4: ExpPow [74.06] |
5: Weibull [80.79]
Fra\_exc - Kernel ranking [RMSE\%]
1: ExpPow [25.75] | 2: twoDt [25.83] | 3: LogSec [30.06] | 4: Logistic [45.77] |
5: Weibull [53.95]
Pic\_abi - Kernel ranking [RMSE\%]
1: twoDt [32.9] | 2: Logistic [38.5] | 3: LogSec [42.21] | 4: ExpPow [58.97] |
5: Weibull [76.99]
Pic\_sit - Kernel ranking [RMSE\%]
1: ExpPow [31.15] | 2: Logistic [37.45] | 3: LogSec [45.69] | 4: twoDt [49.17] |
5: Weibull [72.51]
Pin\_hal - Kernel ranking [RMSE\%]
1: Logistic [29.2] | 2: LogSec [48.4] | 3: twoDt [73.25] | 4: ExpPow [101.17] |
5: Weibull [103.02]
Pin\_syl - Kernel ranking [RMSE\%]
1: Logistic [34.32] | 2: LogSec [48.32] | 3: ExpPow [70.03] | 4: twoDt [70.3] |
5: Weibull [97.29]
Que\_coc - Kernel ranking [RMSE\%]
1: Logistic [21.11] | 2: LogSec [23.4] | 3: twoDt [34.35] | 4: Weibull [90.15] |
5: ExpPow [90.65]
Que\_ile - Kernel ranking [RMSE\%]
1: Logistic [15.25] | 2: LogSec [19.53] | 3: twoDt [72.91] | 4: ExpPow [85.21] |
5: Weibull [91.14]
Que\_pub - Kernel ranking [RMSE\%]
1: LogSec [14.69] | 2: Logistic [22.81] | 3: twoDt [25.82] | 4: ExpPow [94.6] |
5: Weibull [101.04]
Que\_rob - Kernel ranking [RMSE\%]
1: LogSec [19.53] | 2: Logistic [24.8] | 3: twoDt [39.18] | 4: ExpPow [92.38] |
5: Weibull [92.38]
Til\_cor - Kernel ranking [RMSE\%]
1: ExpPow [31.41] | 2: LogSec [35.82] | 3: twoDt [57.41] | 4: Weibull [79.82] |
5: Logistic [123.11]
Ulm\_gla - Kernel ranking [RMSE\%]
1: LogSec [17.12] | 2: Logistic [24.42] | 3: twoDt [26.16] | 4: ExpPow [71.52] |
5: Weibull [86.66]
    \end{Verbatim}

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{23}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{good\PYZus{}est} \PY{o}{=} \PY{n}{df\PYZus{}output}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{p}{(}\PY{n}{df\PYZus{}output}\PY{o}{.}\PY{n}{residuals\PYZus{}mean} \PY{o}{\PYZlt{}} \PY{l+m+mf}{10.}\PY{p}{)} \PY{o}{\PYZam{}} \PY{p}{(}\PY{n}{df\PYZus{}output}\PY{o}{.}\PY{n}{residuals\PYZus{}mean} \PY{o}{\PYZgt{}} \PY{o}{\PYZhy{}}\PY{l+m+mf}{10.}\PY{p}{)}\PY{p}{]}
\PY{n}{bad\PYZus{}est} \PY{o}{=} \PY{n}{df\PYZus{}output}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{p}{(}\PY{n}{df\PYZus{}output}\PY{o}{.}\PY{n}{residuals\PYZus{}mean} \PY{o}{\PYZgt{}} \PY{l+m+mf}{10.}\PY{p}{)} \PY{o}{|} \PY{p}{(}\PY{n}{df\PYZus{}output}\PY{o}{.}\PY{n}{residuals\PYZus{}mean} \PY{o}{\PYZlt{}} \PY{o}{\PYZhy{}}\PY{l+m+mf}{10.}\PY{p}{)}\PY{p}{]}
\PY{n}{over\PYZus{}est} \PY{o}{=} \PY{n}{bad\PYZus{}est}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{n}{bad\PYZus{}est}\PY{o}{.}\PY{n}{residuals\PYZus{}mean} \PY{o}{\PYZgt{}} \PY{l+m+mf}{0.}\PY{p}{]}
\PY{n}{under\PYZus{}est} \PY{o}{=} \PY{n}{bad\PYZus{}est}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{n}{bad\PYZus{}est}\PY{o}{.}\PY{n}{residuals\PYZus{}mean} \PY{o}{\PYZlt{}} \PY{l+m+mf}{0.}\PY{p}{]}

\PY{n}{good\PYZus{}sp} \PY{o}{=} \PY{n}{good\PYZus{}est}\PY{o}{.}\PY{n}{Species}\PY{o}{.}\PY{n}{unique}\PY{p}{(}\PY{p}{)}
\PY{k}{for} \PY{n}{sp} \PY{o+ow}{in} \PY{n}{good\PYZus{}sp} \PY{p}{:}
    \PY{n}{sp\PYZus{}sub} \PY{o}{=} \PY{n}{good\PYZus{}est}\PY{p}{[}\PY{n}{good\PYZus{}est}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{n}{sp}\PY{p}{]}
    \PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Good estimates: }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n}{sp}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ for }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n+nb}{str}\PY{p}{(}\PY{n}{sp\PYZus{}sub}\PY{o}{.}\PY{n}{Parameter\PYZus{}combo}\PY{o}{.}\PY{n}{values}\PY{o}{.}\PY{n}{tolist}\PY{p}{(}\PY{p}{)}\PY{p}{)}\PY{p}{)}

\PY{n}{over\PYZus{}sp} \PY{o}{=} \PY{n}{over\PYZus{}est}\PY{o}{.}\PY{n}{Species}\PY{o}{.}\PY{n}{unique}\PY{p}{(}\PY{p}{)}
\PY{k}{for} \PY{n}{sp} \PY{o+ow}{in} \PY{n}{over\PYZus{}sp} \PY{p}{:}
    \PY{n}{sp\PYZus{}sub} \PY{o}{=} \PY{n}{over\PYZus{}est}\PY{p}{[}\PY{n}{over\PYZus{}est}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{n}{sp}\PY{p}{]}
    \PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Over\PYZhy{}estimations: }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n}{sp}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ for }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n+nb}{str}\PY{p}{(}\PY{n}{sp\PYZus{}sub}\PY{o}{.}\PY{n}{Parameter\PYZus{}combo}\PY{o}{.}\PY{n}{values}\PY{o}{.}\PY{n}{tolist}\PY{p}{(}\PY{p}{)}\PY{p}{)}\PY{p}{)}
    
\PY{n}{under\PYZus{}sp} \PY{o}{=} \PY{n}{under\PYZus{}est}\PY{o}{.}\PY{n}{Species}\PY{o}{.}\PY{n}{unique}\PY{p}{(}\PY{p}{)}
\PY{k}{for} \PY{n}{sp} \PY{o+ow}{in} \PY{n}{under\PYZus{}sp} \PY{p}{:}
    \PY{n}{sp\PYZus{}sub} \PY{o}{=} \PY{n}{under\PYZus{}est}\PY{p}{[}\PY{n}{under\PYZus{}est}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{n}{sp}\PY{p}{]}
    \PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Under\PYZhy{}estimations: }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n}{sp}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ for }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n+nb}{str}\PY{p}{(}\PY{n}{sp\PYZus{}sub}\PY{o}{.}\PY{n}{Parameter\PYZus{}combo}\PY{o}{.}\PY{n}{values}\PY{o}{.}\PY{n}{tolist}\PY{p}{(}\PY{p}{)}\PY{p}{)}\PY{p}{)}

\PY{c+c1}{\PYZsh{} Calculate overall underestimation error (RMSE\PYZpc{})}
\PY{n}{mean\PYZus{}MIN} \PY{o}{=} \PY{n}{under\PYZus{}est}\PY{p}{[}\PY{n}{under\PYZus{}est}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{all\PYZus{}MIN}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{.}\PY{n}{residuals\PYZus{}mean}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{p}{)}
\PY{n}{std\PYZus{}MIN} \PY{o}{=} \PY{n}{under\PYZus{}est}\PY{p}{[}\PY{n}{under\PYZus{}est}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{all\PYZus{}MIN}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{.}\PY{n}{residuals\PYZus{}mean}\PY{o}{.}\PY{n}{std}\PY{p}{(}\PY{p}{)}
\PY{n}{mean\PYZus{}MAX} \PY{o}{=} \PY{n}{under\PYZus{}est}\PY{p}{[}\PY{n}{under\PYZus{}est}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{all\PYZus{}MAX}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{.}\PY{n}{residuals\PYZus{}mean}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{p}{)}
\PY{n}{std\PYZus{}MAX} \PY{o}{=} \PY{n}{under\PYZus{}est}\PY{p}{[}\PY{n}{under\PYZus{}est}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{all\PYZus{}MAX}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{.}\PY{n}{residuals\PYZus{}mean}\PY{o}{.}\PY{n}{std}\PY{p}{(}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}

    \begin{Verbatim}[commandchars=\\\{\}]
Good estimates: Abi\_alb for ['LogSec', 'twoDt']
Good estimates: Car\_bet for ['Logistic']
Good estimates: Cor\_ave for ['LogSec', 'Logistic']
Good estimates: Fag\_syl for ['LogSec']
Good estimates: Fra\_exc for ['ExpPow', 'twoDt']
Good estimates: Pic\_sit for ['ExpPow']
Good estimates: Que\_ile for ['Logistic']
Good estimates: Que\_pub for ['LogSec']
Good estimates: Til\_cor for ['ExpPow']
Good estimates: Ulm\_gla for ['LogSec']
Over-estimations: Abi\_alb for ['Logistic']
Over-estimations: Bet\_pen for ['ExpPow', 'LogSec', 'Logistic']
Over-estimations: Bet\_pub for ['ExpPow', 'LogSec', 'Logistic']
Over-estimations: Car\_bet for ['LogSec']
Over-estimations: Cor\_ave for ['ExpPow']
Over-estimations: Fag\_syl for ['Logistic', 'twoDt']
Over-estimations: Fra\_exc for ['LogSec', 'Logistic']
Over-estimations: Pic\_abi for ['LogSec', 'Logistic', 'twoDt']
Over-estimations: Pic\_sit for ['LogSec', 'Logistic', 'twoDt']
Over-estimations: Pin\_syl for ['LogSec']
Over-estimations: Que\_coc for ['LogSec', 'Logistic', 'twoDt']
Over-estimations: Que\_ile for ['LogSec', 'twoDt']
Over-estimations: Que\_rob for ['LogSec', 'Logistic']
Over-estimations: Til\_cor for ['LogSec', 'Logistic', 'twoDt']
Over-estimations: Ulm\_gla for ['twoDt']
Under-estimations: Abi\_alb for ['ExpPow', 'Weibull']
Under-estimations: Bet\_pen for ['Weibull', 'twoDt']
Under-estimations: Bet\_pub for ['Weibull', 'twoDt']
Under-estimations: Car\_bet for ['ExpPow', 'Weibull', 'twoDt']
Under-estimations: Cor\_ave for ['Weibull', 'twoDt']
Under-estimations: Fag\_syl for ['ExpPow', 'Weibull']
Under-estimations: Fra\_exc for ['Weibull']
Under-estimations: Pic\_abi for ['ExpPow', 'Weibull']
Under-estimations: Pic\_sit for ['Weibull']
Under-estimations: Pin\_hal for ['ExpPow', 'LogSec', 'Logistic', 'Weibull',
'twoDt']
Under-estimations: Pin\_syl for ['ExpPow', 'Logistic', 'Weibull', 'twoDt']
Under-estimations: Que\_coc for ['ExpPow', 'Weibull']
Under-estimations: Que\_ile for ['ExpPow', 'Weibull']
Under-estimations: Que\_pub for ['ExpPow', 'Logistic', 'Weibull', 'twoDt']
Under-estimations: Que\_rob for ['ExpPow', 'Weibull', 'twoDt']
Under-estimations: Til\_cor for ['Weibull']
Under-estimations: Ulm\_gla for ['ExpPow', 'Logistic', 'Weibull']
    \end{Verbatim}

    \hypertarget{test-species-specific-kernel-performance}{%
\subsection{Test species-specific kernel
performance}\label{test-species-specific-kernel-performance}}

We conducted a one-way ANOVA with post-hoc Tukey's HSD test among
residuals generated by the newly-added kernels to verify whether one or
more fat-tailed kernels improved the predictions at the species level.

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{24}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{k}{for} \PY{n}{sp} \PY{o+ow}{in} \PY{n}{species} \PY{p}{:} 
    \PY{n}{sp\PYZus{}df} \PY{o}{=} \PY{n}{residuals\PYZus{}df}\PY{p}{[}\PY{n}{residuals\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{n}{sp}\PY{p}{]}
    
    \PY{c+c1}{\PYZsh{} Perform one\PYZhy{}way ANOVA}
    \PY{n}{twoDt\PYZus{}res} \PY{o}{=} \PY{n}{sp\PYZus{}df}\PY{p}{[}\PY{n}{sp\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{2Dt}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{.}\PY{n}{residuals}
    \PY{n}{exppow\PYZus{}res} \PY{o}{=} \PY{n}{sp\PYZus{}df}\PY{p}{[}\PY{n}{sp\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ExpPow}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{.}\PY{n}{residuals}
    \PY{n}{logsec\PYZus{}res} \PY{o}{=} \PY{n}{sp\PYZus{}df}\PY{p}{[}\PY{n}{sp\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{LogSec}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{.}\PY{n}{residuals}
    \PY{n}{weibull\PYZus{}res} \PY{o}{=} \PY{n}{sp\PYZus{}df}\PY{p}{[}\PY{n}{sp\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Weibull}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{.}\PY{n}{residuals}
    \PY{n}{logistic\PYZus{}res} \PY{o}{=} \PY{n}{sp\PYZus{}df}\PY{p}{[}\PY{n}{sp\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Logistic}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{.}\PY{n}{residuals}
    \PY{n}{stats}\PY{o}{.}\PY{n}{f\PYZus{}oneway}\PY{p}{(}\PY{n}{twoDt\PYZus{}res}\PY{p}{,}\PY{n}{exppow\PYZus{}res}\PY{p}{,}\PY{n}{logsec\PYZus{}res}\PY{p}{,}\PY{n}{logistic\PYZus{}res}\PY{p}{,}\PY{n}{weibull\PYZus{}res}\PY{p}{)}

    \PY{c+c1}{\PYZsh{} Perform Tukey\PYZsq{}s test}
    \PY{n}{tukey} \PY{o}{=} \PY{n}{pairwise\PYZus{}tukeyhsd}\PY{p}{(}\PY{n}{endog}\PY{o}{=}\PY{n}{sp\PYZus{}df}\PY{o}{.}\PY{n}{residuals}\PY{p}{,}
                              \PY{n}{groups}\PY{o}{=}\PY{n}{sp\PYZus{}df}\PY{o}{.}\PY{n}{Parameter\PYZus{}combo}\PY{p}{,}
                              \PY{n}{alpha}\PY{o}{=}\PY{l+m+mf}{0.05}\PY{p}{)}
    \PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{=== }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n}{sp}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ ===}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
    \PY{n+nb}{print}\PY{p}{(}\PY{n}{tukey}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}

    \begin{Verbatim}[commandchars=\\\{\}]
=== Abi\_alb ===
    Multiple Comparison of Means - Tukey HSD, FWER=0.05
===========================================================
 group1   group2  meandiff p-adj    lower    upper   reject
-----------------------------------------------------------
  ExpPow   LogSec  57.9235  0.001   55.0046  60.8424   True
  ExpPow Logistic  79.7814  0.001   76.8625  82.7004   True
  ExpPow  Weibull -18.5792  0.001  -21.4982 -15.6603   True
  ExpPow    twoDt   59.745  0.001   56.8261  62.6639   True
  LogSec Logistic  21.8579  0.001    18.939  24.7769   True
  LogSec  Weibull -76.5027  0.001  -79.4217 -73.5838   True
  LogSec    twoDt   1.8215 0.4283   -1.0974   4.7404  False
Logistic  Weibull -98.3607  0.001 -101.2796 -95.4417   True
Logistic    twoDt -20.0364  0.001  -22.9554 -17.1175   True
 Weibull    twoDt  78.3242  0.001   75.4053  81.2432   True
-----------------------------------------------------------
=== Bet\_pen ===
    Multiple Comparison of Means - Tukey HSD, FWER=0.05
============================================================
 group1   group2   meandiff p-adj   lower     upper   reject
------------------------------------------------------------
  ExpPow   LogSec  -29.7237 0.001  -32.4147  -27.0327   True
  ExpPow Logistic   75.1307 0.001   72.4397   77.8217   True
  ExpPow  Weibull -135.0261 0.001 -137.7171 -132.3351   True
  ExpPow    twoDt  -97.5355 0.001 -100.2265  -94.8445   True
  LogSec Logistic  104.8544 0.001  102.1634  107.5454   True
  LogSec  Weibull -105.3025 0.001 -107.9935 -102.6115   True
  LogSec    twoDt  -67.8118 0.001  -70.5028  -65.1208   True
Logistic  Weibull -210.1568 0.001 -212.8478 -207.4658   True
Logistic    twoDt -172.6662 0.001 -175.3572 -169.9752   True
 Weibull    twoDt   37.4907 0.001   34.7997   40.1817   True
------------------------------------------------------------
=== Bet\_pub ===
    Multiple Comparison of Means - Tukey HSD, FWER=0.05
============================================================
 group1   group2   meandiff p-adj   lower     upper   reject
------------------------------------------------------------
  ExpPow   LogSec  -27.1845 0.001  -29.8755  -24.4935   True
  ExpPow Logistic   77.6699 0.001   74.9789   80.3609   True
  ExpPow  Weibull -132.4869 0.001 -135.1779 -129.7959   True
  ExpPow    twoDt  -94.9963 0.001  -97.6873  -92.3053   True
  LogSec Logistic  104.8544 0.001  102.1634  107.5454   True
  LogSec  Weibull -105.3025 0.001 -107.9935 -102.6115   True
  LogSec    twoDt  -67.8118 0.001  -70.5028  -65.1208   True
Logistic  Weibull -210.1568 0.001 -212.8478 -207.4658   True
Logistic    twoDt -172.6662 0.001 -175.3572 -169.9752   True
 Weibull    twoDt   37.4907 0.001   34.7997   40.1817   True
------------------------------------------------------------
=== Car\_bet ===
     Multiple Comparison of Means - Tukey HSD, FWER=0.05
=============================================================
 group1   group2   meandiff p-adj    lower     upper   reject
-------------------------------------------------------------
  ExpPow   LogSec   72.1815  0.001   68.8534   75.5095   True
  ExpPow Logistic   49.2328  0.001   45.9047   52.5609   True
  ExpPow  Weibull  -36.8245  0.001  -40.1526  -33.4965   True
  ExpPow    twoDt  -33.2221  0.001  -36.5502  -29.8941   True
  LogSec Logistic  -22.9486  0.001  -26.2767  -19.6205   True
  LogSec  Weibull  -109.006  0.001 -112.3341 -105.6779   True
  LogSec    twoDt -105.4036  0.001 -108.7317 -102.0755   True
Logistic  Weibull  -86.0574  0.001  -89.3855  -82.7293   True
Logistic    twoDt   -82.455  0.001  -85.7831  -79.1269   True
 Weibull    twoDt    3.6024 0.0262    0.2743    6.9305   True
-------------------------------------------------------------
=== Cor\_ave ===
   Multiple Comparison of Means - Tukey HSD, FWER=0.05
=========================================================
 group1   group2  meandiff p-adj  lower    upper   reject
---------------------------------------------------------
  ExpPow   LogSec -17.1269 0.001 -19.1232 -15.1305   True
  ExpPow Logistic -17.1269 0.001 -19.1232 -15.1305   True
  ExpPow  Weibull -71.5486 0.001 -73.5449 -69.5523   True
  ExpPow    twoDt -39.6959 0.001 -41.6922 -37.6996   True
  LogSec Logistic      0.0   0.9  -1.9963   1.9963  False
  LogSec  Weibull -54.4218 0.001 -56.4181 -52.4254   True
  LogSec    twoDt  -22.569 0.001 -24.5654 -20.5727   True
Logistic  Weibull -54.4218 0.001 -56.4181 -52.4254   True
Logistic    twoDt  -22.569 0.001 -24.5654 -20.5727   True
 Weibull    twoDt  31.8527 0.001  29.8564  33.8491   True
---------------------------------------------------------
=== Fag\_syl ===
   Multiple Comparison of Means - Tukey HSD, FWER=0.05
==========================================================
 group1   group2  meandiff p-adj   lower    upper   reject
----------------------------------------------------------
  ExpPow   LogSec  81.3627  0.001  76.8605   85.865   True
  ExpPow Logistic  84.5691  0.001  80.0669  89.0714   True
  ExpPow  Weibull  -6.8136  0.001 -11.3159  -2.3114   True
  ExpPow    twoDt  86.9739  0.001  82.4717  91.4762   True
  LogSec Logistic   3.2064 0.2926  -1.2958   7.7087  False
  LogSec  Weibull -88.1764  0.001 -92.6786 -83.6741   True
  LogSec    twoDt   5.6112 0.0062    1.109  10.1135   True
Logistic  Weibull -91.3828  0.001  -95.885 -86.8805   True
Logistic    twoDt   2.4048 0.5758  -2.0974    6.907  False
 Weibull    twoDt  93.7876  0.001  89.2853  98.2898   True
----------------------------------------------------------
=== Fra\_exc ===
   Multiple Comparison of Means - Tukey HSD, FWER=0.05
=========================================================
 group1   group2  meandiff p-adj  lower    upper   reject
---------------------------------------------------------
  ExpPow   LogSec  10.0143 0.001   4.4796  15.5491   True
  ExpPow Logistic  31.4735 0.001  25.9388  37.0083   True
  ExpPow  Weibull -54.9356 0.001 -60.4704 -49.4009   True
  ExpPow    twoDt -14.3062 0.001 -19.8409  -8.7714   True
  LogSec Logistic  21.4592 0.001  15.9245   26.994   True
  LogSec  Weibull -64.9499 0.001 -70.4847 -59.4152   True
  LogSec    twoDt -24.3205 0.001 -29.8552 -18.7857   True
Logistic  Weibull -86.4092 0.001 -91.9439 -80.8744   True
Logistic    twoDt -45.7797 0.001 -51.3144 -40.2449   True
 Weibull    twoDt  40.6295 0.001  35.0947  46.1642   True
---------------------------------------------------------
=== Pic\_abi ===
    \end{Verbatim}

    \begin{Verbatim}[commandchars=\\\{\}]
C:\textbackslash{}Users\textbackslash{}zani\textbackslash{}Anaconda3\textbackslash{}envs\textbackslash{}LPJGM\_uncertainty\textbackslash{}lib\textbackslash{}site-
packages\textbackslash{}scipy\textbackslash{}stats\textbackslash{}stats.py:3621: F\_onewayBadInputSizesWarning: at least one
input has length 0
  warnings.warn(F\_onewayBadInputSizesWarning('at least one input '
    \end{Verbatim}

    \begin{Verbatim}[commandchars=\\\{\}]

    Multiple Comparison of Means - Tukey HSD, FWER=0.05
===========================================================
 group1   group2  meandiff p-adj    lower    upper   reject
-----------------------------------------------------------
  ExpPow   LogSec  78.5824  0.001   72.1463  85.0186   True
  ExpPow Logistic  72.7273  0.001   66.2911  79.1634   True
  ExpPow  Weibull  -20.339  0.001  -26.7751 -13.9029   True
  ExpPow    twoDt  60.7088  0.001   54.2727  67.1449   True
  LogSec Logistic  -5.8552 0.0945  -12.2913    0.581  False
  LogSec  Weibull -98.9214  0.001 -105.3575 -92.4853   True
  LogSec    twoDt -17.8737  0.001  -24.3098 -11.4375   True
Logistic  Weibull -93.0663  0.001  -99.5024 -86.6301   True
Logistic    twoDt -12.0185  0.001  -18.4546  -5.5824   True
 Weibull    twoDt  81.0478  0.001   74.6116  87.4839   True
-----------------------------------------------------------
=== Pic\_sit ===
    Multiple Comparison of Means - Tukey HSD, FWER=0.05
===========================================================
 group1   group2  meandiff p-adj    lower    upper   reject
-----------------------------------------------------------
  ExpPow   LogSec  32.6656  0.001   26.2295  39.1018   True
  ExpPow Logistic  20.0308  0.001   13.5947  26.4669   True
  ExpPow  Weibull -66.2558  0.001  -72.6919 -59.8197   True
  ExpPow    twoDt  37.2881  0.001    30.852  43.7243   True
  LogSec Logistic -12.6348  0.001  -19.0709  -6.1987   True
  LogSec  Weibull -98.9214  0.001 -105.3575 -92.4853   True
  LogSec    twoDt   4.6225 0.2857   -1.8136  11.0586  False
Logistic  Weibull -86.2866  0.001  -92.7227 -79.8505   True
Logistic    twoDt  17.2573  0.001   10.8212  23.6934   True
 Weibull    twoDt 103.5439  0.001   97.1078   109.98   True
-----------------------------------------------------------
=== Pin\_hal ===
   Multiple Comparison of Means - Tukey HSD, FWER=0.05
==========================================================
 group1   group2  meandiff p-adj   lower    upper   reject
----------------------------------------------------------
  ExpPow   LogSec  56.5031  0.001  53.3168  59.6894   True
  ExpPow Logistic  82.6108  0.001  79.4245  85.7971   True
  ExpPow  Weibull  -1.9057 0.4776   -5.092   1.2806  False
  ExpPow    twoDt  29.1567  0.001  25.9704   32.343   True
  LogSec Logistic  26.1077  0.001  22.9214   29.294   True
  LogSec  Weibull -58.4088  0.001 -61.5951 -55.2225   True
  LogSec    twoDt -27.3464  0.001 -30.5327 -24.1601   True
Logistic  Weibull -84.5164  0.001 -87.7027 -81.3301   True
Logistic    twoDt  -53.454  0.001 -56.6403 -50.2677   True
 Weibull    twoDt  31.0624  0.001  27.8761  34.2487   True
----------------------------------------------------------
=== Pin\_syl ===
    Multiple Comparison of Means - Tukey HSD, FWER=0.05
============================================================
 group1   group2   meandiff p-adj   lower     upper   reject
------------------------------------------------------------
  ExpPow   LogSec  107.0033 0.001   103.817  110.1896   True
  ExpPow Logistic   41.7342 0.001   38.5479   44.9205   True
  ExpPow  Weibull   -28.585 0.001  -31.7713  -25.3987   True
  ExpPow    twoDt   -0.2859   0.9   -3.4721    2.9004  False
  LogSec Logistic  -65.2692 0.001  -68.4555  -62.0829   True
  LogSec  Weibull -135.5884 0.001 -138.7747 -132.4021   True
  LogSec    twoDt -107.2892 0.001 -110.4755 -104.1029   True
Logistic  Weibull  -70.3192 0.001  -73.5055  -67.1329   True
Logistic    twoDt    -42.02 0.001  -45.2063  -38.8337   True
 Weibull    twoDt   28.2992 0.001   25.1129   31.4855   True
------------------------------------------------------------
=== Que\_coc ===
     Multiple Comparison of Means - Tukey HSD, FWER=0.05
=============================================================
 group1   group2   meandiff p-adj    lower     upper   reject
-------------------------------------------------------------
  ExpPow   LogSec  107.8849  0.001  103.9256  111.8441   True
  ExpPow Logistic  104.8811  0.001  100.9219  108.8403   True
  ExpPow  Weibull    0.5006    0.9   -3.4586    4.4599  False
  ExpPow    twoDt  120.6508  0.001  116.6916    124.61   True
  LogSec Logistic   -3.0038 0.2326    -6.963    0.9555  False
  LogSec  Weibull -107.3842  0.001 -111.3435  -103.425   True
  LogSec    twoDt    12.766  0.001    8.8067   16.7252   True
Logistic  Weibull -104.3805  0.001 -108.3397 -100.4212   True
Logistic    twoDt   15.7697  0.001   11.8105   19.7289   True
 Weibull    twoDt  120.1502  0.001   116.191  124.1094   True
-------------------------------------------------------------
=== Que\_ile ===
    Multiple Comparison of Means - Tukey HSD, FWER=0.05
===========================================================
 group1   group2   meandiff p-adj   lower    upper   reject
-----------------------------------------------------------
  ExpPow   LogSec   97.1214 0.001   93.1622 101.0806   True
  ExpPow Logistic   88.8611 0.001   84.9018  92.8203   True
  ExpPow  Weibull   -6.0075 0.001   -9.9667  -2.0483   True
  ExpPow    twoDt  155.4443 0.001  151.4851 159.4035   True
  LogSec Logistic   -8.2603 0.001  -12.2196  -4.3011   True
  LogSec  Weibull -103.1289 0.001 -107.0881 -99.1697   True
  LogSec    twoDt   58.3229 0.001   54.3637  62.2821   True
Logistic  Weibull  -94.8686 0.001  -98.8278 -90.9094   True
Logistic    twoDt   66.5832 0.001    62.624  70.5425   True
 Weibull    twoDt  161.4518 0.001  157.4926  165.411   True
-----------------------------------------------------------
=== Que\_pub ===
    Multiple Comparison of Means - Tukey HSD, FWER=0.05
============================================================
 group1   group2   meandiff p-adj    lower    upper   reject
------------------------------------------------------------
  ExpPow   LogSec   96.1202  0.001   92.1609 100.0794   True
  ExpPow Logistic   75.8448  0.001   71.8856   79.804   True
  ExpPow  Weibull   -6.5081  0.001  -10.4674  -2.5489   True
  ExpPow    twoDt   72.0901  0.001   68.1309  76.0493   True
  LogSec Logistic  -20.2753  0.001  -24.2346 -16.3161   True
  LogSec  Weibull -102.6283  0.001 -106.5875 -98.6691   True
  LogSec    twoDt    -24.03  0.001  -27.9893 -20.0708   True
Logistic  Weibull  -82.3529  0.001  -86.3122 -78.3937   True
Logistic    twoDt   -3.7547 0.0728   -7.7139   0.2045  False
 Weibull    twoDt   78.5982  0.001    74.639  82.5575   True
------------------------------------------------------------
=== Que\_rob ===
    Multiple Comparison of Means - Tukey HSD, FWER=0.05
============================================================
 group1   group2   meandiff p-adj   lower     upper   reject
------------------------------------------------------------
  ExpPow   LogSec  104.3805 0.001  100.4212  108.3397   True
  ExpPow Logistic  111.3892 0.001    107.43  115.3485   True
  ExpPow  Weibull       0.0   0.9   -3.9592    3.9592  False
  ExpPow    twoDt   54.8185 0.001   50.8593   58.7778   True
  LogSec Logistic    7.0088 0.001    3.0495    10.968   True
  LogSec  Weibull -104.3805 0.001 -108.3397 -100.4212   True
  LogSec    twoDt   -49.562 0.001  -53.5212  -45.6027   True
Logistic  Weibull -111.3892 0.001 -115.3485   -107.43   True
Logistic    twoDt  -56.5707 0.001  -60.5299  -52.6115   True
 Weibull    twoDt   54.8185 0.001   50.8593   58.7778   True
------------------------------------------------------------
=== Til\_cor ===
    Multiple Comparison of Means - Tukey HSD, FWER=0.05
===========================================================
 group1   group2  meandiff p-adj   lower     upper   reject
-----------------------------------------------------------
  ExpPow   LogSec  21.8798 0.001   15.4437   28.3159   True
  ExpPow Logistic 123.2666 0.001  116.8304  129.7027   True
  ExpPow  Weibull -69.3374 0.001  -75.7736  -62.9013   True
  ExpPow    twoDt  52.3883 0.001   45.9522   58.8244   True
  LogSec Logistic 101.3867 0.001   94.9506  107.8229   True
  LogSec  Weibull -91.2173 0.001  -97.6534  -84.7811   True
  LogSec    twoDt  30.5085 0.001   24.0723   36.9446   True
Logistic  Weibull -192.604 0.001 -199.0401 -186.1679   True
Logistic    twoDt -70.8783 0.001  -77.3144  -64.4421   True
 Weibull    twoDt 121.7257 0.001  115.2896  128.1619   True
-----------------------------------------------------------
=== Ulm\_gla ===
   Multiple Comparison of Means - Tukey HSD, FWER=0.05
=========================================================
 group1   group2  meandiff p-adj  lower    upper   reject
---------------------------------------------------------
  ExpPow   LogSec  66.1072 0.001  63.0512  69.1631   True
  ExpPow Logistic  51.7753 0.001  48.7194  54.8313   True
  ExpPow  Weibull -15.4939 0.001 -18.5498 -12.4379   True
  ExpPow    twoDt  89.6062 0.001  86.5502  92.6622   True
  LogSec Logistic -14.3318 0.001 -17.3878 -11.2758   True
  LogSec  Weibull  -81.601 0.001  -84.657 -78.5451   True
  LogSec    twoDt   23.499 0.001   20.443   26.555   True
Logistic  Weibull -67.2692 0.001 -70.3252 -64.2132   True
Logistic    twoDt  37.8309 0.001  34.7749  40.8868   True
 Weibull    twoDt 105.1001 0.001 102.0441  108.156   True
---------------------------------------------------------
    \end{Verbatim}

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{25}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Default NegExp kernel }\PY{l+s+se}{\PYZbs{}n}\PY{l+s+s1}{\PYZhy{}\PYZhy{}\PYZgt{} minimum RMSE: }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n+nb}{str}\PY{p}{(}\PY{n+nb}{round}\PY{p}{(}\PY{n+nb}{min}\PY{p}{(}\PY{n}{best\PYZus{}EVA\PYZus{}df}\PY{o}{.}\PY{n}{rmse}\PY{p}{)}\PY{p}{,}\PY{l+m+mi}{2}\PY{p}{)}\PY{p}{)}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+si}{\PYZpc{} f}\PY{l+s+s1}{or }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}
      \PY{n+nb}{str}\PY{p}{(}\PY{n}{best\PYZus{}EVA\PYZus{}df}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{n}{best\PYZus{}EVA\PYZus{}df}\PY{o}{.}\PY{n}{rmse} \PY{o}{==} \PY{n+nb}{min}\PY{p}{(}\PY{n}{best\PYZus{}EVA\PYZus{}df}\PY{o}{.}\PY{n}{rmse}\PY{p}{)}\PY{p}{]}\PY{o}{.}\PY{n}{Species}\PY{o}{.}\PY{n}{tolist}\PY{p}{(}\PY{p}{)}\PY{p}{)}\PY{o}{+}
     \PY{l+s+s1}{\PYZsq{}}\PY{l+s+se}{\PYZbs{}n}\PY{l+s+s1}{\PYZhy{}\PYZhy{}\PYZgt{} maximum RMSE: }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n+nb}{str}\PY{p}{(}\PY{n+nb}{round}\PY{p}{(}\PY{n+nb}{max}\PY{p}{(}\PY{n}{best\PYZus{}EVA\PYZus{}df}\PY{o}{.}\PY{n}{rmse}\PY{p}{)}\PY{p}{,}\PY{l+m+mi}{2}\PY{p}{)}\PY{p}{)}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+si}{\PYZpc{} f}\PY{l+s+s1}{or }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}
      \PY{n+nb}{str}\PY{p}{(}\PY{n}{best\PYZus{}EVA\PYZus{}df}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{n}{best\PYZus{}EVA\PYZus{}df}\PY{o}{.}\PY{n}{rmse} \PY{o}{==} \PY{n+nb}{max}\PY{p}{(}\PY{n}{best\PYZus{}EVA\PYZus{}df}\PY{o}{.}\PY{n}{rmse}\PY{p}{)}\PY{p}{]}\PY{o}{.}\PY{n}{Species}\PY{o}{.}\PY{n}{tolist}\PY{p}{(}\PY{p}{)}\PY{p}{)}\PY{p}{)}
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Fat\PYZhy{}tailed kernels }\PY{l+s+se}{\PYZbs{}n}\PY{l+s+s1}{\PYZhy{}\PYZhy{}\PYZgt{} minimum RMSE: }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n+nb}{str}\PY{p}{(}\PY{n+nb}{round}\PY{p}{(}\PY{n+nb}{min}\PY{p}{(}\PY{n}{rmse\PYZus{}all\PYZus{}df}\PY{o}{.}\PY{n}{rmse}\PY{p}{)}\PY{p}{,}\PY{l+m+mi}{2}\PY{p}{)}\PY{p}{)}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{\PYZpc{}}\PY{l+s+s1}{ with }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}
      \PY{n+nb}{str}\PY{p}{(}\PY{n}{rmse\PYZus{}all\PYZus{}df}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{n}{rmse\PYZus{}all\PYZus{}df}\PY{o}{.}\PY{n}{rmse} \PY{o}{==} \PY{n+nb}{min}\PY{p}{(}\PY{n}{rmse\PYZus{}all\PYZus{}df}\PY{o}{.}\PY{n}{rmse}\PY{p}{)}\PY{p}{]}\PY{o}{.}\PY{n}{kernel}\PY{o}{.}\PY{n}{tolist}\PY{p}{(}\PY{p}{)}\PY{p}{)}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ for }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}
      \PY{n+nb}{str}\PY{p}{(}\PY{n}{rmse\PYZus{}all\PYZus{}df}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{n}{rmse\PYZus{}all\PYZus{}df}\PY{o}{.}\PY{n}{rmse} \PY{o}{==} \PY{n+nb}{min}\PY{p}{(}\PY{n}{rmse\PYZus{}all\PYZus{}df}\PY{o}{.}\PY{n}{rmse}\PY{p}{)}\PY{p}{]}\PY{o}{.}\PY{n}{Species}\PY{o}{.}\PY{n}{tolist}\PY{p}{(}\PY{p}{)}\PY{p}{)}\PY{o}{+}
     \PY{l+s+s1}{\PYZsq{}}\PY{l+s+se}{\PYZbs{}n}\PY{l+s+s1}{\PYZhy{}\PYZhy{}\PYZgt{} maximum RMSE: }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n+nb}{str}\PY{p}{(}\PY{n+nb}{round}\PY{p}{(}\PY{n+nb}{max}\PY{p}{(}\PY{n}{rmse\PYZus{}all\PYZus{}df}\PY{o}{.}\PY{n}{rmse}\PY{p}{)}\PY{p}{,}\PY{l+m+mi}{2}\PY{p}{)}\PY{p}{)}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{\PYZpc{}}\PY{l+s+s1}{ with }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}
      \PY{n+nb}{str}\PY{p}{(}\PY{n}{rmse\PYZus{}all\PYZus{}df}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{n}{rmse\PYZus{}all\PYZus{}df}\PY{o}{.}\PY{n}{rmse} \PY{o}{==} \PY{n+nb}{max}\PY{p}{(}\PY{n}{rmse\PYZus{}all\PYZus{}df}\PY{o}{.}\PY{n}{rmse}\PY{p}{)}\PY{p}{]}\PY{o}{.}\PY{n}{kernel}\PY{o}{.}\PY{n}{tolist}\PY{p}{(}\PY{p}{)}\PY{p}{)}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ for }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}
      \PY{n+nb}{str}\PY{p}{(}\PY{n}{rmse\PYZus{}all\PYZus{}df}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{n}{rmse\PYZus{}all\PYZus{}df}\PY{o}{.}\PY{n}{rmse} \PY{o}{==} \PY{n+nb}{max}\PY{p}{(}\PY{n}{rmse\PYZus{}all\PYZus{}df}\PY{o}{.}\PY{n}{rmse}\PY{p}{)}\PY{p}{]}\PY{o}{.}\PY{n}{Species}\PY{o}{.}\PY{n}{tolist}\PY{p}{(}\PY{p}{)}\PY{p}{)}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}

    \begin{Verbatim}[commandchars=\\\{\}]
Default NegExp kernel
--> minimum RMSE: 2.66\% for ['Abi\_alb']
--> maximum RMSE: 191.48\% for ['Pin\_hal']
Fat-tailed kernels
--> minimum RMSE: 7.99\% with ['twoDt'] for ['Abi\_alb']
--> maximum RMSE: 34.32\% with ['Logistic'] for ['Pin\_syl']
    \end{Verbatim}

    \hypertarget{best-kernel-shapes-per-species}{%
\subsection{Best kernel shapes per
species}\label{best-kernel-shapes-per-species}}

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{26}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{c+c1}{\PYZsh{}\PYZsh{} Create dataframe with: }
\PY{c+c1}{\PYZsh{} simulated and observed (75th percentile) migration rates}
\PY{c+c1}{\PYZsh{} migration parameters}
\PY{c+c1}{\PYZsh{} life\PYZhy{}history traits (dispersal syndromes and kernel shape categories)}

\PY{c+c1}{\PYZsh{} Add species\PYZhy{}specific migration parameters}
\PY{n}{best\PYZus{}all\PYZus{}df} \PY{o}{=} \PY{n}{rmse\PYZus{}all\PYZus{}df}
\PY{n}{best\PYZus{}all\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{FEC\PYZus{}max}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n}{KA\PYZus{}input}\PY{o}{.}\PY{n}{groupby}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{p}{)}\PY{o}{.}\PY{n}{FEC\PYZus{}max}\PY{o}{.}\PY{n}{tolist}\PY{p}{(}\PY{p}{)}
\PY{n}{best\PYZus{}all\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{GERM\PYZus{}p}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n}{KA\PYZus{}input}\PY{o}{.}\PY{n}{groupby}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{p}{)}\PY{o}{.}\PY{n}{GERM\PYZus{}p}\PY{o}{.}\PY{n}{tolist}\PY{p}{(}\PY{p}{)}
\PY{n}{best\PYZus{}all\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{SDD\PYZus{}d}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n}{KA\PYZus{}input}\PY{o}{.}\PY{n}{groupby}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{p}{)}\PY{o}{.}\PY{n}{SDD\PYZus{}d}\PY{o}{.}\PY{n}{tolist}\PY{p}{(}\PY{p}{)}
\PY{n}{best\PYZus{}all\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{LDD\PYZus{}d}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n}{KA\PYZus{}input}\PY{o}{.}\PY{n}{groupby}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{p}{)}\PY{o}{.}\PY{n}{LDD\PYZus{}d}\PY{o}{.}\PY{n}{tolist}\PY{p}{(}\PY{p}{)}

\PY{c+c1}{\PYZsh{} Add best default kernel (from EVA)}
\PY{n}{EVA\PYZus{}opt\PYZus{}df} \PY{o}{=} \PY{n}{best\PYZus{}EVA\PYZus{}df}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{n}{best\PYZus{}EVA\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameter\PYZus{}combo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{all\PYZus{}MAX\PYZus{}opt}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}
\PY{n}{species\PYZus{}best\PYZus{}EVA} \PY{o}{=} \PY{n}{EVA\PYZus{}opt\PYZus{}df}\PY{o}{.}\PY{n}{Species}\PY{o}{.}\PY{n}{to\PYZus{}list}\PY{p}{(}\PY{p}{)}
\PY{k}{for} \PY{n}{sp} \PY{o+ow}{in} \PY{n}{species\PYZus{}best\PYZus{}EVA} \PY{p}{:}
    \PY{n}{best\PYZus{}all\PYZus{}df}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{n}{rmse\PYZus{}all\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{n}{sp}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{kernel}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{NegExp}\PY{l+s+s1}{\PYZsq{}}
    \PY{n}{best\PYZus{}all\PYZus{}df}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{n}{rmse\PYZus{}all\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{n}{sp}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{shape\PYZus{}par}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{NA}\PY{l+s+s1}{\PYZsq{}}
    \PY{n}{best\PYZus{}all\PYZus{}df}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{n}{rmse\PYZus{}all\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{n}{sp}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{sim}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n+nb}{float}\PY{p}{(}\PY{n}{EVA\PYZus{}opt\PYZus{}df}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{n}{EVA\PYZus{}opt\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{n}{sp}\PY{p}{]}\PY{o}{.}\PY{n}{sim}\PY{p}{)}
    \PY{n}{best\PYZus{}all\PYZus{}df}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{n}{rmse\PYZus{}all\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{n}{sp}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{rmse}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n+nb}{float}\PY{p}{(}\PY{n}{EVA\PYZus{}opt\PYZus{}df}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{n}{EVA\PYZus{}opt\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{n}{sp}\PY{p}{]}\PY{o}{.}\PY{n}{rmse}\PY{p}{)}
    \PY{n}{best\PYZus{}all\PYZus{}df}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{n}{rmse\PYZus{}all\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{n}{sp}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{LDD\PYZus{}d}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n+nb}{float}\PY{p}{(}\PY{n}{EVA\PYZus{}opt\PYZus{}df}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{n}{EVA\PYZus{}opt\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{n}{sp}\PY{p}{]}\PY{o}{.}\PY{n}{LDD\PYZus{}d}\PY{p}{)}

\PY{c+c1}{\PYZsh{} Add species\PYZhy{}specific dispersal syndromes (cf. Table 1)}
\PY{n}{best\PYZus{}all\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{dispersal\PYZus{}syndrome}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Mainly\PYZhy{}wind}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Wind/Animal + LDD}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Wind/Animal + LDD}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Wind/Animal + LDD}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}
                                        \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Wind/Animal + LDD}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Hoarding animals}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Wind/Animal + LDD}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Wind/Animal + LDD}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}
                                        \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Mainly\PYZhy{}wind}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Wind/Animal + LDD}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Mainly\PYZhy{}wind}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Hoarding animals}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}
                                        \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Hoarding animals}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Hoarding animals}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Hoarding animals}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Hoarding animals}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}
                                        \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Mainly\PYZhy{}wind}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}

\PY{c+c1}{\PYZsh{} Add simplified kernel shape description}
\PY{n}{kernel\PYZus{}functions} \PY{o}{=} \PY{n}{rmse\PYZus{}all\PYZus{}df}\PY{o}{.}\PY{n}{kernel}\PY{o}{.}\PY{n}{tolist}\PY{p}{(}\PY{p}{)}
\PY{n}{kernel\PYZus{}shape} \PY{o}{=} \PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Fat\PYZhy{}tailed (concave)}\PY{l+s+s1}{\PYZsq{}} \PY{k}{if} \PY{p}{(}\PY{n}{kernel\PYZus{}fun} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{twoDt}\PY{l+s+s1}{\PYZsq{}} \PY{o+ow}{or} \PY{n}{kernel\PYZus{}fun} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ExpPow}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)} 
                \PY{k}{else} \PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Exponentially\PYZhy{}bounded}\PY{l+s+s1}{\PYZsq{}} \PY{k}{if} \PY{p}{(}\PY{n}{kernel\PYZus{}fun} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{NegExp}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
                \PY{k}{else} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Fat\PYZhy{}tailed (convex)}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)} \PY{k}{for} \PY{n}{kernel\PYZus{}fun} \PY{o+ow}{in} \PY{n}{kernel\PYZus{}functions}\PY{p}{]}
\PY{n}{best\PYZus{}all\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{kernel\PYZus{}shape}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{n}{kernel\PYZus{}shape}

\PY{c+c1}{\PYZsh{} Export to CSV}
\PY{n}{best\PYZus{}all\PYZus{}df}\PY{o}{.}\PY{n}{to\PYZus{}csv}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Table\PYZus{}B2.csv}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{sep}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{;}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{index}\PY{o}{=}\PY{k+kc}{False}\PY{p}{)}
\PY{n}{best\PYZus{}all\PYZus{}df}
\end{Verbatim}
\end{tcolorbox}

            \begin{tcolorbox}[breakable, size=fbox, boxrule=.5pt, pad at break*=1mm, opacityfill=0]
\prompt{Out}{outcolor}{26}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
    Species    kernel shape\_par       rmse     sim  obs\_75ile  FEC\_max  \textbackslash{}
0   Abi\_alb    NegExp        NA   2.663086   305.0     286.75     50.0
1   Bet\_pen    LogSec      0.29  19.705736   778.0     734.25  11775.0
2   Bet\_pub    LogSec      0.29  19.705736   778.0     734.25  11775.0
3   Car\_bet  Logistic      4.75  19.629633   778.0     874.25    705.0
4   Cor\_ave    LogSec       0.4  12.212030  1200.0    1374.25      6.0
5   Fag\_syl    LogSec     0.375  14.190301   270.0     274.25     29.0
6   Fra\_exc    ExpPow       0.5  25.751338   374.0     424.25     42.0
7   Pic\_abi    NegExp        NA   9.206669   352.0     411.75    163.0
8   Pic\_sit    ExpPow       0.5  31.145396   327.0     411.75     50.0
9   Pin\_hal  Logistic       4.0  29.198774   887.0    1274.25     22.0
10  Pin\_syl  Logistic       4.5  34.321916   800.0    1274.25     43.0
11  Que\_coc  Logistic      4.15  21.114749   461.0     449.25      5.0
12  Que\_ile  Logistic       4.5  15.253691   419.0     449.25     50.0
13  Que\_pub    LogSec     0.525  14.688697   410.0     449.25     50.0
14  Que\_rob    LogSec       0.5  19.533229   452.0     449.25     50.0
15  Til\_cor    ExpPow      0.45  31.412574   311.0     411.75    720.0
16  Ulm\_gla    LogSec      0.35  17.118000   748.0     886.75    725.0

    GERM\_p  SDD\_d   LDD\_d dispersal\_syndrome           kernel\_shape
0     46.0  100.0   710.0        Mainly-wind  Exponentially-bounded
1     19.0  200.0   475.0  Wind/Animal + LDD    Fat-tailed (convex)
2     19.0  200.0   475.0  Wind/Animal + LDD    Fat-tailed (convex)
3     80.0  100.0   425.0  Wind/Animal + LDD    Fat-tailed (convex)
4     60.0  200.0  1500.0  Wind/Animal + LDD    Fat-tailed (convex)
5     71.0   25.0   200.0   Hoarding animals    Fat-tailed (convex)
6     60.0  100.0   725.0  Wind/Animal + LDD   Fat-tailed (concave)
7     80.0  100.0   780.0  Wind/Animal + LDD  Exponentially-bounded
8     75.0  100.0   800.0        Mainly-wind   Fat-tailed (concave)
9     60.0  100.0   250.0  Wind/Animal + LDD    Fat-tailed (convex)
10    91.0  100.0   250.0        Mainly-wind    Fat-tailed (convex)
11    70.0   25.0   200.0   Hoarding animals    Fat-tailed (convex)
12    90.0   25.0   200.0   Hoarding animals    Fat-tailed (convex)
13    90.0   25.0   200.0   Hoarding animals    Fat-tailed (convex)
14    95.0   25.0   200.0   Hoarding animals    Fat-tailed (convex)
15    55.0  100.0   374.0   Hoarding animals   Fat-tailed (concave)
16    65.0  100.0   350.0        Mainly-wind    Fat-tailed (convex)
\end{Verbatim}
\end{tcolorbox}
        
    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{27}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{c+c1}{\PYZsh{} Define kernel functions}
\PY{k}{def} \PY{n+nf}{neg\PYZus{}exponential}\PY{p}{(}\PY{n}{dist}\PY{p}{,} \PY{n}{sdd}\PY{p}{,} \PY{n}{ldd}\PY{p}{)} \PY{p}{:}
    \PY{n}{a1} \PY{o}{=} \PY{n}{sdd} \PY{o}{/} \PY{l+m+mi}{2}
    \PY{n}{a2} \PY{o}{=} \PY{n}{ldd} \PY{o}{/} \PY{l+m+mi}{2}
    \PY{k}{if} \PY{p}{(}\PY{n}{a1} \PY{o}{\PYZlt{}}\PY{o}{=} \PY{l+m+mi}{0}\PY{p}{)}\PY{p}{:}
        \PY{k}{return} \PY{n}{np}\PY{o}{.}\PY{n}{zeros}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{dist}\PY{p}{)}\PY{p}{)}
    \PY{n}{dist\PYZus{}prob\PYZus{}sdd} \PY{o}{=} \PY{l+m+mi}{1} \PY{o}{/} \PY{p}{(}\PY{l+m+mi}{2} \PY{o}{*} \PY{n}{np}\PY{o}{.}\PY{n}{pi} \PY{o}{*} \PY{n}{a1}\PY{o}{*}\PY{o}{*}\PY{l+m+mi}{2}\PY{p}{)} \PY{o}{*} \PY{n}{np}\PY{o}{.}\PY{n}{exp}\PY{p}{(}\PY{o}{\PYZhy{}}\PY{n}{dist} \PY{o}{/} \PY{n}{a1}\PY{p}{)}
    \PY{n}{dist\PYZus{}prob\PYZus{}ldd} \PY{o}{=} \PY{l+m+mi}{1} \PY{o}{/} \PY{p}{(}\PY{l+m+mi}{2} \PY{o}{*} \PY{n}{np}\PY{o}{.}\PY{n}{pi} \PY{o}{*} \PY{n}{a2}\PY{o}{*}\PY{o}{*}\PY{l+m+mi}{2}\PY{p}{)} \PY{o}{*} \PY{n}{np}\PY{o}{.}\PY{n}{exp}\PY{p}{(}\PY{o}{\PYZhy{}}\PY{n}{dist} \PY{o}{/} \PY{n}{a2}\PY{p}{)}
    \PY{n}{dist\PYZus{}prob} \PY{o}{=} \PY{n}{short\PYZus{}range\PYZus{}disp\PYZus{}frac}\PY{o}{*}\PY{n}{dist\PYZus{}prob\PYZus{}sdd} \PY{o}{+} \PY{p}{(}\PY{l+m+mi}{1} \PY{o}{\PYZhy{}} \PY{n}{short\PYZus{}range\PYZus{}disp\PYZus{}frac}\PY{p}{)}\PY{o}{*}\PY{n}{dist\PYZus{}prob\PYZus{}ldd}
    \PY{k}{return} \PY{n}{scaler\PYZus{}0\PYZus{}1}\PY{p}{(}\PY{n}{dist\PYZus{}prob}\PY{p}{)}

\PY{k}{def} \PY{n+nf}{exp\PYZus{}power}\PY{p}{(}\PY{n}{dist}\PY{p}{,} \PY{n}{sdd}\PY{p}{,} \PY{n}{ldd}\PY{p}{,} \PY{n}{b}\PY{p}{)} \PY{p}{:}
    \PY{n}{a1} \PY{o}{=} \PY{p}{(}\PY{n}{gamma}\PY{p}{(}\PY{l+m+mi}{2}\PY{o}{/}\PY{n}{b}\PY{p}{)} \PY{o}{/} \PY{n}{gamma}\PY{p}{(}\PY{l+m+mi}{3}\PY{o}{/}\PY{n}{b}\PY{p}{)}\PY{p}{)} \PY{o}{*} \PY{n}{sdd}
    \PY{n}{a2} \PY{o}{=} \PY{p}{(}\PY{n}{gamma}\PY{p}{(}\PY{l+m+mi}{2}\PY{o}{/}\PY{n}{b}\PY{p}{)} \PY{o}{/} \PY{n}{gamma}\PY{p}{(}\PY{l+m+mi}{3}\PY{o}{/}\PY{n}{b}\PY{p}{)}\PY{p}{)} \PY{o}{*} \PY{n}{ldd}
    \PY{k}{if} \PY{p}{(}\PY{n}{a1} \PY{o}{==} \PY{l+m+mf}{0.} \PY{o+ow}{or} \PY{n}{b} \PY{o}{\PYZlt{}}\PY{o}{=} \PY{l+m+mf}{0.}\PY{p}{)}\PY{p}{:}
        \PY{k}{return} \PY{n}{np}\PY{o}{.}\PY{n}{zeros}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{dist}\PY{p}{)}\PY{p}{)}
    \PY{n}{dist\PYZus{}prob\PYZus{}sdd} \PY{o}{=} \PY{n}{b} \PY{o}{/} \PY{p}{(}\PY{l+m+mi}{2} \PY{o}{*} \PY{n}{np}\PY{o}{.}\PY{n}{pi} \PY{o}{*} \PY{n}{a1}\PY{o}{*}\PY{o}{*}\PY{l+m+mi}{2} \PY{o}{*} \PY{n}{gamma}\PY{p}{(}\PY{l+m+mi}{2}\PY{o}{/}\PY{n}{b}\PY{p}{)}\PY{p}{)} \PY{o}{*} \PY{n}{np}\PY{o}{.}\PY{n}{exp}\PY{p}{(}\PY{o}{\PYZhy{}}\PY{p}{(}\PY{n}{dist}\PY{o}{*}\PY{o}{*}\PY{n}{b} \PY{o}{/} \PY{n}{a1}\PY{o}{*}\PY{o}{*}\PY{n}{b}\PY{p}{)}\PY{p}{)}
    \PY{n}{dist\PYZus{}prob\PYZus{}ldd} \PY{o}{=} \PY{n}{b} \PY{o}{/} \PY{p}{(}\PY{l+m+mi}{2} \PY{o}{*} \PY{n}{np}\PY{o}{.}\PY{n}{pi} \PY{o}{*} \PY{n}{a2}\PY{o}{*}\PY{o}{*}\PY{l+m+mi}{2} \PY{o}{*} \PY{n}{gamma}\PY{p}{(}\PY{l+m+mi}{2}\PY{o}{/}\PY{n}{b}\PY{p}{)}\PY{p}{)} \PY{o}{*} \PY{n}{np}\PY{o}{.}\PY{n}{exp}\PY{p}{(}\PY{o}{\PYZhy{}}\PY{p}{(}\PY{n}{dist}\PY{o}{*}\PY{o}{*}\PY{n}{b} \PY{o}{/} \PY{n}{a2}\PY{o}{*}\PY{o}{*}\PY{n}{b}\PY{p}{)}\PY{p}{)}
    \PY{n}{dist\PYZus{}prob} \PY{o}{=} \PY{n}{short\PYZus{}range\PYZus{}disp\PYZus{}frac}\PY{o}{*}\PY{n}{dist\PYZus{}prob\PYZus{}sdd} \PY{o}{+} \PY{p}{(}\PY{l+m+mi}{1} \PY{o}{\PYZhy{}} \PY{n}{short\PYZus{}range\PYZus{}disp\PYZus{}frac}\PY{p}{)}\PY{o}{*}\PY{n}{dist\PYZus{}prob\PYZus{}ldd}
    \PY{k}{return} \PY{n}{scaler\PYZus{}0\PYZus{}1}\PY{p}{(}\PY{n}{dist\PYZus{}prob}\PY{p}{)}

\PY{k}{def} \PY{n+nf}{logistic}\PY{p}{(}\PY{n}{dist}\PY{p}{,} \PY{n}{sdd}\PY{p}{,} \PY{n}{ldd}\PY{p}{,} \PY{n}{b}\PY{p}{)} \PY{p}{:}
    \PY{n}{a1} \PY{o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Zhy{}}\PY{l+m+mi}{1}
    \PY{n}{dist\PYZus{}prob} \PY{o}{=} \PY{n}{short\PYZus{}range\PYZus{}disp\PYZus{}frac}\PY{o}{*}\PY{n}{dist\PYZus{}prob\PYZus{}sdd} \PY{o}{+} \PY{p}{(}\PY{l+m+mi}{1} \PY{o}{\PYZhy{}} \PY{n}{short\PYZus{}range\PYZus{}disp\PYZus{}frac}\PY{p}{)}\PY{o}{*}\PY{n}{dist\PYZus{}prob\PYZus{}ldd}
    \PY{k}{return} \PY{n}{scaler\PYZus{}0\PYZus{}1}\PY{p}{(}\PY{n}{dist\PYZus{}prob}\PY{p}{)}

\PY{k}{def} \PY{n+nf}{log\PYZus{}sech}\PY{p}{(}\PY{n}{dist}\PY{p}{,} \PY{n}{sdd}\PY{p}{,} \PY{n}{ldd}\PY{p}{,} \PY{n}{b}\PY{p}{)} \PY{p}{:}
    \PY{n}{a1} \PY{o}{=} \PY{n}{sdd}
    \PY{n}{a2} \PY{o}{=} \PY{n}{ldd}
    \PY{k}{if} \PY{p}{(}\PY{n}{a1} \PY{o}{\PYZlt{}}\PY{o}{=} \PY{l+m+mf}{0.} \PY{o+ow}{or} \PY{n}{b} \PY{o}{\PYZlt{}}\PY{o}{=} \PY{l+m+mf}{0.}\PY{p}{)} \PY{p}{:}
        \PY{k}{return} \PY{n}{np}\PY{o}{.}\PY{n}{zeros}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{dist}\PY{p}{)}\PY{p}{)}
    \PY{n}{dist\PYZus{}prob\PYZus{}sdd} \PY{o}{=} \PY{l+m+mi}{1} \PY{o}{/} \PY{p}{(}\PY{n}{np}\PY{o}{.}\PY{n}{pi}\PY{o}{*}\PY{o}{*}\PY{l+m+mi}{2} \PY{o}{*} \PY{n}{b} \PY{o}{*} \PY{n}{dist}\PY{o}{*}\PY{o}{*}\PY{l+m+mi}{2}\PY{p}{)} \PY{o}{/} \PY{p}{(}\PY{p}{(}\PY{n}{dist} \PY{o}{/} \PY{n}{a1}\PY{p}{)}\PY{o}{*}\PY{o}{*}\PY{p}{(}\PY{l+m+mi}{1} \PY{o}{/} \PY{n}{b}\PY{p}{)} \PY{o}{+} \PY{p}{(}\PY{n}{dist} \PY{o}{/} \PY{n}{a1}\PY{p}{)}\PY{o}{*}\PY{o}{*}\PY{p}{(}\PY{o}{\PYZhy{}}\PY{l+m+mi}{1} \PY{o}{/} \PY{n}{b}\PY{p}{)}\PY{p}{)}
    \PY{n}{dist\PYZus{}prob\PYZus{}ldd} \PY{o}{=} \PY{l+m+mi}{1} \PY{o}{/} \PY{p}{(}\PY{n}{np}\PY{o}{.}\PY{n}{pi}\PY{o}{*}\PY{o}{*}\PY{l+m+mi}{2} \PY{o}{*} \PY{n}{b} \PY{o}{*} \PY{n}{dist}\PY{o}{*}\PY{o}{*}\PY{l+m+mi}{2}\PY{p}{)} \PY{o}{/} \PY{p}{(}\PY{p}{(}\PY{n}{dist} \PY{o}{/} \PY{n}{a2}\PY{p}{)}\PY{o}{*}\PY{o}{*}\PY{p}{(}\PY{l+m+mi}{1} \PY{o}{/} \PY{n}{b}\PY{p}{)} \PY{o}{+} \PY{p}{(}\PY{n}{dist} \PY{o}{/} \PY{n}{a2}\PY{p}{)}\PY{o}{*}\PY{o}{*}\PY{p}{(}\PY{o}{\PYZhy{}}\PY{l+m+mi}{1} \PY{o}{/} \PY{n}{b}\PY{p}{)}\PY{p}{)}
    \PY{n}{dist\PYZus{}prob} \PY{o}{=} \PY{n}{short\PYZus{}range\PYZus{}disp\PYZus{}frac}\PY{o}{*}\PY{n}{dist\PYZus{}prob\PYZus{}sdd} \PY{o}{+} \PY{p}{(}\PY{l+m+mi}{1} \PY{o}{\PYZhy{}} \PY{n}{short\PYZus{}range\PYZus{}disp\PYZus{}frac}\PY{p}{)}\PY{o}{*}\PY{n}{dist\PYZus{}prob\PYZus{}ldd}
    \PY{k}{return} \PY{n}{scaler\PYZus{}0\PYZus{}1}\PY{p}{(}\PY{n}{dist\PYZus{}prob}\PY{p}{)}

\PY{n}{f}\PY{p}{,} \PY{n}{axes} \PY{o}{=} \PY{n}{plt}\PY{o}{.}\PY{n}{subplots}\PY{p}{(}\PY{l+m+mi}{4}\PY{p}{,} \PY{l+m+mi}{4}\PY{p}{,} \PY{n}{sharex}\PY{o}{=}\PY{k+kc}{True}\PY{p}{,} \PY{n}{sharey}\PY{o}{=}\PY{k+kc}{True}\PY{p}{)}
\PY{p}{(}\PY{n}{ax1}\PY{p}{,} \PY{n}{ax2}\PY{p}{,} \PY{n}{ax3}\PY{p}{,} \PY{n}{ax4}\PY{p}{)}\PY{p}{,} \PY{p}{(}\PY{n}{ax5}\PY{p}{,} \PY{n}{ax6}\PY{p}{,} \PY{n}{ax7}\PY{p}{,} \PY{n}{ax8}\PY{p}{)}\PY{p}{,} \PY{p}{(}\PY{n}{ax9}\PY{p}{,} \PY{n}{ax10}\PY{p}{,} \PY{n}{ax11}\PY{p}{,} \PY{n}{ax12}\PY{p}{)}\PY{p}{,} \PY{p}{(}\PY{n}{ax13}\PY{p}{,} \PY{n}{ax14}\PY{p}{,} \PY{n}{ax15}\PY{p}{,} \PY{n}{ax16}\PY{p}{)} \PY{o}{=} \PY{n}{axes}
\PY{n}{f}\PY{o}{.}\PY{n}{set\PYZus{}figheight}\PY{p}{(}\PY{l+m+mf}{7.25}\PY{o}{*}\PY{l+m+mf}{1.25}\PY{p}{)}
\PY{n}{f}\PY{o}{.}\PY{n}{set\PYZus{}figwidth}\PY{p}{(}\PY{l+m+mf}{7.25}\PY{o}{*}\PY{l+m+mf}{1.25}\PY{p}{)}
\PY{n}{f}\PY{o}{.}\PY{n}{dpi} \PY{o}{=} \PY{l+m+mi}{300}

\PY{c+c1}{\PYZsh{} Drop one of the Betula spp. as they are identical}
\PY{n}{bestkernels\PYZus{}sp\PYZus{}df} \PY{o}{=} \PY{n}{best\PYZus{}all\PYZus{}df}\PY{o}{.}\PY{n}{copy}\PY{p}{(}\PY{p}{)}
\PY{n}{bestkernels\PYZus{}sp\PYZus{}df}\PY{o}{.}\PY{n}{drop}\PY{p}{(}\PY{n}{bestkernels\PYZus{}sp\PYZus{}df}\PY{p}{[}\PY{n}{bestkernels\PYZus{}sp\PYZus{}df}\PY{o}{.}\PY{n}{Species} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Bet\PYZus{}pub}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{.}\PY{n}{index}\PY{p}{,} \PY{n}{inplace}\PY{o}{=}\PY{k+kc}{True}\PY{p}{)}

\PY{n}{species} \PY{o}{=} \PY{n}{bestkernels\PYZus{}sp\PYZus{}df}\PY{o}{.}\PY{n}{Species}
\PY{n}{distance\PYZus{}range} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{linspace}\PY{p}{(}\PY{l+m+mf}{1.}\PY{p}{,}\PY{l+m+mf}{750.}\PY{p}{,}\PY{l+m+mi}{750}\PY{p}{)}
\PY{n}{short\PYZus{}range\PYZus{}disp\PYZus{}frac} \PY{o}{=} \PY{l+m+mf}{0.99}

\PY{k}{for} \PY{n}{sp}\PY{p}{,}\PY{n}{ax} \PY{o+ow}{in} \PY{n+nb}{zip}\PY{p}{(}\PY{n}{species}\PY{p}{,}\PY{n}{axes}\PY{o}{.}\PY{n}{flatten}\PY{p}{(}\PY{p}{)}\PY{p}{)}\PY{p}{:}
    \PY{n}{df\PYZus{}sub} \PY{o}{=} \PY{n}{bestkernels\PYZus{}sp\PYZus{}df}\PY{p}{[}\PY{n}{bestkernels\PYZus{}sp\PYZus{}df}\PY{o}{.}\PY{n}{Species} \PY{o}{==} \PY{n}{sp}\PY{p}{]}
    
    \PY{k}{if} \PY{n}{df\PYZus{}sub}\PY{o}{.}\PY{n}{kernel}\PY{o}{.}\PY{n}{item}\PY{p}{(}\PY{p}{)} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{NegExp}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:}
        \PY{n}{x} \PY{o}{=} \PY{n}{neg\PYZus{}exponential}\PY{p}{(}\PY{n}{distance\PYZus{}range}\PY{p}{,} \PY{n}{df\PYZus{}sub}\PY{o}{.}\PY{n}{SDD\PYZus{}d}\PY{o}{.}\PY{n}{item}\PY{p}{(}\PY{p}{)}\PY{p}{,} \PY{n}{df\PYZus{}sub}\PY{o}{.}\PY{n}{LDD\PYZus{}d}\PY{o}{.}\PY{n}{item}\PY{p}{(}\PY{p}{)}\PY{p}{)}
    \PY{k}{if} \PY{n}{df\PYZus{}sub}\PY{o}{.}\PY{n}{kernel}\PY{o}{.}\PY{n}{item}\PY{p}{(}\PY{p}{)} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ExpPow}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:}
        \PY{n}{x} \PY{o}{=} \PY{n}{exp\PYZus{}power}\PY{p}{(}\PY{n}{distance\PYZus{}range}\PY{p}{,} \PY{n}{df\PYZus{}sub}\PY{o}{.}\PY{n}{SDD\PYZus{}d}\PY{o}{.}\PY{n}{item}\PY{p}{(}\PY{p}{)}\PY{p}{,} \PY{n}{df\PYZus{}sub}\PY{o}{.}\PY{n}{LDD\PYZus{}d}\PY{o}{.}\PY{n}{item}\PY{p}{(}\PY{p}{)}\PY{p}{,} \PY{n}{df\PYZus{}sub}\PY{o}{.}\PY{n}{shape\PYZus{}par}\PY{o}{.}\PY{n}{item}\PY{p}{(}\PY{p}{)}\PY{p}{)}
    \PY{k}{if} \PY{n}{df\PYZus{}sub}\PY{o}{.}\PY{n}{kernel}\PY{o}{.}\PY{n}{item}\PY{p}{(}\PY{p}{)} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Logistic}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:}
        \PY{n}{x} \PY{o}{=} \PY{n}{logistic}\PY{p}{(}\PY{n}{distance\PYZus{}range}\PY{p}{,} \PY{n}{df\PYZus{}sub}\PY{o}{.}\PY{n}{SDD\PYZus{}d}\PY{o}{.}\PY{n}{item}\PY{p}{(}\PY{p}{)}\PY{p}{,} \PY{n}{df\PYZus{}sub}\PY{o}{.}\PY{n}{LDD\PYZus{}d}\PY{o}{.}\PY{n}{item}\PY{p}{(}\PY{p}{)}\PY{p}{,} \PY{n}{df\PYZus{}sub}\PY{o}{.}\PY{n}{shape\PYZus{}par}\PY{o}{.}\PY{n}{item}\PY{p}{(}\PY{p}{)}\PY{p}{)}
    \PY{k}{if} \PY{n}{df\PYZus{}sub}\PY{o}{.}\PY{n}{kernel}\PY{o}{.}\PY{n}{item}\PY{p}{(}\PY{p}{)} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{LogSec}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:}
        \PY{n}{x} \PY{o}{=} \PY{n}{log\PYZus{}sech}\PY{p}{(}\PY{n}{distance\PYZus{}range}\PY{p}{,} \PY{n}{df\PYZus{}sub}\PY{o}{.}\PY{n}{SDD\PYZus{}d}\PY{o}{.}\PY{n}{item}\PY{p}{(}\PY{p}{)}\PY{p}{,} \PY{n}{df\PYZus{}sub}\PY{o}{.}\PY{n}{LDD\PYZus{}d}\PY{o}{.}\PY{n}{item}\PY{p}{(}\PY{p}{)}\PY{p}{,} \PY{n}{df\PYZus{}sub}\PY{o}{.}\PY{n}{shape\PYZus{}par}\PY{o}{.}\PY{n}{item}\PY{p}{(}\PY{p}{)}\PY{p}{)}
    
    \PY{c+c1}{\PYZsh{}ax.plot(distance\PYZus{}range,x,color=\PYZsq{}black\PYZsq{},ls=\PYZsq{}\PYZhy{}\PYZhy{}\PYZsq{})}
    \PY{n}{ax}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{distance\PYZus{}range}\PY{p}{,}\PY{n}{x}\PY{p}{,}\PY{n}{ls}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{\PYZhy{}\PYZhy{}}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
    \PY{n}{ax}\PY{o}{.}\PY{n}{grid}\PY{p}{(}\PY{k+kc}{False}\PY{p}{)}
    \PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}xlim}\PY{p}{(}\PY{o}{\PYZhy{}}\PY{l+m+mf}{0.05}\PY{p}{,}\PY{n}{distance\PYZus{}range}\PY{o}{.}\PY{n}{max}\PY{p}{(}\PY{p}{)}\PY{p}{)}
    \PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}ylim}\PY{p}{(}\PY{o}{\PYZhy{}}\PY{l+m+mf}{0.05}\PY{p}{,}\PY{l+m+mf}{1.05}\PY{p}{)}
    \PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}title}\PY{p}{(}\PY{n}{sp}\PY{p}{)}

\PY{n}{ax13}\PY{o}{.}\PY{n}{set\PYZus{}xlabel}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Dispersal distance [m]}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n}{ax14}\PY{o}{.}\PY{n}{set\PYZus{}xlabel}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Dispersal distance [m]}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n}{ax15}\PY{o}{.}\PY{n}{set\PYZus{}xlabel}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Dispersal distance [m]}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n}{ax16}\PY{o}{.}\PY{n}{set\PYZus{}xlabel}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Dispersal distance [m]}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n}{ax1}\PY{o}{.}\PY{n}{set\PYZus{}ylabel}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Dispersal probability}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n}{ax5}\PY{o}{.}\PY{n}{set\PYZus{}ylabel}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Dispersal probability}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n}{ax9}\PY{o}{.}\PY{n}{set\PYZus{}ylabel}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Dispersal probability}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n}{ax13}\PY{o}{.}\PY{n}{set\PYZus{}ylabel}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Dispersal probability}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n}{f}\PY{o}{.}\PY{n}{subplots\PYZus{}adjust}\PY{p}{(}\PY{n}{wspace}\PY{o}{=}\PY{l+m+mf}{0.1}\PY{p}{)}

\PY{n}{plt}\PY{o}{.}\PY{n}{savefig}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Figure\PYZus{}6.png}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{bbox\PYZus{}inches}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{tight}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{dpi}\PY{o}{=}\PY{l+m+mi}{300}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}

    \begin{center}
    \adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{output_51_0.png}
    \end{center}
    { \hspace*{\fill} \\}
    
    \hypertarget{migration-rate-and-life-history-traits}{%
\subsection{Migration rate and life-history
traits}\label{migration-rate-and-life-history-traits}}

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{28}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{c+c1}{\PYZsh{} Function to plot migration rate vs. parameter values }
\PY{c+c1}{\PYZsh{} Color points by group}
\PY{k}{def} \PY{n+nf}{scatterplot\PYZus{}group}\PY{p}{(}\PY{n}{df}\PY{p}{,} \PY{n}{group\PYZus{}name}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{dispersal\PYZus{}syndrome}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}\PY{p}{:}
    \PY{n}{f}\PY{p}{,} \PY{n}{axes} \PY{o}{=} \PY{n}{plt}\PY{o}{.}\PY{n}{subplots}\PY{p}{(}\PY{l+m+mi}{2}\PY{p}{,} \PY{l+m+mi}{2}\PY{p}{,} \PY{n}{sharex}\PY{o}{=}\PY{k+kc}{True}\PY{p}{,} \PY{n}{sharey}\PY{o}{=}\PY{k+kc}{True}\PY{p}{)}
    \PY{p}{(}\PY{n}{ax1}\PY{p}{,} \PY{n}{ax2}\PY{p}{)}\PY{p}{,} \PY{p}{(}\PY{n}{ax3}\PY{p}{,} \PY{n}{ax4}\PY{p}{)} \PY{o}{=} \PY{n}{axes}
    \PY{n}{f}\PY{o}{.}\PY{n}{set\PYZus{}figheight}\PY{p}{(}\PY{l+m+mf}{7.25}\PY{p}{)}
    \PY{n}{f}\PY{o}{.}\PY{n}{set\PYZus{}figwidth}\PY{p}{(}\PY{l+m+mf}{7.25}\PY{p}{)}
    \PY{n}{f}\PY{o}{.}\PY{n}{dpi} \PY{o}{=} \PY{l+m+mi}{300}

    \PY{n}{headers} \PY{o}{=} \PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{SDD\PYZus{}d}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{LDD\PYZus{}d}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{FEC\PYZus{}max}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{GERM\PYZus{}p}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}
    \PY{k}{for} \PY{n}{header}\PY{p}{,}\PY{n}{ax} \PY{o+ow}{in} \PY{n+nb}{zip}\PY{p}{(}\PY{n}{headers}\PY{p}{,}\PY{n}{axes}\PY{o}{.}\PY{n}{flatten}\PY{p}{(}\PY{p}{)}\PY{p}{)}\PY{p}{:}

        \PY{c+c1}{\PYZsh{} Select y, x and scale x}
        \PY{n}{y} \PY{o}{=} \PY{n}{df}\PY{o}{.}\PY{n}{sim}    
        \PY{n}{x} \PY{o}{=} \PY{n}{df}\PY{p}{[}\PY{n}{header}\PY{p}{]} 
        \PY{n}{x} \PY{o}{=} \PY{n}{scaler\PYZus{}0\PYZus{}1}\PY{p}{(}\PY{n}{x}\PY{p}{)}
        \PY{n}{df}\PY{p}{[}\PY{n}{header}\PY{p}{]} \PY{o}{=} \PY{n}{x}
        
        \PY{c+c1}{\PYZsh{} Select group\PYZhy{}color}
        \PY{n}{group\PYZus{}lab} \PY{o}{=} \PY{n}{df}\PY{p}{[}\PY{n}{group\PYZus{}name}\PY{p}{]}\PY{o}{.}\PY{n}{unique}\PY{p}{(}\PY{p}{)}
        \PY{k}{for} \PY{n}{g\PYZus{}lab} \PY{o+ow}{in} \PY{n}{group\PYZus{}lab}\PY{p}{:}
            \PY{n}{group\PYZus{}df} \PY{o}{=} \PY{n}{df}\PY{p}{[}\PY{n}{df}\PY{p}{[}\PY{n}{group\PYZus{}name}\PY{p}{]} \PY{o}{==} \PY{n}{g\PYZus{}lab}\PY{p}{]}
            \PY{n}{ys} \PY{o}{=} \PY{n}{group\PYZus{}df}\PY{o}{.}\PY{n}{sim}
            \PY{n}{xs} \PY{o}{=} \PY{n}{group\PYZus{}df}\PY{p}{[}\PY{n}{header}\PY{p}{]} 
            \PY{n}{ax}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{xs}\PY{p}{,} \PY{n}{ys}\PY{p}{,} \PY{n}{marker}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{o}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{linestyle}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{label}\PY{o}{=}\PY{n}{g\PYZus{}lab}\PY{p}{)}

        \PY{c+c1}{\PYZsh{} Calculate statistics   }
        \PY{c+c1}{\PYZsh{} ref: https://stackoverflow.com/questions/27164114/show\PYZhy{}confidence\PYZhy{}limits\PYZhy{}and\PYZhy{}prediction\PYZhy{}limits\PYZhy{}in\PYZhy{}scatter\PYZhy{}plot}
        \PY{n}{slope}\PY{p}{,} \PY{n}{intercept} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{polyfit}\PY{p}{(}\PY{n}{x}\PY{p}{,} \PY{n}{y}\PY{p}{,} \PY{l+m+mi}{1}\PY{p}{)}
        \PY{n}{y\PYZus{}model} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{polyval}\PY{p}{(}\PY{p}{[}\PY{n}{slope}\PY{p}{,} \PY{n}{intercept}\PY{p}{]}\PY{p}{,} \PY{n}{x}\PY{p}{)}
        \PY{n}{x\PYZus{}mean} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{n}{x}\PY{p}{)}
        \PY{n}{y\PYZus{}mean} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{n}{y}\PY{p}{)}
        \PY{n}{n} \PY{o}{=} \PY{n}{x}\PY{o}{.}\PY{n}{size} \PY{c+c1}{\PYZsh{}number of samples}
        \PY{n}{m} \PY{o}{=} \PY{l+m+mi}{2} \PY{c+c1}{\PYZsh{}number of parameters}
        \PY{n}{dof} \PY{o}{=} \PY{n}{n} \PY{o}{\PYZhy{}} \PY{n}{m}  \PY{c+c1}{\PYZsh{}degrees of freedom}
        \PY{n}{t} \PY{o}{=} \PY{n}{stats}\PY{o}{.}\PY{n}{t}\PY{o}{.}\PY{n}{ppf}\PY{p}{(}\PY{l+m+mf}{0.975}\PY{p}{,} \PY{n}{dof}\PY{p}{)} \PY{c+c1}{\PYZsh{}Students statistic of interval confidence}
        \PY{n}{residual} \PY{o}{=} \PY{n}{y} \PY{o}{\PYZhy{}} \PY{n}{y\PYZus{}model}
        \PY{n}{std\PYZus{}error} \PY{o}{=} \PY{p}{(}\PY{n}{np}\PY{o}{.}\PY{n}{sum}\PY{p}{(}\PY{n}{residual}\PY{o}{*}\PY{o}{*}\PY{l+m+mi}{2}\PY{p}{)} \PY{o}{/} \PY{n}{dof}\PY{p}{)}\PY{o}{*}\PY{o}{*}\PY{l+m+mf}{.5} \PY{c+c1}{\PYZsh{}standard deviation of the error}
        \PY{n}{x\PYZus{}line} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{linspace}\PY{p}{(}\PY{n}{np}\PY{o}{.}\PY{n}{min}\PY{p}{(}\PY{n}{x}\PY{p}{)}\PY{p}{,} \PY{n}{np}\PY{o}{.}\PY{n}{max}\PY{p}{(}\PY{n}{x}\PY{p}{)}\PY{p}{,} \PY{l+m+mi}{100}\PY{p}{)}
        \PY{n}{y\PYZus{}line} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{polyval}\PY{p}{(}\PY{p}{[}\PY{n}{slope}\PY{p}{,} \PY{n}{intercept}\PY{p}{]}\PY{p}{,} \PY{n}{x\PYZus{}line}\PY{p}{)}
        \PY{n}{ci} \PY{o}{=} \PY{n}{t} \PY{o}{*} \PY{n}{std\PYZus{}error} \PY{o}{*} \PY{p}{(}\PY{l+m+mi}{1}\PY{o}{/}\PY{n}{n} \PY{o}{+} \PY{p}{(}\PY{n}{x\PYZus{}line} \PY{o}{\PYZhy{}} \PY{n}{x\PYZus{}mean}\PY{p}{)}\PY{o}{*}\PY{o}{*}\PY{l+m+mi}{2} \PY{o}{/} \PY{n}{np}\PY{o}{.}\PY{n}{sum}\PY{p}{(}\PY{p}{(}\PY{n}{x} \PY{o}{\PYZhy{}} \PY{n}{x\PYZus{}mean}\PY{p}{)}\PY{o}{*}\PY{o}{*}\PY{l+m+mi}{2}\PY{p}{)}\PY{p}{)}\PY{o}{*}\PY{o}{*}\PY{l+m+mf}{.5}

        \PY{c+c1}{\PYZsh{} Draw regression line and confidence interval}
        \PY{n}{ax}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{x}\PY{p}{,} \PY{n}{slope}\PY{o}{*}\PY{n}{x}\PY{o}{+}\PY{n}{intercept}\PY{p}{,} \PY{n}{color}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{black}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{linewidth}\PY{o}{=}\PY{l+m+mi}{1}\PY{p}{)}  
        \PY{n}{ax}\PY{o}{.}\PY{n}{fill\PYZus{}between}\PY{p}{(}\PY{n}{x\PYZus{}line}\PY{p}{,} \PY{n}{y\PYZus{}line} \PY{o}{+} \PY{n}{ci}\PY{p}{,} \PY{n}{y\PYZus{}line} \PY{o}{\PYZhy{}} \PY{n}{ci}\PY{p}{,} \PY{n}{color} \PY{o}{=} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{skyblue}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}

        \PY{c+c1}{\PYZsh{} Add headers}
        \PY{k}{if} \PY{n}{header} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{SDD\PYZus{}d}\PY{l+s+s1}{\PYZsq{}} \PY{p}{:}
            \PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}title}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{SDD\PYZdl{}\PYZus{}d\PYZdl{}}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
            \PY{n}{ax}\PY{o}{.}\PY{n}{legend}\PY{p}{(}\PY{n}{frameon}\PY{o}{=}\PY{k+kc}{False}\PY{p}{)}
        \PY{k}{if} \PY{n}{header} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{LDD\PYZus{}d}\PY{l+s+s1}{\PYZsq{}} \PY{p}{:}
            \PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}title}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{LDD\PYZdl{}\PYZus{}d\PYZdl{}}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)} 
        \PY{k}{if} \PY{n}{header} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{FEC\PYZus{}max}\PY{l+s+s1}{\PYZsq{}} \PY{p}{:}
            \PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}title}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{FEC\PYZdl{}\PYZus{}}\PY{l+s+si}{\PYZob{}max\PYZcb{}}\PY{l+s+s1}{\PYZdl{}}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)} 
        \PY{k}{if} \PY{n}{header} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{GERM\PYZus{}p}\PY{l+s+s1}{\PYZsq{}} \PY{p}{:}
            \PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}title}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{GERM\PYZdl{}\PYZus{}p\PYZdl{}}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)} 

    \PY{n}{ax1}\PY{o}{.}\PY{n}{set\PYZus{}ylabel}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Migration rate [m yr\PYZdl{}\PYZca{}}\PY{l+s+s1}{\PYZob{}}\PY{l+s+s1}{\PYZhy{}1\PYZcb{}\PYZdl{}]}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
    \PY{n}{ax3}\PY{o}{.}\PY{n}{set\PYZus{}ylabel}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Migration rate [m yr\PYZdl{}\PYZca{}}\PY{l+s+s1}{\PYZob{}}\PY{l+s+s1}{\PYZhy{}1\PYZcb{}\PYZdl{}]}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
    \PY{n}{ax3}\PY{o}{.}\PY{n}{set\PYZus{}xlabel}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Scaled parameter value}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
    \PY{n}{ax4}\PY{o}{.}\PY{n}{set\PYZus{}xlabel}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Scaled parameter value}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
    
    \PY{c+c1}{\PYZsh{} Add general title}
    \PY{k}{if} \PY{p}{(}\PY{n}{group\PYZus{}name} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{dispersal\PYZus{}syndrome}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}\PY{p}{:}
        \PY{n}{f}\PY{o}{.}\PY{n}{suptitle}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Dispersal syndrome}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{fontweight}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{bold}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
    \PY{k}{if} \PY{p}{(}\PY{n}{group\PYZus{}name} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{kernel\PYZus{}shape}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}\PY{p}{:}
        \PY{n}{f}\PY{o}{.}\PY{n}{suptitle}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Kernel shape}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{fontweight}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{bold}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
    \PY{n}{f}\PY{o}{.}\PY{n}{subplots\PYZus{}adjust}\PY{p}{(}\PY{n}{wspace}\PY{o}{=}\PY{l+m+mf}{0.1}\PY{p}{,}\PY{n}{top}\PY{o}{=}\PY{l+m+mf}{0.91}\PY{p}{)}

\PY{c+c1}{\PYZsh{} Groups: dispersal\PYZus{}syndrome, kernel\PYZus{}shape}
\PY{n}{scatterplot\PYZus{}group}\PY{p}{(}\PY{n}{df}\PY{o}{=}\PY{n}{best\PYZus{}all\PYZus{}df}\PY{p}{,} \PY{n}{group\PYZus{}name}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{dispersal\PYZus{}syndrome}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{savefig}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Figure\PYZus{}S4.png}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{bbox\PYZus{}inches}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{tight}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{dpi}\PY{o}{=}\PY{l+m+mi}{300}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}

    \begin{center}
    \adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{output_53_0.png}
    \end{center}
    { \hspace*{\fill} \\}
    
    \hypertarget{uncertainty-analysis}{%
\section{Uncertainty analysis}\label{uncertainty-analysis}}

In order to select the best model structure, we quantified the utility U
of each model framework as a synthesis of both sensitivity and error
(\href{https://doi.org/10.1016/S0304-3800(00)00390-2}{Snowling and
Kramer, 2001}):

\[U = \sqrt{2} - \sqrt{(\frac{S}{S_{max}})^2+(\frac{E}{E_{max}})^2} \]

where the sensitivity \(S\) and error \(E\) are calculated according to
the equations above for \(II_2\) and \(RMSE\) across species and
parameters, respectively, whereas \(S_{max}\) and \(E_{max}\) are the
maximum sensitivity and error across models, respectively.

Additionally, we calculated an index of model complexity:

\[C = \sum_{j=1}^{N} \sum_{l=1}^{n_j} p_l r_l \]

where \(N\) is the number of state variable, \(n_j\) is the number of
processes implemented for each state variable \(j\), \(p_l\) is the
number of parameters of each process \(l\), and \(r_l\) is the number of
equations used to formulate each process.

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{29}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{c+c1}{\PYZsh{}\PYZsh{} Calculate Sensitivities across species for both models}
\PY{n}{S\PYZus{}model1} \PY{o}{=} \PY{n}{SA\PYZus{}input}\PY{o}{.}\PY{n}{groupby}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameters}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}\PY{o}{.}\PY{n}{agg}\PY{p}{(}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{mean}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{n}{f\PYZus{}ste}\PY{p}{]}\PY{p}{)}\PY{o}{.}\PY{n}{T}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{II2}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}
\PY{n}{SA\PYZus{}fatkernels\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{II2}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{p}{(}\PY{n}{SA\PYZus{}fatkernels\PYZus{}input}\PY{o}{.}\PY{n}{MigRate\PYZus{}Max} \PY{o}{\PYZhy{}} \PY{n}{SA\PYZus{}fatkernels\PYZus{}input}\PY{o}{.}\PY{n}{MigRate\PYZus{}Min}\PY{p}{)} \PY{o}{/} \PY{n}{SA\PYZus{}fatkernels\PYZus{}input}\PY{o}{.}\PY{n}{MigRate\PYZus{}Max}
\PY{n}{S\PYZus{}model2} \PY{o}{=} \PY{n}{SA\PYZus{}fatkernels\PYZus{}input}\PY{o}{.}\PY{n}{groupby}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Parameters}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}\PY{o}{.}\PY{n}{agg}\PY{p}{(}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{mean}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{n}{f\PYZus{}ste}\PY{p}{]}\PY{p}{)}\PY{o}{.}\PY{n}{T}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{II2}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}

\PY{c+c1}{\PYZsh{} Create dataframe to plot}
\PY{n}{S\PYZus{}toPlot} \PY{o}{=} \PY{n}{pd}\PY{o}{.}\PY{n}{concat}\PY{p}{(}\PY{p}{[}\PY{n}{S\PYZus{}model1}\PY{p}{,} \PY{n}{S\PYZus{}model2}\PY{p}{]}\PY{p}{)}
\PY{n}{S\PYZus{}toPlot}\PY{o}{.}\PY{n}{index} \PY{o}{=} \PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{mean\PYZus{}model1}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ste\PYZus{}model1}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{mean\PYZus{}model2}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ste\PYZus{}model2}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}
\PY{n}{S\PYZus{}toPlot}\PY{o}{.}\PY{n}{columns} \PY{o}{=} \PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{S\PYZus{}FEC\PYZus{}max}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{S\PYZus{}GERM\PYZus{}p}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{S\PYZus{}LDD\PYZus{}d}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{S\PYZus{}SDD\PYZus{}d}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}

\PY{c+c1}{\PYZsh{} Calculate II2 for shape parameter (only model 2)}
\PY{n}{species} \PY{o}{=} \PY{n}{KA\PYZus{}input}\PY{o}{.}\PY{n}{Species}\PY{o}{.}\PY{n}{unique}\PY{p}{(}\PY{p}{)}
\PY{n}{II2s} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{zeros}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{species}\PY{p}{)}\PY{p}{)}
\PY{n}{pos} \PY{o}{=} \PY{l+m+mi}{0}
\PY{k}{for} \PY{n}{sp} \PY{o+ow}{in} \PY{n}{species}\PY{p}{:}
    \PY{c+c1}{\PYZsh{} Subset for best kernel per species}
    \PY{n}{sp\PYZus{}sub} \PY{o}{=} \PY{n}{KA\PYZus{}input}\PY{p}{[}\PY{n}{KA\PYZus{}input}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{n}{sp}\PY{p}{]}
    \PY{n}{best\PYZus{}kernel\PYZus{}sp} \PY{o}{=} \PY{n}{rmse\PYZus{}all\PYZus{}df}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{n}{rmse\PYZus{}all\PYZus{}df}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Species}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{n}{sp}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{kernel}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{o}{.}\PY{n}{tolist}\PY{p}{(}\PY{p}{)}
    \PY{n}{best\PYZus{}kernel\PYZus{}sub} \PY{o}{=} \PY{n}{sp\PYZus{}sub}\PY{p}{[}\PY{n}{sp\PYZus{}sub}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{kernel\PYZus{}fun}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{==} \PY{n+nb}{str}\PY{p}{(}\PY{n}{best\PYZus{}kernel\PYZus{}sp}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{)}\PY{p}{]}
    
    \PY{c+c1}{\PYZsh{} Get the minimum and maximum simulated migration speed}
    \PY{n}{y\PYZus{}min} \PY{o}{=} \PY{n}{best\PYZus{}kernel\PYZus{}sub}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{n}{best\PYZus{}kernel\PYZus{}sub}\PY{o}{.}\PY{n}{SIM} \PY{o}{==} \PY{n+nb}{min}\PY{p}{(}\PY{n}{best\PYZus{}kernel\PYZus{}sub}\PY{o}{.}\PY{n}{SIM}\PY{p}{)}\PY{p}{]}\PY{o}{.}\PY{n}{SIM}\PY{o}{.}\PY{n}{tolist}\PY{p}{(}\PY{p}{)}
    \PY{n}{y\PYZus{}min} \PY{o}{=} \PY{n}{y\PYZus{}min}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}
    \PY{n}{y\PYZus{}max} \PY{o}{=} \PY{n}{best\PYZus{}kernel\PYZus{}sub}\PY{o}{.}\PY{n}{loc}\PY{p}{[}\PY{n}{best\PYZus{}kernel\PYZus{}sub}\PY{o}{.}\PY{n}{SIM} \PY{o}{==} \PY{n+nb}{max}\PY{p}{(}\PY{n}{best\PYZus{}kernel\PYZus{}sub}\PY{o}{.}\PY{n}{SIM}\PY{p}{)}\PY{p}{]}\PY{o}{.}\PY{n}{SIM}\PY{o}{.}\PY{n}{tolist}\PY{p}{(}\PY{p}{)}
    \PY{n}{y\PYZus{}max} \PY{o}{=} \PY{n}{y\PYZus{}max}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}
    
    \PY{c+c1}{\PYZsh{} Calculate II2 per species}
    \PY{n}{II2} \PY{o}{=} \PY{p}{(}\PY{n}{y\PYZus{}max} \PY{o}{\PYZhy{}} \PY{n}{y\PYZus{}min}\PY{p}{)} \PY{o}{/} \PY{n}{y\PYZus{}max}
    \PY{n}{II2s}\PY{p}{[}\PY{n}{pos}\PY{p}{]} \PY{o}{=} \PY{n}{II2}
    \PY{n}{pos} \PY{o}{=} \PY{n}{pos} \PY{o}{+} \PY{l+m+mi}{1}

\PY{c+c1}{\PYZsh{} Calculate mean and ste II2 across species (shape parameter)}
\PY{n}{II2\PYZus{}mean\PYZus{}shapepar} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{n}{II2s}\PY{p}{)}
\PY{n}{II2\PYZus{}ste\PYZus{}shapepar} \PY{o}{=} \PY{n}{II2s}\PY{o}{.}\PY{n}{std}\PY{p}{(}\PY{p}{)} \PY{o}{/} \PY{n}{np}\PY{o}{.}\PY{n}{sqrt}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{II2s}\PY{p}{)}\PY{p}{)}
\PY{n}{S\PYZus{}toPlot}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{S\PYZus{}shape\PYZus{}par}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{p}{[}\PY{l+m+mi}{0}\PY{p}{,}\PY{l+m+mi}{0}\PY{p}{,}\PY{n}{II2\PYZus{}mean\PYZus{}shapepar}\PY{p}{,}\PY{n}{II2\PYZus{}ste\PYZus{}shapepar}\PY{p}{]} \PY{c+c1}{\PYZsh{}only model 2}

\PY{c+c1}{\PYZsh{}\PYZsh{} Calculate mean Sensitivity S across parameters }
\PY{n}{S\PYZus{}mean\PYZus{}model1} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{n}{S\PYZus{}toPlot}\PY{o}{.}\PY{n}{T}\PY{o}{.}\PY{n}{mean\PYZus{}model1}\PY{p}{)}
\PY{n}{S\PYZus{}mean\PYZus{}model2} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{n}{S\PYZus{}toPlot}\PY{o}{.}\PY{n}{T}\PY{o}{.}\PY{n}{mean\PYZus{}model2}\PY{p}{)}

\PY{c+c1}{\PYZsh{} Calculate average of observed 75thile migration rates across species}
\PY{n}{obs\PYZus{}mean} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{n}{best\PYZus{}EVA\PYZus{}df}\PY{o}{.}\PY{n}{obs\PYZus{}75ile}\PY{p}{)}

\PY{c+c1}{\PYZsh{}\PYZsh{} Calculate Error E across species}
\PY{n}{E\PYZus{}model1} \PY{o}{=} \PY{n}{rmse\PYZus{}perc}\PY{p}{(}\PY{n}{best\PYZus{}EVA\PYZus{}df}\PY{o}{.}\PY{n}{sim}\PY{p}{,} \PY{n}{best\PYZus{}EVA\PYZus{}df}\PY{o}{.}\PY{n}{obs\PYZus{}75ile}\PY{p}{,} \PY{n}{obs\PYZus{}mean}\PY{p}{)} \PY{o}{/} \PY{l+m+mi}{100}
\PY{n}{E\PYZus{}model2} \PY{o}{=} \PY{n}{rmse\PYZus{}perc}\PY{p}{(}\PY{n}{rmse\PYZus{}all\PYZus{}df}\PY{o}{.}\PY{n}{sim}\PY{p}{,} \PY{n}{rmse\PYZus{}all\PYZus{}df}\PY{o}{.}\PY{n}{obs\PYZus{}75ile}\PY{p}{,} \PY{n}{obs\PYZus{}mean}\PY{p}{)} \PY{o}{/} \PY{l+m+mi}{100}
\PY{n}{S\PYZus{}toPlot}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Error}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{o}{=} \PY{p}{[}\PY{n}{E\PYZus{}model1}\PY{p}{,} \PY{l+m+mi}{0}\PY{p}{,} \PY{n}{E\PYZus{}model2}\PY{p}{,} \PY{l+m+mi}{0}\PY{p}{]}

\PY{c+c1}{\PYZsh{} Find S\PYZus{}max (rounded\PYZhy{}up maximum)}
\PY{n}{S\PYZus{}max} \PY{o}{=} \PY{n+nb}{max}\PY{p}{(}\PY{n}{S\PYZus{}mean\PYZus{}model1}\PY{p}{,} \PY{n}{S\PYZus{}mean\PYZus{}model2}\PY{p}{)}
\PY{n}{S\PYZus{}max} \PY{o}{=} \PY{n+nb}{round}\PY{p}{(}\PY{n}{S\PYZus{}max}\PY{p}{,}\PY{l+m+mi}{1}\PY{p}{)} \PY{o}{+} \PY{l+m+mf}{0.1}

\PY{c+c1}{\PYZsh{} Find E\PYZus{}max (rounded\PYZhy{}up maximum)}
\PY{n}{E\PYZus{}max} \PY{o}{=} \PY{n+nb}{max}\PY{p}{(}\PY{n}{E\PYZus{}model1}\PY{p}{,} \PY{n}{E\PYZus{}model2}\PY{p}{)}
\PY{n}{E\PYZus{}max} \PY{o}{=} \PY{n+nb}{round}\PY{p}{(}\PY{n}{E\PYZus{}max}\PY{p}{,}\PY{l+m+mi}{1}\PY{p}{)} \PY{o}{+} \PY{l+m+mf}{0.1}

\PY{c+c1}{\PYZsh{}\PYZsh{} Calculate Utility U}
\PY{n}{U\PYZus{}model1} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{sqrt}\PY{p}{(}\PY{l+m+mi}{2}\PY{p}{)} \PY{o}{\PYZhy{}} \PY{n}{np}\PY{o}{.}\PY{n}{sqrt}\PY{p}{(}\PY{p}{(}\PY{n}{S\PYZus{}mean\PYZus{}model1} \PY{o}{/} \PY{n}{S\PYZ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ots}\PY{p}{(}\PY{p}{)}
\PY{n}{f}\PY{o}{.}\PY{n}{set\PYZus{}figheight}\PY{p}{(}\PY{l+m+mf}{3.54}\PY{p}{)}
\PY{n}{f}\PY{o}{.}\PY{n}{set\PYZus{}figwidth}\PY{p}{(}\PY{l+m+mf}{3.54}\PY{p}{)}
\PY{n}{f}\PY{o}{.}\PY{n}{dpi} \PY{o}{=} \PY{l+m+mi}{300}

\PY{n}{rects1} \PY{o}{=} \PY{n}{ax}\PY{o}{.}\PY{n}{bar}\PY{p}{(}\PY{n}{x} \PY{o}{\PYZhy{}} \PY{n}{width}\PY{o}{/}\PY{l+m+mi}{2}\PY{p}{,} \PY{n}{S\PYZus{}toPlot}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{mean\PYZus{}model1}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{,} \PY{n}{width}\PY{p}{,} \PY{n}{yerr}\PY{o}{=}\PY{n}{S\PYZus{}toPlot}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ste\PYZus{}model1}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{,} \PY{n}{label}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Model 1}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n}{rects2} \PY{o}{=} \PY{n}{ax}\PY{o}{.}\PY{n}{bar}\PY{p}{(}\PY{n}{x} \PY{o}{+} \PY{n}{width}\PY{o}{/}\PY{l+m+mi}{2}\PY{p}{,} \PY{n}{S\PYZus{}toPlot}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{mean\PYZus{}model2}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{,} \PY{n}{width}\PY{p}{,} \PY{n}{yerr}\PY{o}{=}\PY{n}{S\PYZus{}toPlot}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ste\PYZus{}model2}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{,} \PY{n}{label}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Model 2}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}

\PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}xticks}\PY{p}{(}\PY{n}{x}\PY{p}{)}
\PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}xticklabels}\PY{p}{(}\PY{n}{labels}\PY{p}{)}
\PY{n}{ax}\PY{o}{.}\PY{n}{set\PYZus{}ylabel}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Uncertainty Indexes}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n}{ax}\PY{o}{.}\PY{n}{legend}\PY{p}{(}\PY{n}{frameon}\PY{o}{=}\PY{k+kc}{False}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{xticks}\PY{p}{(}\PY{n}{rotation}\PY{o}{=}\PY{l+m+mi}{45}\PY{p}{)}

\PY{c+c1}{\PYZsh{} Export figure   }
\PY{n}{plt}\PY{o}{.}\PY{n}{savefig}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Figure\PYZus{}7.png}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{bbox\PYZus{}inches}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{tight}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{dpi}\PY{o}{=}\PY{l+m+mi}{300}\PY{p}{)}

\PY{c+c1}{\PYZsh{} Calculate Complexity C}
\PY{n}{C\PYZus{}model1} \PY{o}{=} \PY{l+m+mi}{5}
\PY{n}{C\PYZus{}model2} \PY{o}{=} \PY{l+m+mi}{6}

\PY{c+c1}{\PYZsh{} Print results}
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Model 1 | Complexity: }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n+nb}{str}\PY{p}{(}\PY{n+nb}{round}\PY{p}{(}\PY{n}{C\PYZus{}model1}\PY{p}{,}\PY{l+m+mi}{2}\PY{p}{)}\PY{p}{)}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{; Sensitivity: }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n+nb}{str}\PY{p}{(}\PY{n+nb}{round}\PY{p}{(}\PY{n}{S\PYZus{}mean\PYZus{}model1}\PY{p}{,}\PY{l+m+mi}{2}\PY{p}{)}\PY{p}{)}\PY{o}{+}
      \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{; Error: }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n+nb}{str}\PY{p}{(}\PY{n+nb}{round}\PY{p}{(}\PY{n}{E\PYZus{}model1}\PY{o}{*}\PY{l+m+mi}{100}\PY{p}{,}\PY{l+m+mi}{2}\PY{p}{)}\PY{p}{)}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{\PYZpc{}}\PY{l+s+s1}{; Utility: }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n+nb}{str}\PY{p}{(}\PY{n+nb}{round}\PY{p}{(}\PY{n}{U\PYZus{}model1}\PY{p}{,}\PY{l+m+mi}{2}\PY{p}{)}\PY{p}{)}\PY{o}{+}
     \PY{l+s+s1}{\PYZsq{}}\PY{l+s+se}{\PYZbs{}n}\PY{l+s+s1}{Model 2 | Complexity: }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n+nb}{str}\PY{p}{(}\PY{n+nb}{round}\PY{p}{(}\PY{n}{C\PYZus{}model2}\PY{p}{,}\PY{l+m+mi}{2}\PY{p}{)}\PY{p}{)}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{; Sensitivity: }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n+nb}{str}\PY{p}{(}\PY{n+nb}{round}\PY{p}{(}\PY{n}{S\PYZus{}mean\PYZus{}model2}\PY{p}{,}\PY{l+m+mi}{2}\PY{p}{)}\PY{p}{)}\PY{o}{+}
      \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{; Error: }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n+nb}{str}\PY{p}{(}\PY{n+nb}{round}\PY{p}{(}\PY{n}{E\PYZus{}model2}\PY{o}{*}\PY{l+m+mi}{100}\PY{p}{,}\PY{l+m+mi}{2}\PY{p}{)}\PY{p}{)}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{\PYZpc{}}\PY{l+s+s1}{; Utility: }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n+nb}{str}\PY{p}{(}\PY{n+nb}{round}\PY{p}{(}\PY{n}{U\PYZus{}model2}\PY{p}{,}\PY{l+m+mi}{2}\PY{p}{)}\PY{p}{)}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}

    \begin{Verbatim}[commandchars=\\\{\}]
Model 1 | Complexity: 5; Sensitivity: 0.27; Error: 89.94\%; Utility: 0.37
Model 2 | Complexity: 6; Sensitivity: 0.42; Error: 25.14\%; Utility: 0.54
    \end{Verbatim}

    \begin{center}
    \adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{output_55_1.png}
    \end{center}
    { \hspace*{\fill} \\}
    

    % Add a bibliography block to the postdoc
    
    
    
\end{document}