Clustering
C++20 header-only: DBSCAN, HDBSCAN, k-means.
Loading...
Searching...
No Matches
rng.h File Reference
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <span>
#include <type_traits>
#include <utility>
#include <vector>
#include "clustering/ndarray.h"
Include dependency graph for rng.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  clustering::math::pcg64
 128-bit state for the PCG-XSL-RR 64-bit output generator (Melissa O'Neill). More...
struct  clustering::math::xoshiro256ss
 256-bit state for Vigna & Blackman's xoshiro256** generator. More...

Namespaces

namespace  clustering
namespace  clustering::math

Functions

std::uint64_t clustering::math::advanceState (pcg64 &rng) noexcept
 Advance a pcg64 one step and return the 64-bit XSL-RR output.
std::uint64_t clustering::math::advanceState (xoshiro256ss &rng) noexcept
 Advance a xoshiro256ss one step and return the 64-bit output.
template<class Rng>
std::uint32_t clustering::math::randUniformU32 (Rng &rng) noexcept
 Draw a 32-bit unsigned integer uniformly at random from the full u32 range.
template<class Rng>
std::uint64_t clustering::math::randUniformU64 (Rng &rng) noexcept
 Draw a 64-bit unsigned integer uniformly at random from the full u64 range.
template<class T, class Rng>
clustering::math::randUnit (Rng &rng) noexcept
 Draw a uniform variate in the half-open unit interval [0, 1).
template<class T, Layout L, class Rng>
std::size_t clustering::math::weightedCategorical (const NDArray< T, 1, L > &weights, Rng &rng) noexcept
 Sample one category index proportionally to non-negative weights.
template<class T, Layout L, class Rng>
void clustering::math::aExpjReservoir (const NDArray< T, 1, L > &weights, std::size_t k, Rng &rng, std::span< std::size_t > outIdx) noexcept
 Efraimidis-Spirakis weighted reservoir sampling (A-Exp variant, log-key form).