API

BipartiteGraph class

This module contains the class BipartiteGraph that handles the graph object, and many useful functions.

The solver functions are located here for compatibility with the numba package.

class bicm.graph_classes.BipartiteGraph(biadjacency=None, adjacency_list=None, edgelist=None, degree_sequences=None)[source]

Bases: object

Bipartite Graph class for undirected binary bipartite networks.

This class handles the bipartite graph object to compute the Bipartite Configuration Model (BiCM), which can be used as a null model for the analysis of undirected and binary bipartite networks. The class provides methods for calculating the probabilities and matrices of the null model and for projecting the bipartite network on its layers. The object can be initialized passing one of the parameters, or the nodes and edges can be passed later.

Parameters:
  • biadjacency (numpy.array, scipy.sparse, list, optional) – binary input matrix describing the biadjacency matrix of a bipartite graph with the nodes of one layer along the rows and the nodes of the other layer along the columns.

  • adjacency_list (dict, optional) – dictionary that contains the adjacency list of nodes. The keys are considered as the nodes on the rows layer and the values, to be given as lists or numpy arrays, are considered as the nodes on the columns layer.

  • edgelist (list, numpy.array, optional) – list of edges containing couples (row_node, col_node) of nodes forming an edge. each element in the couples must belong to the respective layer.

  • degree_sequences (list, numpy.array, tuple, optional) – couple of lists describing the degree sequences of both layers.

_check_solution(return_error=False, in_place=False)[source]

Check if the solution of the BiCM is compatible with the degree sequences of the graph.

Parameters:
  • return_error (bool) – If this is set to true, return 1 if the solution is not correct, 0 otherwise.

  • in_place (bool) – check also the error in the single entries of the matrices. Always False unless comparing two different solutions.

_clean_root()[source]

Clean variables used for the root solver

_compute_projected_pvals_mat(layer='rows')[source]

Compute the pvalues matrix representing the significance of the original matrix.

_equations_root(x)[source]

Equations for the root solver

_initialize_fitnesses()[source]

Internal method to initialize the fitnesses of the BiCM. If there are empty rows, the corresponding fitnesses are set to 0, while for full rows the corresponding columns are set to numpy.inf.

_initialize_graph(biadjacency=None, adjacency_list=None, edgelist=None, degree_sequences=None)[source]

Internal method for the initialization of the graph. Use the setter methods instead.

Parameters:
  • biadjacency (numpy.array, scipy.sparse, list, optional) – binary input matrix describing the biadjacency matrix of a bipartite graph with the nodes of one layer along the rows and the nodes of the other layer along the columns.

  • adjacency_list (dict, optional) – dictionary that contains the adjacency list of nodes. The keys are considered as the nodes on the rows layer and the values, to be given as lists or numpy arrays, are considered as the nodes on the columns layer.

  • edgelist (list, numpy.array, optional) – list of edges containing couples (row_node, col_node) of nodes forming an edge. each element in the couples must belong to the respective layer.

  • degree_sequences (list, numpy.array, tuple, optional) – couple of lists describing the degree sequences of both layers.

_initialize_node_dictionaries()[source]
_initialize_problem(rows_deg=None, cols_deg=None)[source]

Initializes the solver reducing the degree sequences, setting the initial guess and setting the functions for the solver. The two parameters rows_deg and cols_deg are passed if there were some full or empty rows or columns.

_jacobian_root(x)[source]

Jacobian for the root solver

_projection_calculator()[source]
_projection_from_pvals(alpha=0.05, validation_method='fdr')[source]

Internal method to build the projected network from pvalues.

Parameters:
  • alpha (float) – Threshold for the validation.

  • validation_method (str) – The type of validation to apply.

_pvals_validator(pval_list, alpha=0.05, validation_method='fdr')[source]
_residuals_jacobian(x)[source]

Residuals and jacobian for the root solver

_set_initial_guess()[source]

Internal method to set the initial point of the solver.

_set_parameters(method, initial_guess, tol, eps, regularise, max_steps, verbose, linsearch, exp, full_return)[source]

Internal method for setting the parameters of the solver.

_set_solved_problem(solution)[source]

Sets the solution of the problem.

Parameters:

solution (numpy.ndarray) – A numpy array containing that reduced fitnesses of the two layers, consecutively.

_solve_bicm_full()[source]

Internal method for computing the solution of the BiCM via matrices.

_solve_bicm_light()[source]

Internal method for computing the solution of the BiCM via degree sequences.

_solve_root()[source]

Internal root solver

