code: def write_results(self, filename):
          
          with self.io(filename, 'a') as fp:
              # write samples
              fp.write_samples(self.samples, self.model.variable_params,
                               last_iteration=self.niterations)
              # write stats
              fp.write_samples(self.model_stats,
                               last_iteration=self.niterations)
              # write accpetance
              fp.write_acceptance_fraction(self._sampler.acceptance_fraction)
              # write random state
              fp.write_random_state(state=self._sampler.random_state)
docs: Writes samples, model stats, acceptance fraction, and random state
          to the given file.
  
          Parameters
          -----------
          filename : str
              The file to write to. The file is opened using the ``io`` class
              in an an append state.