def check_empirical_phi(self):
nt_freqs = [<NUM_LIT:0>] * N_NT<EOL>for r in range(self.nsites):<EOL><INDENT>for x in range(N_CODON):<EOL><INDENT>for w in range(N_NT):<EOL><INDENT>nt_freqs[w] += self.expcm.prx[r][x] * CODON_NT_COUNT[w][x]<EOL><DEDENT><DEDENT><DEDENT>self.assertTrue(scipy.allclose(sum(nt_freqs), <NUM_LIT:3> * self.nsites))<EOL>nt_freqs = scipy.array(nt_freqs)<EOL>nt_freqs /= nt_freqs.sum()<EOL>self.assertTrue(scipy.allclose(nt_freqs, self.expcm.g, atol=<NUM_LIT>),<EOL>"<STR_LIT>".format(<EOL>nt_freqs, self.expcm.g))<EOL>def func_phi(beta, expcm, w):<EOL><INDENT>expcm.updateParams({'<STR_LIT>':beta[<NUM_LIT:0>]})<EOL>return expcm.phi[w]<EOL><DEDENT>def func_dphi(beta, expcm, w):<EOL><INDENT>expcm.updateParams({'<STR_LIT>':beta[<NUM_LIT:0>]})<EOL>return expcm.dphi_dbeta[w]<EOL><DEDENT>for w in range(N_NT):<EOL><INDENT>diff = scipy.optimize.check_grad(func_phi, func_dphi,<EOL>[self.expcm.beta], self.expcm, w, epsilon=<NUM_LIT>)<EOL>self.assertTrue(diff < <NUM_LIT>,<EOL>"<STR_LIT>".format(diff, w))<EOL><DEDENT>self.expcm.updateParams(self.params)<EOL>
Check that `phi` gives right `g`, and has right derivative.