Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
max_post=True
fitmethod="BFGS"
else:
as_priors=None
logging.warn("fit_power_density_spectrum: can't create priors from dave_priors.")
if as_priors:
# Creates a Posterior object with the priors
lpost = PSDPosterior(pds.freq, pds.power, fit_model, priors=as_priors, m=pds.m)
else:
# Creates the Maximum Likelihood object for fitting
lpost = PSDLogLikelihood(pds.freq, pds.power, fit_model, m=pds.m)
# Creates the PSD Parameters Estimation object and runs the fitting
parest = PSDParEst(pds, fitmethod=fitmethod, max_post=max_post)
res = parest.fit(lpost, starting_pars, neg=True)
sample = None
if as_priors and sampling_params is not None:
# If is a Bayesian Par. Est. and has sampling parameters
# then sample the posterior distribution defined in `lpost` using MCMC
sample = parest.sample(lpost, res.p_opt, cov=res.cov,
nwalkers=sampling_params["nwalkers"],
niter=sampling_params["niter"],
burnin=sampling_params["burnin"],
threads=sampling_params["threads"],
print_results=False, plot=False)
# Prepares the results to be returned to GUI
fixed = [fit_model.fixed[n] for n in fit_model.param_names]
parnames = [n for n, f in zip(fit_model.param_names, fixed) \