Simulation module

Simulation functions

b3alien.simulation.get_bootstrap_errors(annual_time, annual_rate, iterations=100)[source]

Perform bootstrap resampling to estimate the standard errors of the parameters and C1 values.

Parameters:
  • annual_time (pandas Series) – Time points

  • annual_rate (pandas Series) – Rates corresponding to the time points

  • iterations (int) – Number of bootstrap iterations to perform

Returns:

  • vec1_mean – mean of the fitted parameters across bootstrap samples

  • vec1_std – standard error of the fitted parameters across bootstrap samples

  • C1_mean – mean of the C1 values across bootstrap samples

  • C1_std – standard error of the C1 values across bootstrap samples

b3alien.simulation.parallel_bootstrap_solow_costello(annual_time_gbif, annual_rate_gbif, n_iterations=1000, ci=95)[source]

Perform parallel bootstrapping of the Solow-Costello model to estimate confidence intervals.

Parameters:
  • annual_time_gbif (pandas.Series) – Time series of the rate of establishment.

  • annual_rate_gbif (pandas.Series) – Rates corresponding to the time series.

  • n_iterations (int, optional) – Number of bootstrap iterations. Default is 1000.

  • ci (float, optional) – Confidence interval percentage. Default is 95.

Returns:

A dictionary containing bootstrap results and confidence intervals.

Return type:

dict

b3alien.simulation.plot_with_confidence(T, observed, results)[source]

Plot the observed cumulative discoveries with bootstrap confidence intervals.

Parameters:
  • T (pandas.Series) – Time series of the rate of establishment.

  • observed (pandas.Series) – Observed cumulative discoveries.

  • results (dict) – Dictionary containing bootstrap results and confidence intervals.

b3alien.simulation.run_bootstrap_analysis(time_list, rate_list, n_iterations=200)[source]

Run the bootstrap analysis in parallel and aggregate results into a DataFrame. :param time_list: Time points for the analysis. :type time_list: list or pandas Series :param rate_list: Rates corresponding to the time points. :type rate_list: list or pandas Series :param n_iterations: Number of bootstrap iterations to perform. :type n_iterations: int

Returns:

A DataFrame containing the mean annual rates, cumulative values, and confidence intervals.

Return type:

pandas DataFrame

b3alien.simulation.simulate_solow_costello(annual_time_gbif, annual_rate_gbif, vis=False)[source]

Solow-Costello simulation of the rate of establishment.

Parameters:
  • annual_time_gbif (pandas.Series) – Time series of the rate of establishment.

  • annual_rate_gbif (pandas.Series) – Rates corresponding to the time series.

  • vis (bool, optional) – Create a plot of the simulation. Default is False.

Returns:

  • C1 (numpy.Series) – Result of the simulation.

  • val1 (numpy.Series) – Parameters of the fitting.

b3alien.simulation.simulate_solow_costello_scipy(annual_time_gbif, annual_rate_gbif, vis=False)[source]

Solow-Costello simulation of the rate of establishment. Uses scipy’s minimize for optimization.

Parameters:
  • annual_time_gbif (pandas.Series) – Time series of the rate of establishment.

  • annual_rate_gbif (pandas.Series) – Rates corresponding to the time series.

  • vis (bool, optional) – Create a plot of the simulation. Default is False.

Returns:

  • C1 (numpy.Series) – Result of the simulation.

  • val1 (numpy.Series) – Parameters of the fitting.