def builddata(self, mopt=None, data=None, pdata=None, prior=None):
if pdata is None:<EOL><INDENT>if data is None:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>pdata = gvar.BufferDict()<EOL>for m in self.flatmodels:<EOL><INDENT>pdata[m.datatag] = (<EOL>m.builddata(data) if m.ncg <= <NUM_LIT:1> else<EOL>MultiFitter.coarse_grain(m.builddata(data), m.ncg)<EOL>)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>npdata = gvar.BufferDict()<EOL>for m in self.flatmodels:<EOL><INDENT>npdata[m.datatag] = pdata[m.datatag]<EOL><DEDENT>pdata = npdata<EOL><DEDENT>if mopt is not None:<EOL><INDENT>fitfcn = self.buildfitfcn()<EOL>p_all = self.buildprior(prior=prior, mopt=None)<EOL>f_all = fitfcn(p_all)<EOL>p_trunc = self.buildprior(prior=prior, mopt=mopt)<EOL>f_trunc = fitfcn(p_trunc)<EOL>pdata = gvar.BufferDict(pdata)<EOL>if not self.ratio:<EOL><INDENT>for m in self.flatmodels:<EOL><INDENT>pdata[m.datatag] += f_trunc[m.datatag] - f_all[m.datatag]<EOL><DEDENT><DEDENT>else:<EOL><INDENT>for m in self.flatmodels:<EOL><INDENT>ii = (gvar.mean(f_all[m.datatag]) != <NUM_LIT:0>)<EOL>ratio = f_trunc[m.datatag][ii] / f_all[m.datatag][ii]<EOL>pdata[m.datatag][ii] *= ratio<EOL><DEDENT><DEDENT><DEDENT>return pdata<EOL>
Rebuild pdata to account for marginalization.