<a id="skfolio-utils-stats-sample-unique-subsets"></a>

# skfolio.utils.stats.sample_unique_subsets

<a id="skfolio.utils.stats.sample_unique_subsets"></a>

### skfolio.utils.stats.sample_unique_subsets(n, k, n_subsets, random_state=None)

Generate unique k-element subsets from a universe of size n using combinatorial
unranking.

Each subset is drawn without replacement (elements within subset are distinct) and
no subset is repeated across draws. Ranks are sampled uniformly without replacement
over [0, C(n, k)).

Time complexity: O(n_subsets \* k)
Space complexity: O(n_subsets \* k)

* **Parameters:**
  **n** *int*
  : Universe size.

  **k** *int*
  : Subset size (0 <= k <= n).

  **n_subsets** *int*
  : Number of distinct subsets to generate (0 <= n_subsets <= C(n, k)).

  **random_state** *int, RandomState instance, optional*
  : Seed or random state to ensure reproducibility.
* **Returns:**
  **subsets** *ndarray of shape (n_subsets, k)*
  : 2D integer array of shape (n_subsets, k) where each row is a sorted
    k-combination.
* **Raises:**
  ValueError
  : If any parameters are out of valid ranges.

