hecss.optimize¶
Post-processing procedure to match the sampling set to the target distribution by adjusting the data weights in the sample.
__all__ = ['get_sample_weights', 'make_sampling']
module-attribute
¶
get_sample_weights(data, T, sigma_scale=1.0, border=False, debug=False)
¶
Generate data weights making the probability distribution of data in
sample format into normal distribution corresponding to temperature T.
The actual distribution traces the normal curve. Normally, no weight
is given to the data outside the input data range. This may skew the
resulting distribution and shift its parameters but avoids nasty border
artefacts in the form of large weights given to border samples to account
for the rest of the domain. You can switch this behavior on by passing
border parameter (not recommended).
Input¶
data- list of samples generated by HECSS sampler ([n, i, x, f, e])T- temperature in kelvinsigma_scale- scaling factor for variance. Defaults to 1.0.border- make border samples account for unrepresented part of domaindebug- plot diagnostic plots
Output (weights, index)¶
- weights - array of weights in sorted energy order
- index - indexing array which sorts samples by energy
Source code in hecss/optimize.py
make_sampling(data, T, sigma_scale=1.0, border=False, probTH=0.25, Nmul=4, N=None, nonzero_w=True, debug=False)
¶
Generate new sample with normal energy probability distribution
corresponding to temperature T and size of the system inferred
from data. The output is generated by multiplying samples
proportionally to the weights generated by get_sample_weights
and assuming the final dataset will be Nmul times longer
(or the length N which takes precedence). If nonzero_w is True
the data multipliers in the range (probTH, 1) will be clamped to 1,
to avoid losing low-probability data. This will obviously deform the
distribution but may be beneficial for the interaction model constructed
from the data. The data on output will be ordered in increasing energy
and re-numbered. The configuration index is retained.
Input¶
data- list of samples generated by HECSS sampler ([n, i, x, f, e])T- temperature in kelvinsigma_scale- scaling factor for variance. Defaults to 1.0.border- make border samples account for unrepresented part of domainprobTH- threshold for probability (N*weight) clamping.Nmul- data multiplication factor. The length of output data will be approximatelyNmul*len(data).N- approximate output data length. Takes precedence overNmulnonzero_w- prevent zero weights for data with weights in (probTH, 1) rangedebug- plot diagnostic plots
Output¶
Weighted, sorted by energy and re-numbered samples as a new list.
The data in the list is just reference-duplicated, not copied.
Thus the data elements should not be modified.
The format is the same as the data produced by HECSS sampler.
Source code in hecss/optimize.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |