Probability that each Gaussian-dist R.V. is less than the others :param vscores: mean vector :param var: variance vector This function works by sampling n_samples from every (gaussian) mean distribution, and counting up the number of times each element's sample is the best.
(mean, var, n_samples=1000, rng=None)
| 119 | |
| 120 | |
| 121 | def pmin_sampled(mean, var, n_samples=1000, rng=None): |
| 122 | """Probability that each Gaussian-dist R.V. is less than the others |
| 123 | |
| 124 | :param vscores: mean vector |
| 125 | :param var: variance vector |
| 126 | |
| 127 | This function works by sampling n_samples from every (gaussian) mean distribution, |
| 128 | and counting up the number of times each element's sample is the best. |
| 129 | |
| 130 | """ |
| 131 | if rng is None: |
| 132 | rng = numpy.random.default_rng(232342) |
| 133 | |
| 134 | samples = rng.standard_normal((n_samples, len(mean))) * numpy.sqrt(var) + mean |
| 135 | winners = (samples.T == samples.min(axis=1)).T |
| 136 | wincounts = winners.sum(axis=0) |
| 137 | assert wincounts.shape == mean.shape |
| 138 | return old_div(wincounts.astype("float64"), wincounts.sum()) |
| 139 | |
| 140 | |
| 141 | def fast_isin(X, Y): |