figaro.diagnostic module

figaro.diagnostic.angular_coefficient(x, y)[source]

Angular coefficient obtained from linear regression.

Parameters:
  • x (np.ndarray) – independent variables

  • y (np.ndarray) – dependent variables

Returns:

angular coefficient

Return type:

double

figaro.diagnostic.autocorrelation(draws, bounds=None, out_folder='.', name='event', n_points=1000, save=True, show=False)[source]

Compute autocorrelation of a set of draws and produce the relevant plot

Parameters:
  • draws (iterable) – container of mixture instances

  • bounds (iterable) – bounds of the interval over which the distributions are evaluated. It has to be passed as [[xmin,xmax]]. If None, draws bounds are used.

  • out_folder (str or Path) – output folder

  • name (str) – name to be given to outputs

  • n_points (int) – number of points for linspace

  • save (bool) – whether to save the plot or not

  • show (bool) – whether to show the plot during the run or not

Returns:

autocorrelation

Return type:

np.ndarray

figaro.diagnostic.compute_angular_coefficients(x, L=None)[source]

Given an array of points x, computes the angular coefficient for each adjacent chunk of length L.

Parameters:
  • x (np.ndarray) – array of points

  • L (int) – window length

Returns:

array of angular coefficients

Return type:

np.ndarray

figaro.diagnostic.compute_autocorrelation(draws, mean, dx)[source]

Computes autocorrelation of subsequent draws as <∫(draw[i]-mean)*(draw[i+t]-mean)*dx/∫(draw[i]-mean)**2*dx>

Parameters:
  • draws (np.ndarray) – evaluated mixtures (2d array)

  • mean (np.ndarray) – bin-wise mean of evaluated mixtures (1d array)

  • dx (double) – integration measure

Returns:

upper bound of autocorrelation length np.ndarray: autocorrelation function

Return type:

int

figaro.diagnostic.compute_entropy(draws, n_draws=1000.0, return_error=False)[source]

Compute entropy for a list of realisations of the DPGMM using Monte Carlo integration

Parameters:
  • draws (iterable) – container of mixture class instaces (see mixture.py for definition)

  • n_draws (double) – number of MC draws

Returns:

entropy values

Return type:

np.ndarray

figaro.diagnostic.compute_entropy_single_draw(mixture, n_draws=1000.0, return_error=False)[source]

Compute entropy for a single realisation of the DPGMM using Monte Carlo integration

Parameters:
  • mixture (mixture) – instance of mixture class (see mixture.py for definition)

  • n_draws (double) – number of MC draws

Returns:

entropy value

Return type:

double

figaro.diagnostic.entropy(draws, out_folder='.', exp_entropy=None, name='event', n_draws=10000.0, step=1, show=False, save=True)[source]

Compute entropy of a set of draws and produce the relevant plot

Parameters:
  • draws (iterable) – container of mixture instances

  • out_folder (str or Path) – output folder

  • exp_entropy (double) – expected value for entropy, expressed in bits

  • name (str) – name to be given to outputs

  • n_draws (int) – number of MC draws

  • step (int) – number of draws between entropy samples (if downsampled by some other method, for plotting purposes only)

  • save (bool) – whether to save the plot or not

  • show (bool) – whether to show the plot during the run or not

Returns:

entropy

Return type:

np.ndarray

figaro.diagnostic.plot_angular_coefficient(entropy, L=500, ac_expected=None, out_folder='.', name='event', step=1, show=False, save=True)[source]

Compute entropy angular coefficient and produce the relevant plot

Parameters:
  • entropy (iterable) – container of mixture instances

  • L (int) – window lenght

  • ac_expected (double) – expected angular coefficient

  • out_folder (str or Path) – output folder

  • name (str) – name to be given to outputs

  • step (int) – number of draws between entropy samples (if downsampled by some other method, for plotting purposes only)

  • save (bool) – whether to save the plot or not

  • show (bool) – whether to show the plot during the run or not

Returns:

angular coefficients

Return type:

np.ndarray