def METHOD_NAME(self, samples, parameters=None):
    """Writes samples to the given file.
    Results are written to ``samples_group/{vararg}``, where ``{vararg}``
    is the name of a model params. The samples are written as an
    array of length ``niterations``.
    Parameters
    ----------
    samples : dict
        The samples to write. Each array in the dictionary should have
        length niterations.
    parameters : list, optional
        Only write the specified parameters to the file. If None, will
        write all of the keys in the ``samples`` dict.
    """
    niterations = len(tuple(samples.values())[0])
    assert all(len(p) == niterations for p in samples.values()), (
        "all samples must have the same shape")
    group = self.samples_group + '/{name}'
    if parameters is None:
        parameters = samples.keys()
    # loop over number of dimensions
    for param in parameters:
        dataset_name = group.format(name=param)
        try:
            fp_niterations = len(self[dataset_name])
            if niterations != fp_niterations:
                # resize the dataset
                self[dataset_name].resize(niterations, axis=0)
        except KeyError:
            # dataset doesn't exist yet
            self.create_dataset(dataset_name, (niterations,),
                                maxshape=(None,),
                                dtype=samples[param].dtype,
                                fletcher32=True)
        self[dataset_name][:] = samples[param]