static check_sol(biad_mat, avg_bicm, return_error=False, in_place=False, mrse=None)[source]

Static method. This function prints the rows sums differences between two matrices, that originally are the biadjacency matrix and its bicm average matrix. The intended use of this is to check if an average matrix is actually a solution

for a bipartite configuration model.

If return_error is set to True, it returns 1 if the sum of the differences is bigger than 1.

If in_place is set to True, it checks and sums also the total error entry by entry. The intended use of this is to check if two solutions are the same solution.

check_sol_light(return_error=False)[source]

Light version of the check_sol function, working only on the fitnesses and the degree sequences.

clean_edges()[source]

Clean the edges of the graph.

compute_projection(rows=True, alpha=0.05, approx_method=None, method=None, threads_num=None, progress_bar=True, validation_method='fdr')[source]

Compute the projection of the network on the rows or columns layer. If the BiCM has not been computed, it also computes it with standard settings. This is the most customizable method for the pvalues computation.

Parameters:
  • rows (bool) – True if requesting the rows’ projection.

  • alpha (float) – Threshold for the p-values validation.

  • approx_method (str) – Method for the approximation of the pvalues computation. Implemented methods are poisson, poibin, normal, rna.

  • method (str) – Deprecated, same as approx_method.

  • threads_num – Number of threads to use for the parallelization. If it is set to 1, the computation is not parallelized.

  • progress_bar (bool) – Show progress bar of the pvalues computation.

  • validation_method (str) – The type of validation to apply: ‘global’ for a global threshold, ‘fdr’ for False Discovery Rate or ‘bonferroni’ for Bonferroni correction.

compute_weighted_pvals_mat()[source]

Compute the pvalues matrix representing the significance of the original matrix.

degree_reduction(rows_deg=None, cols_deg=None)[source]

Reduce the degree sequences to contain no repetition of the degrees. The two parameters rows_deg and cols_deg are passed if there were some full or empty rows or columns.

get_bicm_fitnesses()[source]

Get the fitnesses of the BiCM. If the BiCM has not been computed, it also computes it with standard settings.

Returns:

The fitnesses of the BiCM in the format rows fitnesses dictionary, columns fitnesses dictionary

get_bicm_matrix()[source]

Get the matrix of probabilities of the BiCM. If the BiCM has not been computed, it also computes it with standard settings.

Returns:

The average matrix of the BiCM

Return type:

numpy.ndarray

get_cols_projection(alpha=0.05, method='poisson', threads_num=None, progress_bar=True, fmt='adjacency_list')[source]

Get the projected network on the columns layer of the graph.

Parameters:
  • alpha (float, optional) – threshold for the validation of the projected edges.

  • method (str, optional) – approximation method for the calculation of the p-values. Implemented choices are: poisson, poibin, normal, rna

  • threads_num (int, optional) – number of threads to use for the parallelization. If it is set to 1, the computation is not parallelized.

  • progress_bar (bool) – Show the progress bar

  • fmt (str) – the desired format for the output: adjacency_list (default) or edgelist

Returns:

the projected network on the columns layer, in the format specified by fmt

get_fitnesses()[source]

See get_bicm_fitnesses.

get_projected_pvals_mat(layer=None)[source]

Return the pvalues matrix of the projection if it has been computed.

Parameters:

layer (string, optional) – the layer to return.

get_rows_projection(alpha=0.05, method='poisson', threads_num=None, progress_bar=True, fmt='adjacency_list', validation_method='fdr')[source]

Get the projected network on the rows layer of the graph.

Parameters:
  • alpha (float, optional) – threshold for the validation of the projected edges.

  • method (str, optional) – approximation method for the calculation of the p-values. Implemented choices are: poisson, poibin, normal, rna

  • threads_num (int, optional) – number of threads to use for the parallelization. If it is set to 1, the computation is not parallelized.

  • progress_bar (bool) – Show the progress bar

  • fmt (str) – the desired format for the output: adjacency_list (default) or edgelist

  • validation_method (str) – The type of validation to apply: ‘global’ for a global threshold, ‘fdr’ for False Discovery Rate or ‘bonferroni’ for Bonferroni correction.

Returns:

the projected network on the rows layer, in the format specified by fmt

get_validated_matrix(significance=0.01, validation_method=None)[source]

Extract a backbone of the original network keeping only the most significant links. At the moment this method only applies a global significance level for any link.

Parameters:
  • significance (float) – Threshold for the pvalues significance.

  • validation_method (str) – The type of validation to apply: ‘global’ for a global threshold, ‘fdr’ for False Discovery Rate or ‘bonferroni’ for Bonferroni correction.

