def SIRD_fsm(t, y, R_t, T_inf, gamma_x, *R_args):
    """
        This is a finite state machine which given the S, I, X value at time t, computes these values at time t + 1

        Arguments
        ----------------
        t       : The current time in days
        y       : List of size 3 containing the current S, I, X values
        R_t     : Either a scalar or a function of the form R_t(t, *params) where t is the current time 
        T_inf   : The average time a person with COVID19 is infectious
        gamma_x : The number of people who die from COVID19 in a day as a fraction of the number of infected people
        R_args  : List of arguments to be passed onto the function calculating R

        Returns 
        ----------------
        A list of size 3 containing the values S, I, X at time t + 1
    """

    if callable(R_t):
        R = R_t(t, *R_args)
    else:
        R = R_t
    
    S, I, X = y
    
    S_out = S - (R * I * S / T_inf)
    I_out = I + (R * I * S / T_inf) - I / T_inf
    X_out = X + gamma_x * I

    return [S_out, I_out, X_out]