Nonlinear Optimization¶
The main result of running rsdfit nlopt ...
is a *.npz
file saved to the
output directory for each MCMC chain that was run. These results can be
loaded from file using the pyRSD.rsdfit.results.LBFGSResults
class.
The LBFGSResults
stores the best-fit values for both the
free parameters and the constrained parameters, as computed from the final
iteration of the LBFGS algorithm.
The best-fit parameter values and the corresponding minimum \(\chi^2 value\)
can be quickly displayed by printing the LBFGSResults
object.
For example,
In [1]: from pyRSD.rsdfit.results import LBFGSResults
In [2]: results = LBFGSResults.from_npz('nlopt_result.npz')
# print out a summary of the best-fit parameters
In [3]: print(results)
minimum chi2 = 120.57745038002743
Free parameters [ mean ]
_______________
Nsat_mult : 2.4324089012014207
alpha_par : 1.0072991239946898
alpha_perp : 1.0048333693698863
b1_cA : 2.0068377074748778
f : 0.8735346371321935
f1h_sBsB : 3.6140366462767153
fs : 0.14175570928456935
fsB : 0.4782779433107577
gamma_b1sA : 1.31213984320964
gamma_b1sB : 2.3651886897525896
sigma8_z : 0.5363993024676117
sigma_c : 0.9194602113178405
sigma_sA : 3.420304679802984
Constrained parameters [ mean ]
_________________________
NsBsB : 51736.1
b1_sA : 2.6332517
NcBs : 23183.68
fcB : 0.11864934
sigma_sB : 5.739127
b1_sB : 4.74655
b1_cB : 3.2117057
epsilon : 0.0008172965
b1_c : 2.1497946
b1sigma8 : 1.2667638
alpha : 1.0056546
F_AP : 1.0024539
b1_s : 3.6439955
fsigma8 : 0.46856338
b1 : 2.3616061
The minimum \(\chi^2\) value can be accessed from the min_chi2
attribute of the LBFGSResults
object.
Parameter Access¶
The LBFGSResults
object provides
access to the parameters via a dictionary-like behavior. When accessing
parameters using the name as the key, the best-fit value of that
parameter is returned.
For example,
# growth rate
In [4]: f = results['f']
In [5]: print(f)
0.8735346371321935
# power spectrum normalization
In [6]: sigma8 = results['sigma8_z']
In [7]: print(sigma8)
0.5363993024676117
# this is the product of f and sigma8_z
In [8]: fs8 = results['fsigma8']
In [9]: print(fs8)
0.46856338
In [10]: print(numpy.isclose(fs8, f*sigma8))