chain_binomial_rippler.py
def _compute_state(initial_state, events, stoichiometry, closed=False):
    """Computes a state tensor from initial state and event tensor

    :param initial_state: a tensor of shape [S, M]
    :param events: a tensor of shape [T, R, M]
    :param stoichiometry: a stoichiometry matrix of shape [R, S] describing
                          how transitions update the state.
    :param closed: if `True`, return state in close interval [0, T], otherwise [0, T)
    :return: a tensor of shape [T, S, M] if `closed=False` or [T+1, S, M] if `closed=True`
             describing the state of the
             system for each batch M at time T.
    """
    if isinstance(stoichiometry, tf.Tensor):
        stoichiometry = ps.cast(stoichiometry, dtype=events.dtype)
    else:
        stoichiometry = tf.convert_to_tensor(stoichiometry, dtype=events.dtype)

    increments = tf.einsum("...trm,rs->...tsm", events, stoichiometry)

    if closed is False:
        cum_increments = tf.cumsum(increments, axis=-3, exclusive=True)
    else:
        cum_increments = tf.cumsum(increments, axis=-3, exclusive=False)
        cum_increments = tf.concat(
            [tf.zeros_like(cum_increments[..., 0:1, :, :]), cum_increments],
            axis=-2,
        )
    state = cum_increments + tf.expand_dims(initial_state, axis=-3)
    return state
Computes a state tensor from initial state and event tensor

    :param initial_state: a tensor of shape [S, M]
    :param events: a tensor of shape [T, R, M]
    :param stoichiometry: a stoichiometry matrix of shape [R, S] describing
                          how transitions update the state.
    :param closed: if `True`, return state in close interval [0, T], otherwise [0, T)
    :return: a tensor of shape [T, S, M] if `closed=False` or [T+1, S, M] if `closed=True`
             describing the state of the
             system for each batch M at time T.
    
Computes a state tensor from initial state and event tensor
Computes a state tensor from initial state and event tensor
def _compute_state(initial_state, events, stoichiometry, closed=False):
    if isinstance(stoichiometry, tf.Tensor):
        stoichiometry = ps.cast(stoichiometry, dtype=events.dtype)
    else:
        stoichiometry = tf.convert_to_tensor(stoichiometry, dtype=events.dtype)
    increments = tf.einsum("...trm,rs->...tsm", events, stoichiometry)
    if closed is False:
        cum_increments = tf.cumsum(increments, axis=-3, exclusive=True)
    else:
        cum_increments = tf.cumsum(increments, axis=-3, exclusive=False)
        cum_increments = tf.concat(
            [tf.zeros_like(cum_increments[..., 0:1, :, :]), cum_increments],
            axis=-2,
        )
    state = cum_increments + tf.expand_dims(initial_state, axis=-3)
    return state
def _compute_state ( initial_state , events , stoichiometry , closed = False ) : if isinstance ( stoichiometry , tf . Tensor ) : stoichiometry = ps . cast ( stoichiometry , dtype = events . dtype ) else : stoichiometry = tf . convert_to_tensor ( stoichiometry , dtype = events . dtype ) increments = tf . einsum ( "...trm,rs->...tsm" , events , stoichiometry ) if closed is False : cum_increments = tf . cumsum ( increments , axis = - 3 , exclusive = True ) else : cum_increments = tf . cumsum ( increments , axis = - 3 , exclusive = False ) cum_increments = tf . concat ( [ tf . zeros_like ( cum_increments [ ... , 0 : 1 , : , : ] ) , cum_increments ] , axis = - 2 , ) state = cum_increments + tf . expand_dims ( initial_state , axis = - 3 ) return state
Computes a state tensor from initial state and event tensor
Computes a state tensor from initial state and event tensor
"""Computes a state tensor from initial state and event tensor

    :param initial_state: a tensor of shape [S, M]
    :param events: a tensor of shape [T, R, M]
    :param stoichiometry: a stoichiometry matrix of shape [R, S] describing
                          how transitions update the state.
    :param closed: if `True`, return state in close interval [0, T], otherwise [0, T)
    :return: a tensor of shape [T, S, M] if `closed=False` or [T+1, S, M] if `closed=True`
             describing the state of the
             system for each batch M at time T.
    """
a tensor of shape [T, S, M] if `closed=False` or [T+1, S, M] if `closed=True`
describing the state of the
system for each batch M at time T.
a tensor of shape [ T S M ] if ` closed = False ` or [ T + 1 S M ] if ` closed = True ` describing the state of the system for each batch M at time T .
initial_state
a tensor of shape [S, M]
a tensor of shape [ S M ]
events
a tensor of shape [T, R, M]
a tensor of shape [ T R M ]
stoichiometry
a stoichiometry matrix of shape [R, S] describing
how transitions update the state.
a stoichiometry matrix of shape [ R S ] describing how transitions update the state .
closed
if `True`, return state in close interval [0, T], otherwise [0, T)
if ` True ` return state in close interval [ 0 T ] otherwise [ 0 T )