2023-11-18 20:25:12 +00:00
|
|
|
#ifndef SQUIGGLE_C_CORE
|
|
|
|
#define SQUIGGLE_C_CORE
|
2023-06-26 17:44:41 +00:00
|
|
|
|
2023-07-23 10:47:47 +00:00
|
|
|
// uint64_t header
|
2023-07-16 19:00:30 +00:00
|
|
|
#include <stdint.h>
|
2023-06-26 17:44:41 +00:00
|
|
|
|
|
|
|
// Pseudo Random number generator
|
2023-07-23 10:47:47 +00:00
|
|
|
uint64_t xorshift64(uint64_t* seed);
|
2023-06-26 17:44:41 +00:00
|
|
|
|
2023-07-16 20:32:03 +00:00
|
|
|
// Basic distribution sampling functions
|
2023-07-23 11:02:56 +00:00
|
|
|
double sample_unit_uniform(uint64_t* seed);
|
|
|
|
double sample_unit_normal(uint64_t* seed);
|
2023-07-16 20:32:03 +00:00
|
|
|
|
|
|
|
// Composite distribution sampling functions
|
2023-07-23 11:02:56 +00:00
|
|
|
double sample_uniform(double start, double end, uint64_t* seed);
|
|
|
|
double sample_normal(double mean, double sigma, uint64_t* seed);
|
|
|
|
double sample_lognormal(double logmean, double logsigma, uint64_t* seed);
|
|
|
|
double sample_to(double low, double high, uint64_t* seed);
|
2023-06-26 17:44:41 +00:00
|
|
|
|
2023-07-23 11:02:56 +00:00
|
|
|
double sample_gamma(double alpha, uint64_t* seed);
|
|
|
|
double sample_beta(double a, double b, uint64_t* seed);
|
2023-08-11 12:01:02 +00:00
|
|
|
double sample_laplace(double successes, double failures, uint64_t* seed);
|
2023-07-23 08:09:34 +00:00
|
|
|
|
2023-06-26 17:44:41 +00:00
|
|
|
// Array helpers
|
2023-07-23 11:02:56 +00:00
|
|
|
double array_sum(double* array, int length);
|
|
|
|
void array_cumsum(double* array_to_sum, double* array_cumsummed, int length);
|
|
|
|
double array_mean(double* array, int length);
|
|
|
|
double array_std(double* array, int length);
|
2023-06-26 17:44:41 +00:00
|
|
|
|
|
|
|
// Mixture function
|
2023-07-23 11:02:56 +00:00
|
|
|
double sample_mixture(double (*samplers[])(uint64_t*), double* weights, int n_dists, uint64_t* seed);
|
2023-06-26 17:44:41 +00:00
|
|
|
|
2023-12-09 17:59:41 +00:00
|
|
|
// Trick to mute unused variable warning. Useful for nested functions
|
|
|
|
#define UNUSED(x) (void)(x)
|
|
|
|
|
2023-07-16 19:00:30 +00:00
|
|
|
#endif
|