nk 1.0.0
C++ Numerical Computing Runtime
Loading...
Searching...
No Matches
gamma_dist.hpp
Go to the documentation of this file.
1
3// toolboxes/stats/include/nk/stats/distributions/gamma_dist.hpp
4//
5// Gamma distribution Gamma(a, b): a = shape, b = scale.
6
7#pragma once
8
9#include <memory_resource>
10#include <nk/value/value.hpp>
11
12#include <tuple>
13
14namespace nk {
15
18 namespace ops { class RngContext; } }
19
20namespace nk::stats {
21
33Value gampdf(const Value &x, double a, double b, std::pmr::memory_resource *mr = nullptr);
34
46Value gamcdf(const Value &x, double a, double b, std::pmr::memory_resource *mr = nullptr);
47
58Value gaminv(const Value &p, double a, double b, std::pmr::memory_resource *mr = nullptr);
59
71Value gamrnd(::nk::ops::RngContext &rng, double a, double b, size_t rows = 1, size_t cols = 1, std::pmr::memory_resource *mr = nullptr);
72
81std::tuple<double, double> gamstat(double a, double b);
82
96Value randg(::nk::ops::RngContext &rng, double shape, size_t rows = 1, size_t cols = 1,
97 std::pmr::memory_resource *mr = nullptr);
98
110Value randg(::nk::ops::RngContext &rng, const Value &shapeArray,
111 std::pmr::memory_resource *mr = nullptr);
112
127Value gamfit(const Value &x, std::pmr::memory_resource *mr = nullptr);
128
138Value gamfit(const Value &x, const Value &censoring, const Value &freq,
139 std::pmr::memory_resource *mr = nullptr);
140
146Value gamfit_ci(const Value &x, double alpha = 0.05,
147 std::pmr::memory_resource *mr = nullptr);
148
151Value gamfit_ci(const Value &x, double alpha,
152 const Value &censoring, const Value &freq,
153 std::pmr::memory_resource *mr = nullptr);
154
155
157} // namespace nk::stats
Core MATLAB-compatible multidimensional array and scalar value type.
Definition value.hpp:61
Value gampdf(const Value &x, double a, double b, std::pmr::memory_resource *mr=nullptr)
Gamma pdf (y = gampdf(x, a, b)).
Value gamrnd(::nk::ops::RngContext &rng, double a, double b, size_t rows=1, size_t cols=1, std::pmr::memory_resource *mr=nullptr)
Gamma random samples (r = gamrnd(a, b, rows, cols)).
Value gamfit(const Value &x, std::pmr::memory_resource *mr=nullptr)
Gamma distribution MLE fit ([ahat, bhat] = gamfit(x)).
Value gaminv(const Value &p, double a, double b, std::pmr::memory_resource *mr=nullptr)
Gamma inverse cdf (x = gaminv(p, a, b)).
std::tuple< double, double > gamstat(double a, double b)
Gamma mean and variance ([m, v] = gamstat(a, b)).
Value gamcdf(const Value &x, double a, double b, std::pmr::memory_resource *mr=nullptr)
Gamma cdf (F = gamcdf(x, a, b)).
Value gamfit_ci(const Value &x, double alpha=0.05, std::pmr::memory_resource *mr=nullptr)
95% Wald CI for gamfit (pci = gamfit_ci(x, alpha)).
Value randg(::nk::ops::RngContext &rng, double shape, size_t rows=1, size_t cols=1, std::pmr::memory_resource *mr=nullptr)
Raw gamma(shape, 1) RNG (r = randg(shape [, rows, cols])).