code: def getTransitionAndRewardArrays(s):
      
      assert 0 <= s <= 1, "'s' must be between 0 and 1"
      # The transition probability array
      P = np.zeros((ACTIONS, STATES, STATES))
      # The reward vector
      R = np.zeros(STATES)
      # Loop over all states
      for idx in range(STATES):
          # Get the state index as inputs to our functions
          x, F = convertIndexToState(idx)
          # The reward for being in this state is 1 if the population is extant
          if x != 0:
              R[idx] = 1
          # Loop over all actions
          for a in range(ACTIONS):
              # Assign the transition probabilities for this state, action pair
              P[a][idx] = getTransitionProbabilities(s, x, F, a)
      return(P, R)
docs: Generate the fire management transition and reward matrices.
      
      The output arrays from this function are valid input to the mdptoolbox.mdp
      classes.
      
      Let ``S`` = number of states, and ``A`` = number of actions.
      
      Parameters
      ----------
      s : float
          The class-independent probability of the population staying in its
          current population abundance class.
      
      Returns
      -------
      out : tuple
          ``out[0]`` contains the transition probability matrices P and
          ``out[1]`` contains the reward vector R. P is an  ``A`` × ``S`` × ``S``
          numpy array and R is a numpy vector of length ``S``.