Miscellaneous#
stochastix.utils.algebraic_sigmoid #
algebraic_sigmoid(x: ndarray)
Compute an algebraic sigmoid function.
Gradient of this function decays much more slowly in the tails than the standard sigmoid function. It is defined as:
.. math:: f(x) = 0.5 + (x / (2 * \sqrt(1 + x^2)))
Parameters:
-
x(ndarray) –The input array.
Returns:
-
–
The algebraic sigmoid of the input array.
stochastix.utils.entropy #
entropy(p: ndarray, base: float = 2) -> jnp.ndarray
MLE estimator for the entropy of a probability distribution.
Default calculation is in bits. No correction for finite sample size is applied.
Parameters:
-
p(ndarray) –The probability distribution.
-
base(float, default:2) –The base of the logarithm. Default is 2 (bits).
Returns:
-
ndarray–The entropy of the probability distribution.
stochastix.utils.rate_constant_conc_to_count #
rate_constant_conc_to_count(
rate_constant: ndarray | float,
reaction_order: float | int | floating | integer,
volume: float | floating,
use_molar_units: bool = True,
avogadro_number: float | floating | None = None,
return_log: bool = False,
) -> jnp.ndarray
Convert a concentration-based rate constant to a count-based constant.
This converts the macroscopic (deterministic ODE) rate constant k to the
mesoscopic (stochastic) propensity constant c used with molecule counts.
General relation for an m-th order reaction
c = k * (V)^(1 - m) [number-density units] c = k * (N_A * V)^(1 - m) [molar units]
Computation is performed in log10 space for numerical stability and interpretability.
Parameters:
-
rate_constant(ndarray | float) –Macroscopic rate constant
k(in concentration units). -
reaction_order(float | int | floating | integer) –Total order
mof the reaction (sum of reactant stoichiometries). May be non-integer for effective kinetics. -
volume(float | floating) –System volume. Liters if
use_molar_unitsis True. -
use_molar_units(bool, default:True) –Whether
kis in molar units (e.g., M^(1-m)/s). -
avogadro_number(float | floating | None, default:None) –Optional Avogadro's number override. Defaults to 6.02214076e23.
-
return_log(bool, default:False) –If True, return log10(c) instead of c.
Returns:
-
ndarray–The propensity constant
c(or its log10 ifreturn_logis True).