Monte Carlo Markov Chain analysis

MCMC_analysis.cost_sensitivity()

Analysis of GDP sensitivity to changes in the inputs. Sets all levers to 2 and moves each lever to 3 at a time, reading its corresponding output.

MCMC_analysis.find_lever_URL_position(name)

Given a lever name, return its position in the URL

MCMC_analysis.find_lever_ref(name, box=1)

Given a lever name and box position, return its XPath

MCMC_analysis.find_lever_sensitivities()

Analysis of climate impact sensitivity to changes in the inputs. Takes the default pathway (TIAM UCL 2DS) and changes each lever value at a time (between 1.0 and 4.0), reading its corresponding output.

MCMC_analysis.generate_mu_proposal_2D(all_levers_current, all_thresholds, address='http://tool.globalcalculator.org/globcalc.html?levers=22rfoe2e13be1111c2c2c1n31hfjdcef222hp233f211111fn2211111111/dashboard/en')

Used in MCMC. Takes arrays containing all current values and thresholds and generates a new mu proposal

MCMC_analysis.lever_step(lever_value, thresholds)

Naive modification of the Metropolis Hastings algorithm - moves a lever randomly up or down by 0.1. Return the new lever value

MCMC_analysis.log_training_sample()

Generate training sample and save it to a CSV file

MCMC_analysis.map_to_letter(value)

Takes a float value in the range [1, 4.0] and returns its corresponding URL character

MCMC_analysis.move_lever(lever, value, costs=False, address='http://tool.globalcalculator.org/globcalc.html?levers=22rfoe2e13be1111c2c2c1n31hfjdcef222hp233f211111fn2211111111/dashboard/en')

Sets a lever to a given value. Reads corresponding temperature and, if selected, cost values.

Args:

  • lever (list of strings): Contains the names of the levers to be moved.

  • value (list of floats): Contains the value of the levers to be moved - Automatically matched to lever names.

  • costs (optional, boolean): Flag to decide whether to read cost values or not.

  • address (optional, string): URL address corresponding to given lever combination.

MCMC_analysis.multi_sampler_2D(observations, all_levers_current, all_thresholds, samples=4, mu_init=[3000, 0.5], plot=False, mu_prior_mu=[3100, 1], mu_prior_sd=[[200, 0], [0, 0.3]], imprimir=False)

Implementation of a variant of Markov Chain Monte-Carlo (MCMC). Given some prior information and a set of observations, this function performs MCMC. It calculates the posterior distribution of temperature and cost values and the lever values used in doing so.

Args:

  • observations (list of lists (N x 2)): Contains temperature and cost values.

  • all_levers_current (list): Current values of input levers.

  • all_thresholds (list of lists (48 x 2)): Each entry contains an upper and lower bound for each lever.

  • samples (int): Number of MCMC steps.

  • mu_init (list): Initial guess of temperature and cost values.

  • plot (boolean): Flag used for plotting.

  • mu_prior_mu (list): Mean temperature and cost values of prior distribution (assummed Gaussian).

  • mu_prior_sd (list of lists (2 x 2)): Diagonal matrix containing the standard deviation of the 2D prior.

  • imprimir (boolean): Flag used for printing useful information.

Returns:

  • posterior (list of lists (N x 2)): Contains trace of all temperature and cost values.

  • accepted (list): Contains all the lever values corresponding the proposal accepted by MCMC.

  • rate (list): Contains the probability of each temperature and cost pair proposal.

  • accepted_values (list of lists (M x 2)): Contains accepted temperature and cost values.

MCMC_analysis.new_URL(name, value, address='http://tool.globalcalculator.org/globcalc.html?levers=l2wz222CBpp3pC3f2Dw3DC3plzgj1tA13pp2p223ri11111p22211111111/dashboard/en')

Generate a new URL address by changing a lever value.

Args:

  • Name (string): Target lever name

  • Value (float): Target value for lever

  • Address (string): URL where lever will be changed. Set to TIAM-UCL 2DS pathway by default.

Returns:

URL after changes are applied.

MCMC_analysis.new_lever_combination()

Returns an array containing a random value for each lever

MCMC_analysis.open_lever_menus()

Opens all the lever menus of the Global Calculator

MCMC_analysis.random_URL()

Generates and return a random URL (address) and its corresponding lever values (input_levers)

MCMC_analysis.random_lever_value(lever_name)

Moves a given lever (lever_name) to a random position between 1 and 3.9

MCMC_analysis.read_CO2()

For the current lever combination, return the CO2 level (GtCO2)

MCMC_analysis.read_lever(name)

Given a lever name, return its ID

MCMC_analysis.read_outputs()

Reads all outputs and returns them as a list

MCMC_analysis.save_all()

Save all accepted lever combinations, temperature and cost values, trace and probability values to a .XLSX file

MCMC_analysis.set_lever(target, lever_name)

Set a given lever (lever_name) to a value (target) by clicking on it - Using a minimum number of clicks.

MCMC_analysis.set_to_benchmark()

Set Global Calculator to TIMA-UCL 2DS’s benchmark pathway

MCMC_analysis.training_sample()

Generates a random training sample. It returns the input (input_levers) and output (random_output) values