get_weighted_pvals_mat()[source]

Return the pvalues matrix representing the significance of the original matrix.

initialize_avg_mat()[source]

Reduces the matrix eliminating empty or full rows or columns. It repeats the process on the so reduced matrix until no more reductions are possible. For instance, a perfectly nested matrix will be reduced until all entries are set to 0 or 1.

model_loglikelihood()[source]

Returns the loglikelihood of the solution of last model executed.

pval_calculator(v_list_key, x, y)[source]

Calculate the p-values of the v-motifs numbers of one vertex and all its neighbours.

Parameters:
  • v_list_key (int) – the key of the node to consider for the adjacency list of the v-motifs.

  • x (numpy.ndarray) – the fitnesses of the layer of the desired projection.

  • y (numpy.ndarray) – the fitnesses of the opposite layer.

Returns:

a dictionary containing as keys the nodes that form v-motifs with the

considered node, and as values the corresponding p-values.

pval_calculator_poibin(deg_couple, deg_dict, x, y)[source]

Calculate the p-values of the v-motifs numbers of all nodes with a given couple degrees.

Parameters:
  • deg_couple (tuple) – the couple of degrees considered.

  • deg_dict (dict) – node-degrees dictionary.

  • x (numpy.ndarray) – the fitnesses of the layer of the desired projection.

  • y (numpy.ndarray) – the fitnesses of the opposite layer.

Returns:

a list containing 3-tuples with the two nodes considered and their p-value.

set_adjacency_list(adj_list)[source]

Set the adjacency list of the graph.

Parameters:

adj_list (dict) – a dictionary containing the adjacency list of a bipartite graph with the nodes of one layer as keys and lists of neighbor nodes of the other layer as values.

set_biadjacency_matrix(biadjacency)[source]

Set the biadjacency matrix of the graph.

Parameters:

biadjacency (numpy.array, scipy.sparse, list) – binary input matrix describing the biadjacency matrix of a bipartite graph with the nodes of one layer along the rows and the nodes of the other layer along the columns.

set_degree_sequences(degree_sequences)[source]

Set the degree sequence of the graph.

Parameters:

degree_sequences (list, numpy.array, tuple) – couple of lists describing the degree sequences of both layers.

set_edgelist(edgelist)[source]

Set the edgelist of the graph.

Parameters:

edgelist (list, numpy.array) – list of edges containing couples (row_node, col_node) of nodes forming an edge. each element in the couples must belong to the respective layer.

set_to_continuous()[source]
solve_bicm(method='newton', initial_guess=None, light_mode=None, tolerance=None, tol=1e-08, eps=1e-08, max_steps=None, verbose=False, linsearch=True, regularise=None, print_error=True, full_return=False, exp=False)[source]

Deprecated method, replaced by solve_tool

solve_tool(method=None, initial_guess=None, light_mode=None, tol=None, eps=None, max_steps=None, verbose=False, linsearch=True, regularise=None, print_error=True, full_return=False, exp=False, model=None)[source]

Solve the BiCM of the graph. It does not return the solution, use the getter methods instead.

Parameters:
  • light_mode (bool) – Doesn’t use matrices in the computation if this is set to True. If the graph has been initialized without the matrix or in sparse mode, the light mode is used regardless.

  • method (str) – Method of choice among newton, quasinewton or iterative, default is set by the model solved

  • initial_guess (str) – Initial guess of choice among strings: None, chung-lu, random, uniform, degrees, or a list or a numpy array that will be set as initial conditions. The array has to have the same size as the number of rows + the number of columns or has to be a couple of array with len (n_rows, n_cols). Default is None which is the chung-lu approximation

  • tol (float) – Tolerance of the solution, optional

  • eps (float) – Tolerance of the difference between consecutive solutions, optional

  • max_steps (int) – Maximum number of steps, optional

  • verbose (bool, optional) – Print elapsed time, errors and iteration steps, optional

  • linsearch (bool) – Implement the linesearch when searching for roots, default is True

  • regularise (bool) – Regularise the matrices in the computations, optional

  • print_error (bool) – Print the final error of the solution

  • full_return (bool) – If True, the solver returns some more insights on the convergence. Default False.

  • exp (bool) – if this is set to true the solver works with the reparameterization $x_i = e^{- heta_i}$, $y_lpha = e^{- heta_lpha}$. It might be slightly faster but also might not converge.

  • model (str) – Model to be used, to be passed only if the user wants to use a model different from the recognized one.

