mici.utils module#

Utility functions and classes.

class mici.utils.LogRepFloat(val=None, log_val=None)[source]#

Bases: object

Numerically stable logarithmic representation of positive float values.

Stores logarithm of value and overloads arithmetic operators to use more numerically stable implementations where possible.

Parameters:
property val: float#
mici.utils.hash_array(array)[source]#

Compute hash of a NumPy array by hashing data as a byte sequence.

Parameters:

array (ndarray) – NumPy array to compute hash of.

Returns:

Computed hash as an integer.

Return type:

int

mici.utils.log1m_exp(val)[source]#

Numerically stable implementation of log(1 - exp(val)).

Parameters:

val (float)

Return type:

float

mici.utils.log1p_exp(val)[source]#

Numerically stable implementation of log(1 + exp(val)).

Parameters:

val (float)

Return type:

float

mici.utils.log_diff_exp(val1, val2)[source]#

Numerically stable implementation of log(exp(val1) - exp(val2)).

Parameters:
Return type:

float

mici.utils.log_sum_exp(val1, val2)[source]#

Numerically stable implementation of log(exp(val1) + exp(val2)).

Parameters:
Return type:

float