code: def _generate_sample_paths_sparse(P_cdfs1d, indices, indptr, init_states,
                                    random_values, out):
      
      num_reps, ts_length = out.shape
  
      for i in range(num_reps):
          out[i, 0] = init_states[i]
          for t in range(ts_length-1):
              k = searchsorted(P_cdfs1d[indptr[out[i, t]]:indptr[out[i, t]+1]],
                               random_values[i, t])
              out[i, t+1] = indices[indptr[out[i, t]]+k]
docs: For sparse matrix.
  
      Generate num_reps sample paths of length ts_length, where num_reps =
      out.shape[0] and ts_length = out.shape[1].
  
      Parameters
      ----------
      P_cdfs1d : ndarray(float, ndim=1)
          1D array containing the CDFs of the state transition.
  
      indices : ndarray(int, ndim=1)
          CSR format index array.
  
      indptr : ndarray(int, ndim=1)
          CSR format index pointer array.
  
      init_states : array_like(int, ndim=1)
          Array containing the initial states. Its length must be equal to
          num_reps.
  
      random_values : ndarray(float, ndim=2)
          Array containing random values from [0, 1). Its shape must be
          equal to (num_reps, ts_length-1)
  
      out : ndarray(int, ndim=2)
          Array to store the sample paths.
  
      Notes
      -----
      This routine is jit-complied by Numba.