poibin class

Created on Tue Mar 29, 2016

Module:

poibin - Poisson Binomial distribution

Author:

Mika Straka, 2016

Description:

Implementation of the Poisson Binomial distribution as described in the reference.

Implemented method:
  • pmf: probability mass function

  • cdf: cumulative density function

  • pval: p-value (1 - cdf)

Usage:

Be p a list / numpy array of success probabilities for n non-identically distributed Bernoulli random variables. Create an instance of the distribution with

>>> pb = PoiBin(p)

Be x a list or numpy array of different number of successes. To obtain:

  • probability mass function of x, use

>>> pb.pmf(x)
  • cumulative density function of x, use

>>> pb.cdf(x)
  • p-values of x, use

>>> pb.pval(x)

The functions are applied component-wise and a numpy array of the same lenth as x is returned.

Reference:

Yili Hong, On computing the distribution function for the Poisson binomial distribution, Computational Statistics & Data Analysis, Volume 59, March 2013, Pages 41-51, ISSN 0167-9473, http://dx.doi.org/10.1016/j.csda.2012.10.006.

class bicm.poibin.PoiBin(p)[source]

Bases: object

cdf(kk)[source]

Calculate the cumulative density function for the input values kk.

check_input_prob()[source]

Check that all the input probabilities are in the interval [0, 1].

check_rv_input(kk)[source]

Check whether input values kk for the random variable are >=0, integers and <= n.

static check_xi_are_real(xx)[source]

Check whether all the xis have imaginary part equal to 0, i.e. whether probabilities pmf are positive.

get_argz_sum(idx)[source]

Sum over all the principal values of z_j(l) for j = 1, …, n, keeping idx fixed.

get_cdf(xx)[source]

Return a list which contains all the values of the cumulative density function for i = 0, 1, …, n.

get_chi(idx)[source]

Return the value of chi_idx.

get_d(idx)[source]

Return coefficient d_idx of the chi value chi_idx = d_idx * (Real + j * Imag).

get_pmf_xi()[source]

Return the values of xi, which are the components that make up the cumulative density function.

get_z(j, idx)[source]

Return z_j(l).

pmf(kk)[source]

Calculate the probability mass function for the input values kk.

pval(k)[source]

Return the p-value corresponding to k, defined as 1 - cdf(k).

Network functions

This module contains several functions for bipartite networks.

bicm.network_functions.adjacency_list_from_adjacency_list_bipartite(old_adj_list)[source]

Creates the adjacency list from another adjacency list, converting the data type to integers. Method for bipartite networks. Returns two dictionaries, each representing an adjacency list with the rows or columns as keys, respectively. Original keys are treated as rows, values as columns. The nodes are enumerated and the adjacency list contains the related integers. Returns also two dictionaries that keep track of the nodes and the two degree sequences.

bicm.network_functions.adjacency_list_from_biadjacency(biadjacency, return_inverse=True, return_degree_sequences=True)[source]

Creates the adjacency list from a biadjacency matrix, given in sparse format or as a list or numpy array. Returns the adjacency list as a dictionary, with the rows as keys and as values lists with indexes of the columns. If return_inverse is True, the inverse adjacency list is also returned. If return_degree_sequences is True, the two degree sequences are also returned.

bicm.network_functions.adjacency_list_from_edgelist_bipartite(edgelist, convert_type=True)[source]

Creates the adjacency list from the edgelist. Method for bipartite networks. Returns two dictionaries containing an adjacency list with the rows as keys and the columns as keys, respectively. If convert_type is True (default), then the nodes are enumerated and the adjacency list is returned as integers. Returns also two dictionaries that keep track of the nodes and the two degree sequences.

bicm.network_functions.biadjacency_from_adjacency_list(adj_list, fmt='array')[source]

Creates the biadjacency matrix from an adjacency list given as a dictionary. Returns the biadjacency as a numpy array by default, or sparse scipy matrix if fmt=’sparse’. The biadjacency comes with the keys as rows of the matrix and the values as columns. :param dict adj_list: the adjacency list to be converted. Must contain integers that will be used as indexes. :param str fmt: the desired format of the output biadjacency matrix, either ‘array’ or ‘sparse’, optional

bicm.network_functions.biadjacency_from_edgelist(edgelist, fmt='array')[source]

Build the biadjacency matrix of a bipartite network from its edgelist. Returns a matrix of the type specified by fmt, by default a numpy array.

bicm.network_functions.bicm_from_fitnesses(x, y)

Rebuilds the average probability matrix of the bicm from the fitnesses

