Example #1
0
                stats[fitname[redshift_bin]] = []
                output[fitname[redshift_bin]] = []
                c[redshift_bin].add_chain(df,
                                          weights=weight,
                                          **extra,
                                          plot_contour=True,
                                          plot_point=False,
                                          show_as_1d_prior=False)
            else:
                c[redshift_bin].add_marker(params, **extra)

            # Compute some summary statistics and add them to a dictionary
            mean, cov = weighted_avg_and_cov(
                df[[
                    "$\\alpha_\\parallel$",
                    "$\\alpha_\\perp$",
                ]],
                weight,
                axis=0,
            )

            corr = cov[1, 0] / np.sqrt(cov[0, 0] * cov[1, 1])
            stats[fitname[redshift_bin]].append([
                mean[0], mean[1],
                np.sqrt(cov[0, 0]),
                np.sqrt(cov[1, 1]), corr, new_chi_squared
            ])
            output[fitname[redshift_bin]].append(
                f"{realisation:s}, {mean[0]:6.4f}, {mean[1]:6.4f}, {np.sqrt(cov[0, 0]):6.4f}, {np.sqrt(cov[1, 1]):6.4f}, {corr:7.3f}, {r_s:7.3f}, {new_chi_squared:7.3f}, {dof:4d}"
            )

        truth = {
Example #2
0
            figname = pfn + "_" + fitname + "_bestfit.pdf" if counter == 3 else None
            new_chi_squared, dof, bband, mods, smooths = model.plot(
                params, display=False, figname=figname)

            ps = chain[max_post, :]
            best_fit = {}
            for l, p in zip(model.get_labels(), ps):
                best_fit[l] = p

            mean, cov = weighted_avg_and_cov(
                df[[
                    "$\\alpha_\\parallel$",
                    "$\\alpha_\\perp$",
                    "$\\Sigma_s$",
                    "$\\Sigma_{nl,||}$",
                    "$\\Sigma_{nl,\\perp}$",
                ]],
                weight,
                axis=0,
            )

            corr = cov[1, 0] / np.sqrt(cov[0, 0] * cov[1, 1])
            print(fitname)
            if "3-Poly" in fitname:
                if "No-Hexa" in fitname:
                    output[fitname].append(
                        f"{kmax:3s}, {mean[0]:6.4f}, {mean[1]:6.4f}, {np.sqrt(cov[0,0]):6.4f}, {np.sqrt(cov[1,1]):6.4f}, {corr:7.3f}, {r_s:7.3f}, {chi2:7.3f}, {dof:4d}, {mean[3]:7.3f}, {mean[4]:7.3f}, {mean[2]:7.3f}, {bband[0]:7.3f}, {bband[1]:8.1f}, {bband[2]:8.1f}, {bband[3]:8.1f}, {bband[4]:8.1f}, {bband[5]:8.1f}, {bband[6]:8.1f}"
                    )
                else:
                    output[fitname].append(