docs: def builddata(self, mopt=None, data=None, pdata=None, prior=None):
          """ Rebuild pdata to account for marginalization. """
          if pdata is None:
              if data is None:
                  raise ValueError('no data or pdata')
              pdata = gvar.BufferDict()
              for m in self.flatmodels:
                  pdata[m.datatag] = (
                      m.builddata(data) if m.ncg <= 1 else
                      MultiFitter.coarse_grain(m.builddata(data), m.ncg)
                      )
          else:
              npdata = gvar.BufferDict()
              for m in self.flatmodels:
                  npdata[m.datatag] = pdata[m.datatag]
              pdata = npdata
          if mopt is not None:
              fitfcn = self.buildfitfcn()
              p_all = self.buildprior(prior=prior, mopt=None)
              f_all = fitfcn(p_all)
  
              # fcn with part we want to keep
              p_trunc = self.buildprior(prior=prior, mopt=mopt)
              f_trunc = fitfcn(p_trunc)
  
              # correct pdata
              pdata = gvar.BufferDict(pdata)
              if not self.ratio:
                  for m in self.flatmodels:
                      pdata[m.datatag] += f_trunc[m.datatag] - f_all[m.datatag]
              else:
                  for m in self.flatmodels:
                      ii = (gvar.mean(f_all[m.datatag]) != 0)
                      ratio = f_trunc[m.datatag][ii] / f_all[m.datatag][ii]
                      pdata[m.datatag][ii] *= ratio
          return pdata