Parameters:
  • x (numpy.ndarray) – the fitness vector of the rows layer

  • y (numpy.ndarray) – the fitness vector of the columns layer

bicm.network_functions.biwcm_c_from_fitnesses(x, y)

Rebuilds the average probability matrix of the BiWCM_c from the fitnesses

Parameters:
  • x (numpy.ndarray) – the fitness vector of the rows layer

  • y (numpy.ndarray) – the fitness vector of the columns layer

bicm.network_functions.biwcm_d_from_fitnesses(x, y)

Rebuilds the average probability matrix of the BiWCM_d from the fitnesses

Parameters:
  • x (numpy.ndarray) – the fitness vector of the rows layer

  • y (numpy.ndarray) – the fitness vector of the columns layer

bicm.network_functions.edgelist_from_adjacency_list_bipartite(adj_list)[source]

Creates the edgelist from an adjacency list given as a dictionary. Returns the edgelist as a numpy array, with the keys as first elements of the couples and the values second. :param dict adj_list: the adjacency list to be converted.

bicm.network_functions.edgelist_from_biadjacency(biadjacency)[source]

Build the edgelist of a bipartite network from its biadjacency matrix. Accounts for sparse matrices and returns a structured array.

bicm.network_functions.edgelist_from_biadjacency_fast(biadjacency)

Build the edgelist of a bipartite network from its biadjacency matrix.

bicm.network_functions.edgelist_from_edgelist_bipartite(edgelist)[source]

Creates a new edgelist with the indexes of the nodes instead of the names. Method for bipartite networks. Returns also two dictionaries that keep track of the nodes.

bicm.network_functions.sample_bicm(avg_mat)[source]

Build a biadjacency matrix sampling from the probability matrix of a BiCM.

bicm.network_functions.sample_bicm_edgelist(x, y)[source]

Build an edgelist sampling from the fitnesses of a BiCM.

bicm.network_functions.sample_bicm_edgelist_names(dict_x, dict_y)[source]

Build an edgelist from the BiCM keeping the names of the nodes as contained in the BiCM fitnesses’ dictionaries.

Solver functions

bicm.solver_functions.matrix_regulariser_function(b, eps)[source]

Trasforms input matrix in a positive defined matrix by adding positive quantites to the main diagonal.

Parameters:
  • b (numpy.ndarray) – Matrix.

  • eps (float) – Positive quantity to add.

Returns:

Regularised matrix.

Return type:

numpy.ndarray

bicm.solver_functions.matrix_regulariser_function_eigen_based(b, eps)[source]

Trasform input matrix in a positive defined matrix by regularising eigenvalues.

Parameters:
  • b (numpy.ndarray) – Matrix.

  • eps (float) – Positive quantity to add.

Returns:

Regularised matrix.

Return type:

numpy.ndarray

bicm.solver_functions.solver(x0, fun, step_fun, linsearch_fun, hessian_regulariser, fun_jac=None, tol=1e-06, eps=1e-10, max_steps=100, method='newton', verbose=False, regularise=True, regularise_eps=0.001, full_return=False, linsearch=True)[source]

Find roots of eq. fun = 0, using newton, quasinewton or fixed-point algorithm.

Parameters:
  • x0 (numpy.ndarray) – Initial point

  • fun (function) – Function handle of the function to find the roots of.

  • step_fun (function) – Function to compute the algorithm step

  • linsearch_fun (function) – Function to compute the linsearch

  • hessian_regulariser (function) – Function to regularise fun hessian

  • fun_jac (function, optional) – Function to compute the hessian of fun, defaults to None

  • tol (float, optional) – The solver stops when |fun|<tol, defaults to 1e-6

  • eps (float, optional) – The solver stops when the difference between two consecutive steps is less than eps, defaults to 1e-10

  • max_steps (int, optional) – Maximum number of steps the solver takes, defaults to 100

  • method (str, optional) – Method the solver uses to solve the problem. Choices are “newton”, “quasinewton”, “fixed-point”. Defaults to “newton”

  • verbose (bool, optional) – If True the solver prints out information at each step, defaults to False

  • regularise (bool, optional) – If True the solver will regularise the hessian matrix, defaults to True

  • regularise_eps (float, optional) – Positive value to pass to the regulariser function, defaults to 1e-3

  • full_return (bool, optional) – If True the function returns information on the convergence, defaults to False

  • linsearch (bool, optional) – If True a linsearch algorithm is implemented, defaults to True

Returns:

Solution to the optimization problem

Return type:

