def test_sampler_runs(self): pe = PSDParEst(self.ps) sample_res = pe.sample(self.lpost, [2.0, 0.1, 100, 2.0], nwalkers=50, niter=10, burnin=15, print_results=True, plot=True) assert os.path.exists("test_corner.pdf") os.unlink("test_corner.pdf") assert sample_res.acceptance > 0.25 assert isinstance(sample_res, SamplingResults)
p_whitenoise = lambda white_noise: scipy.stats.norm(2.0, 0.1).pdf(white_noise) priors = {} priors["alpha_0"] = p_alpha priors["amplitude_0"] = p_amplitude priors["amplitude_1"] = p_whitenoise starting_pars = [3.0, 1.0, 2.4] lpost = PSDPosterior(ps.freq, ps.power, plc, priors=priors, m=ps.m) parest = PSDParEst(ps, fitmethod='BFGS', max_post=True) res = parest.fit(lpost, starting_pars) sample = parest.sample(lpost, res.p_opt, cov=res.cov, nwalkers=400, niter=100, burnin=200, namestr="psd_modeling_test") max_power, max_freq, max_ind = parest._compute_highest_outlier(lpost, res) print(max_power) pval = parest.calibrate_highest_outlier(lpost, starting_pars, sample=sample, max_post=True, nsim=100, niter=100, nwalkers=400, burnin=200, namestr="test")