Adding bootstrap sampling to vp2
Created by: wilsonmr
Hi,
I've been messing around trying to add a bootstrap sampling method to vp2 but have gotten a bit stuck.
Basically I would like to get something similar to the output of results
however instead of the theory results coming from the original PDF, being a monte carlo sample of those replicas.
Just to test the idea I added something like this:
def bootstrap_test(results):
"""try to bootstrap values"""
data_result, th_result = results
alldata, central, npoints = abs_chi2_data(results)
th_sample = th_result
th_sample_i = np.floor(np.random.rand(len(th_result._rawdata[0]))*len(th_result._rawdata[0])).astype(int)
th_sample._rawdata = th_result._rawdata[:, th_sample_i]
results = data_result, th_sample
alldata_sample, central_sample, npoints = abs_chi2_data(results)
return alldata.data.mean(), alldata_sample.data.mean()
which does give what I want for alldata, however since I'm just editing the _rawdata property of th_result here, things like central_value property remains untouched so this appears to be the wrong way to go about it.
I think the idea we were thinking of would be to have a bootstrapping function which can take any function in say results.py and calculate it multiple times for different monte carlo samples of replicas.. so somehow feed a different results
in each time which is the new results from sampling. Is something like this possible?