numpy.ndarray

bicm.solver_functions.sufficient_decrease_condition(f_old, f_new, alpha, grad_f, p, c1=0.0001, c2=0.9)

Returns True if upper wolfe condition is respected.

Parameters:
  • f_old (float) – Function value at previous iteration.

  • f_new (float) – Function value at current iteration.

  • alpha (float) – Alpha parameter of linsearch.

  • grad_f (numpy.ndarray) – Function gradient.

  • p (numpy.ndarray) – Current iteration increment.

  • c1 (float, optional) – Tuning parameter, defaults to 1e-04.

  • c2 (float, optional) – Tuning parameter, defaults to 0.9.

Returns:

Condition validity.

Return type:

bool

Models functions

bicm.models_functions.eqs_root(xx, d_rows, d_cols, multiplier_rows, multiplier_cols, nrows, ncols, out_res)

Equations for the root solver of the reduced BiCM.

Parameters:

xx (numpy.array) – fitnesses vector

bicm.models_functions.iterative_bicm(x0, args)

Return the next iterative step for the Bipartite Configuration Model reduced version.

Parameters:
  • x0 (numpy.ndarray) – initial point

  • args (list, tuple) – rows degree sequence, columns degree sequence, rows multipl., cols multipl.

Returns:

next iteration step

Return type:

numpy.ndarray

bicm.models_functions.iterative_bicm_exp(x0, args)

Return the next iterative step for the Bipartite Configuration Model reduced version.

Parameters:
  • x0 (numpy.ndarray) – initial point

  • args (list, tuple) – rows degree sequence, columns degree sequence, rows multipl., cols multipl.

Returns:

next iteration step

Return type:

numpy.ndarray

bicm.models_functions.iterative_biwcm_c(x0, args)

Return the next iterative step for the Bipartite Configuration Model reduced version.

Parameters:
  • x0 (numpy.ndarray) – initial point

  • args (list, tuple) – rows degree sequence, columns degree sequence, rows multipl., cols multipl.

Returns:

next iteration step

Return type:

numpy.ndarray

bicm.models_functions.iterative_biwcm_c_exp(x, args)[source]

To be implemented

bicm.models_functions.iterative_biwcm_d(x0, args)

Return the next iterative step for the Bipartite Configuration Model reduced version.

Parameters:
  • x0 (numpy.ndarray) – initial point

  • args (list, tuple) – rows degree sequence, columns degree sequence, rows multipl., cols multipl.

Returns:

next iteration step

Return type:

numpy.ndarray

bicm.models_functions.iterative_biwcm_d_exp(x0, args)

Return the next iterative step for the Bipartite Configuration Model reduced version.

Parameters:
  • x0 (numpy.ndarray) – initial point

  • args (list, tuple) – rows degree sequence, columns degree sequence, rows multipl., cols multipl.

Returns:

next iteration step

Return type:

numpy.ndarray

bicm.models_functions.jac_root(xx, multiplier_rows, multiplier_cols, nrows, ncols, out_j_t)

Jacobian for the root solver of the reduced BiCM.

Parameters:

xx (numpy.array) – fitnesses vector

bicm.models_functions.linsearch_fun_BiCM(xx, args)

Linsearch function for BiCM/BiWCM_d newton and quasinewton methods. The function returns the step’s size, alpha. Alpha determines how much to move on the descending direction found by the algorithm. :param xx: Tuple of arguments to find alpha:

solution, solution step, tuning parameter beta, initial alpha, function f

Parameters:

args ((func, tuple)) – Tuple, step function and arguments.

Returns:

Working alpha.

Return type:

float

bicm.models_functions.linsearch_fun_BiCM_exp(xx, args)

Linsearch function for BiCM newton and quasinewton methods. This is the linesearch function in the exponential mode. The function returns the step’s size, alpha. Alpha determines how much to move on the descending direction found by the algorithm. :param xx: Tuple of arguments to find alpha:

solution, solution step, tuning parameter beta, initial alpha, function f

Parameters:

args ((func, tuple)) – Tuple, step function and arguments.

Returns:

Working alpha.

Return type:

float

bicm.models_functions.linsearch_fun_BiCM_exp_fixed(xx)

Linsearch function for BiCM fixed-point method. The function returns the step’s size, alpha. Alpha determines how much to move on the descending direction found by the algorithm. This function works on BiCM exponential version. :param xx: Tuple of arguments to find alpha:

solution, solution step, tuning parameter beta, initial alpha, step.

Returns:

Working alpha.

Return type:

float

bicm.models_functions.linsearch_fun_BiCM_fixed(xx)

Linsearch function for BiCM fixed-point method. The function returns the step’s size, alpha. Alpha determines how much to move on the descending direction found by the algorithm.

Parameters:

xx ((numpy.ndarray, numpy.ndarray, func, float, float, int)) – Tuple of arguments to find alpha: solution, solution step, tuning parameter beta, initial alpha, step.

Returns:

Working alpha.

Return type:

float

bicm.models_functions.loglikelihood_bicm(x0, args)

Log-likelihood function of the reduced BiCM.

Parameters:
  • x0 (numpy.ndarray) – 1D fitnesses vector

  • args (list or tuple) – list of arguments needed for the computation

Returns:

log-likelihood of the system

Return type:

float

bicm.models_functions.loglikelihood_bicm_exp(x0, args)

Log-likelihood function of the reduced BiCM.

Parameters:
  • x0 (numpy.ndarray) – 1D fitnesses vector

  • args (list or tuple) – list of arguments needed for the computation

Returns:

log-likelihood of the system

Return type:

float

bicm.models_functions.loglikelihood_biwcm_c(x0, args)

Log-likelihood function of the reduced BiWCM_c.

Parameters:
  • x0 (numpy.ndarray) – 1D fitnesses vector

  • args (list or tuple) – list of arguments needed for the computation

Returns:

log-likelihood of the system

Return type:

float

bicm.models_functions.loglikelihood_biwcm_c_exp(x, args)[source]

To be implemented

bicm.models_functions.loglikelihood_biwcm_d(x0, args)

Log-likelihood function of the reduced BiCM.

Parameters:
  • x0 (numpy.ndarray) – 1D fitnesses vector

  • args (list or tuple) – list of arguments needed for the computation

Returns:

log-likelihood of the system

Return type:

float

bicm.models_functions.loglikelihood_biwcm_d_exp(x0, args)

Log-likelihood function of the reduced BiCM.

Parameters:
  • x0 (numpy.ndarray) – 1D fitnesses vector

  • args (list or tuple) – list of arguments needed for the computation

Returns:

log-likelihood of the system

Return type:

float

bicm.models_functions.loglikelihood_hessian_bicm(x0, args)

Log-likelihood hessian of the reduced BiCM.

Parameters:
  • x0 (numpy.ndarray) – 1D fitnesses vector

  • args (list, tuple) – list of arguments needed for the computation

Returns:

2D hessian matrix of the system

Return type:

numpy.ndarray

bicm.models_functions.loglikelihood_hessian_bicm_exp(x0, args)

Log-likelihood hessian of the reduced BiCM.

Parameters:
  • x0 (numpy.ndarray) – 1D fitnesses vector

  • args (list, tuple) – list of arguments needed for the computation

Returns:

2D hessian matrix of the system

Return type:

numpy.ndarray

bicm.models_functions.loglikelihood_hessian_biwcm_c(x0, args)

Log-likelihood hessian of the reduced BiWCM_c.

Parameters:
  • x0 (numpy.ndarray) – 1D fitnesses vector

  • args (list, tuple) – list of arguments needed for the computation

Returns:

2D hessian matrix of the system

Return type:

numpy.ndarray

bicm.models_functions.loglikelihood_hessian_biwcm_c_exp(x, args)[source]

To be implemented

bicm.models_functions.loglikelihood_hessian_biwcm_d(x0, args)

Log-likelihood hessian of the reduced BiWCM_d.

Parameters:
  • x0 (numpy.ndarray) – 1D fitnesses vector

  • args (list, tuple) – list of arguments needed for the computation

Returns:

2D hessian matrix of the system

Return type:

numpy.ndarray

bicm.models_functions.loglikelihood_hessian_biwcm_d_exp(x0, args)

Log-likelihood hessian of the reduced BiCM.

Parameters:
  • x0 (numpy.ndarray) – 1D fitnesses vector

  • args (list, tuple) – list of arguments needed for the computation

Returns:

2D hessian matrix of the system

Return type:

numpy.ndarray

bicm.models_functions.loglikelihood_hessian_diag_bicm(x0, args)

Log-likelihood diagonal hessian of the reduced BiCM.

Parameters:
  • x0 (numpy.ndarray) – 1D fitnesses vector

  • args (list, tuple) – list of arguments needed for the computation

Returns:

2D hessian matrix of the system

Return type:

numpy.ndarray

bicm.models_functions.loglikelihood_hessian_diag_bicm_exp(x0, args)

