LMMC
Lamina Mathematic core
载入中...
搜索中...
未找到
random.h
浏览该文件的文档.
1
8#ifndef LMMC_RANDOM_H
9#define LMMC_RANDOM_H
10
11#include "lmmc/config.h"
12#include "lmmc/status.h"
13#include <stddef.h>
14#include <stdint.h>
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
21typedef struct lmmc_rng_t lmmc_rng_t;
22
40
42lmmc_status_t lmmc_rng_seed(lmmc_rng_t* rng, uint64_t seed);
45
59
72
85
87uint64_t lmmc_rng_next_u64(lmmc_rng_t* rng);
88
95
103 lmmc_rng_t* rng,
104 lmmc_real_t a,
105 lmmc_real_t b,
106 lmmc_real_t* out_value
107);
108
128 lmmc_rng_t* rng,
129 lmmc_real_t mean,
130 lmmc_real_t stddev,
131 lmmc_real_t* out_value
132);
133
136 lmmc_rng_t* rng,
137 lmmc_real_t rate,
138 lmmc_real_t* out_value
139);
140
143 lmmc_rng_t* rng,
144 lmmc_real_t a,
145 lmmc_real_t b,
146 lmmc_real_t* array,
147 size_t count
148);
149
164 lmmc_rng_t* rng,
165 void* array,
166 size_t count,
167 size_t elem_size
168);
169
190 lmmc_rng_t* rng,
191 lmmc_real_t shape,
192 lmmc_real_t scale,
193 lmmc_real_t* out
194);
195
211 lmmc_rng_t* rng,
212 lmmc_real_t alpha,
213 lmmc_real_t beta_param,
214 lmmc_real_t* out
215);
216
227 lmmc_rng_t* rng,
228 lmmc_real_t df,
229 lmmc_real_t* out
230);
231
242 lmmc_rng_t* rng,
243 lmmc_real_t df,
244 lmmc_real_t* out
245);
246
258 lmmc_rng_t* rng,
259 lmmc_real_t df1,
260 lmmc_real_t df2,
261 lmmc_real_t* out
262);
263
282 lmmc_rng_t* rng,
283 lmmc_real_t lambda,
284 size_t* out
285);
286
301 lmmc_rng_t* rng,
302 size_t n,
303 lmmc_real_t p,
304 size_t* out
305);
306
319 lmmc_rng_t* rng,
320 int64_t lo,
321 int64_t hi,
322 int64_t* out
323);
324
325#ifdef __cplusplus
326}
327#endif
328
329#endif
LMMC binary real type and arithmetic spelling.
double lmmc_real_t
Public and internal LMMC real type.
lmmc_status_t lmmc_rng_long_jump(lmmc_rng_t *rng)
将 RNG 状态前进 2^192 步(xoshiro256** long_jump 多项式)。
lmmc_status_t lmmc_rng_jump(lmmc_rng_t *rng)
将 RNG 状态前进 2^128 步(xoshiro256** jump 多项式)。
lmmc_status_t lmmc_rng_student_t(lmmc_rng_t *rng, lmmc_real_t df, lmmc_real_t *out)
生成 Student-t 分布样本 t(df)。
lmmc_status_t lmmc_rng_normal(lmmc_rng_t *rng, lmmc_real_t mean, lmmc_real_t stddev, lmmc_real_t *out_value)
生成正态分布 样本。
lmmc_status_t lmmc_rng_clone(const lmmc_rng_t *src, lmmc_rng_t **out_rng)
深拷贝 RNG 状态。
lmmc_status_t lmmc_rng_chi_squared(lmmc_rng_t *rng, lmmc_real_t df, lmmc_real_t *out)
生成卡方分布样本 Chi-squared(df)。
lmmc_status_t lmmc_rng_poisson(lmmc_rng_t *rng, lmmc_real_t lambda, size_t *out)
生成 Poisson 分布样本 。
lmmc_status_t lmmc_rng_exponential(lmmc_rng_t *rng, lmmc_real_t rate, lmmc_real_t *out_value)
生成参数为 rate 的指数分布样本。
lmmc_status_t lmmc_rng_int_uniform(lmmc_rng_t *rng, int64_t lo, int64_t hi, int64_t *out)
在 [lo, hi] 闭区间内生成无偏均匀整数分布样本。
lmmc_status_t lmmc_rng_create(lmmc_rng_t **out_rng)
创建随机数发生器实例。
lmmc_status_t lmmc_rng_f(lmmc_rng_t *rng, lmmc_real_t df1, lmmc_real_t df2, lmmc_real_t *out)
生成 F 分布样本 F(df1, df2)。
lmmc_status_t lmmc_rng_uniform(lmmc_rng_t *rng, lmmc_real_t a, lmmc_real_t b, lmmc_real_t *out_value)
实数分布参数的公共约束。
lmmc_status_t lmmc_rng_gamma(lmmc_rng_t *rng, lmmc_real_t shape, lmmc_real_t scale, lmmc_real_t *out)
生成 Gamma 分布样本 。
lmmc_status_t lmmc_rng_binomial(lmmc_rng_t *rng, size_t n, lmmc_real_t p, size_t *out)
生成二项分布样本 Binomial(n, p)。
lmmc_status_t lmmc_rng_shuffle(lmmc_rng_t *rng, void *array, size_t count, size_t elem_size)
Fisher-Yates 洗牌:就地随机重排 array 中的 count 个元素。 每次 Fisher-Yates 选择均使用无偏的拒绝采样。
lmmc_status_t lmmc_rng_fill_uniform(lmmc_rng_t *rng, lmmc_real_t a, lmmc_real_t b, lmmc_real_t *array, size_t count)
批量填充均匀分布样本到 array 。
uint64_t lmmc_rng_next_u64(lmmc_rng_t *rng)
直接获取下一个 64 位均匀整数。
void lmmc_rng_destroy(lmmc_rng_t *rng)
销毁发生器,释放内部分配的所有内存。
lmmc_status_t lmmc_rng_beta(lmmc_rng_t *rng, lmmc_real_t alpha, lmmc_real_t beta_param, lmmc_real_t *out)
生成 Beta 分布样本 Beta(alpha, beta)。
lmmc_status_t lmmc_rng_seed(lmmc_rng_t *rng, uint64_t seed)
重新设定种子。
随机数发生器(不透明类型)。
LMMC 通用状态码定义.
lmmc_status_t
LMMC 库统一返回的状态码.