(self, low, high, q)
| 128 | # because I don't understand the design of those rv classes |
| 129 | |
| 130 | def __init__(self, low, high, q): |
| 131 | low, high = list(map(float, (low, high))) |
| 132 | elow = np.exp(low) |
| 133 | ehigh = np.exp(high) |
| 134 | qlow = safe_int_cast(np.round(old_div(elow, q))) * q |
| 135 | qhigh = safe_int_cast(np.round(old_div(ehigh, q))) * q |
| 136 | |
| 137 | # -- loguniform for using the CDF |
| 138 | lu = loguniform_gen(low=low, high=high) |
| 139 | |
| 140 | cut_low = np.exp(low) # -- lowest possible pre-round value |
| 141 | cut_high = min( |
| 142 | qlow + 0.5 * q, ehigh # -- highest value that would ... |
| 143 | ) # -- round to qlow |
| 144 | xs = [qlow] |
| 145 | ps = [lu.cdf(cut_high)] |
| 146 | ii = 0 |
| 147 | cdf_high = ps[0] |
| 148 | |
| 149 | while cut_high < (ehigh - 1e-10): |
| 150 | # TODO: cut_low never used |
| 151 | cut_high, cut_low = min(cut_high + q, ehigh), cut_high |
| 152 | cdf_high, cdf_low = lu.cdf(cut_high), cdf_high |
| 153 | ii += 1 |
| 154 | xs.append(qlow + ii * q) |
| 155 | ps.append(cdf_high - cdf_low) |
| 156 | |
| 157 | ps = np.asarray(ps) |
| 158 | ps /= ps.sum() |
| 159 | |
| 160 | self.low = low |
| 161 | self.high = high |
| 162 | self.q = q |
| 163 | self.qlow = qlow |
| 164 | self.qhigh = qhigh |
| 165 | self.xs = np.asarray(xs) |
| 166 | self.ps = ps |
| 167 | |
| 168 | def pmf(self, x): |
| 169 | return qtable_pmf(x, self.q, self.qlow, self.xs, self.ps) |
nothing calls this directly
no test coverage detected