Log-likelihood diagonal hessian of the reduced BiCM.

Parameters:
  • x0 (numpy.ndarray) – 1D fitnesses vector

  • args (list, tuple) – list of arguments needed for the computation

Returns:

2D hessian matrix of the system

Return type:

numpy.ndarray

bicm.models_functions.loglikelihood_hessian_diag_biwcm_c(x0, args)

Log-likelihood hessian of the reduced BiWCM_c.

Parameters:
  • x0 (numpy.ndarray) – 1D fitnesses vector

  • args (list, tuple) – list of arguments needed for the computation

Returns:

2D hessian matrix of the system

Return type:

numpy.ndarray

bicm.models_functions.loglikelihood_hessian_diag_biwcm_c_exp(x, args)[source]

To be implemented

bicm.models_functions.loglikelihood_hessian_diag_biwcm_d(x0, args)

Log-likelihood diagonal hessian of the reduced BiWCM_d.

Parameters:
  • x0 (numpy.ndarray) – 1D fitnesses vector

  • args (list, tuple) – list of arguments needed for the computation

Returns:

2D hessian matrix of the system

Return type:

numpy.ndarray

bicm.models_functions.loglikelihood_hessian_diag_biwcm_d_exp(x0, args)

Log-likelihood diagonal hessian of the reduced BiWCM_d.

Parameters:
  • x0 (numpy.ndarray) – 1D fitnesses vector

  • args (list, tuple) – list of arguments needed for the computation

Returns:

2D hessian matrix of the system

Return type:

numpy.ndarray

bicm.models_functions.loglikelihood_prime_bicm(x0, args)

Iterative function for loglikelihood gradient BiCM.

Parameters:
  • x0 (numpy.array) – fitnesses vector

  • args (list or tuple) – list of arguments needed for the computation

Returns:

log-likelihood of the system

Return type:

numpy.array

bicm.models_functions.loglikelihood_prime_bicm_exp(x0, args)

Iterative function for loglikelihood gradient BiCM.

Parameters:
  • x0 (numpy.array) – fitnesses vector

  • args (list or tuple) – list of arguments needed for the computation

Returns:

log-likelihood of the system

Return type:

numpy.array

bicm.models_functions.loglikelihood_prime_biwcm_c(x0, args)

Iterative function for loglikelihood gradient BiWCM_c.

Parameters:
  • x0 (numpy.array) – fitnesses vector

  • args (list or tuple) – list of arguments needed for the computation

Returns:

log-likelihood of the system

Return type:

numpy.array

bicm.models_functions.loglikelihood_prime_biwcm_c_exp(x, args)[source]

To be implemented

bicm.models_functions.loglikelihood_prime_biwcm_d(x0, args)

Iterative function for loglikelihood gradient BiWCM_d.

Parameters:
  • x0 (numpy.array) – fitnesses vector

  • args (list or tuple) – list of arguments needed for the computation

Returns:

log-likelihood of the system

Return type:

numpy.array

bicm.models_functions.loglikelihood_prime_biwcm_d_exp(x0, args)

Iterative function for loglikelihood gradient BiWCM_d.

Parameters:
  • x0 (numpy.array) – fitnesses vector

  • args (list or tuple) – list of arguments needed for the computation

Returns:

log-likelihood of the system

Return type:

numpy.array

bicm.models_functions.made_bicm(xx, args)

Maximum Absolute Degree Error of the model for BiCM.

bicm.models_functions.made_biwcm_c(xx, args)

Maximum Absolute Degree Error of the model for BiWCM_c.

bicm.models_functions.made_biwcm_d(xx, args)

Maximum Absolute Degree Error of the model for BiWCM_d.

bicm.models_functions.mase_biwcm_c(xx, args)

Maximum Absolute Strength Error of the model for BiWCM_c.

bicm.models_functions.mase_biwcm_d(xx, args)

Maximum Absolute Strength Error of the model for BiWCM_d.

bicm.models_functions.mrde_bicm(xx, args)

Maximum Relative Degree Error of the model for BiCM.

bicm.models_functions.mrde_biwcm_c(xx, args)

Maximum Relative Degree Error of the model for BiWCM_c.

bicm.models_functions.mrde_biwcm_d(xx, args)

Maximum Relative Degree Error of the model for BiWCM_d.

bicm.models_functions.mrse_biwcm_c(xx, args)

Maximum Relative Strength Error of the model for BiWCM_c.

bicm.models_functions.mrse_biwcm_d(xx, args)

Maximum Relative Strength Error of the model for BiWCM_d.