nk 1.0.0
C++ Numerical Computing Runtime
Loading...
Searching...
No Matches
resample.hpp
Go to the documentation of this file.
1
3// toolboxes/stats/include/nk/stats/resample/resample.hpp
4//
5// Random sampling and resampling utilities.
6
7#pragma once
8
9#include <memory_resource>
10#include <nk/value/span.hpp>
11#include <nk/value/value.hpp>
12
13namespace nk {
14
17 namespace ops { class RngContext; } }
18
19namespace nk::stats {
20
36Value randsample(::nk::ops::RngContext &rng, int N, int K, bool with_replacement, const Value &weights,
37 std::pmr::memory_resource *mr = nullptr);
38
52Value datasample(::nk::ops::RngContext &rng, const Value &X, int K, int dim, bool with_replacement,
53 const Value &weights, std::pmr::memory_resource *mr = nullptr);
54
55// NOTE: bootstrp / jackknife are not exposed as Engine-free C++ cores — they
56// must invoke a user statistic via the engine, so the logic lives inline in
57// their register half (bundle/.../resample/resample_reg.cpp).
58
67Value combnk(int N, int K,
68 std::pmr::memory_resource *mr = nullptr);
69
80 std::pmr::memory_resource *mr = nullptr);
81
82
84} // namespace nk::stats
Core MATLAB-compatible multidimensional array and scalar value type.
Definition value.hpp:61
Value randsample(::nk::ops::RngContext &rng, int N, int K, bool with_replacement, const Value &weights, std::pmr::memory_resource *mr=nullptr)
Sample integers from 1..N (r = randsample(N, K, replacement, weights)).
Value combnk(int N, int K, std::pmr::memory_resource *mr=nullptr)
Enumerate K-combinations of 1..N (C = combnk(N, K)).
Value datasample(::nk::ops::RngContext &rng, const Value &X, int K, int dim, bool with_replacement, const Value &weights, std::pmr::memory_resource *mr=nullptr)
Sample rows / columns of an array (Y = datasample(X, K, dim, replacement, weights)).