Skip to content

select_realizations builtin

select_realizations(realizations, n, *, seed=0)

Representative realizations by k-medoids, e.g. the truths of a drill hole spacing study.

Realizations are compared by the Euclidean distance between their values (block or panel grades, one column per target). A seeded k-medoids++ start is refined by PAM swaps until no exchange of a medoid for another realization lowers the total distance of every realization to its nearest medoid. Each medoid is a simulated realization standing for its cluster, so a few medoids span the range of outcomes that a random draw of the same size may miss. Distances are computed in parallel, identically on any number of threads.

Parameters:

Name Type Description Default
realizations SimulationSummary or array_like

A summary simulated with keep=, or (n_realizations, targets) values. Targets that are not finite in any realization are ignored.

required
n int

Number of realizations to select, 1 to the number of realizations.

required
seed int

Seed of the k-medoids++ start.

0

Returns:

Type Description
ndarray

(n,) row indices of the medoids (positions in kept for a summary), by cluster size, largest first, ties by index.

Raises:

Type Description
InvalidInput

If a summary holds no realizations, n is out of range, no target is finite in every realization, or the distances overflow.

Examples:

>>> truths = bt.select_realizations(summary, 5, seed=1)
>>> summary.realizations[truths].shape
(5, 400)

used in