forked from personal/squiggle.c
27 lines
806 B
C
27 lines
806 B
C
#ifndef SQUIGGLEC
|
|
#define SQUIGGLEC
|
|
|
|
// uint32_t header
|
|
#include <stdint.h>
|
|
|
|
// Pseudo Random number generator
|
|
uint32_t xorshift32(uint32_t* seed);
|
|
|
|
// Distribution & sampling functions
|
|
float rand_0_to_1(uint32_t* seed);
|
|
float rand_float(float max, uint32_t* seed);
|
|
float ur_normal(uint32_t* seed);
|
|
float random_uniform(float from, float to, uint32_t* seed);
|
|
float random_normal(float mean, float sigma, uint32_t* seed);
|
|
float random_lognormal(float logmean, float logsigma, uint32_t* seed);
|
|
float random_to(float low, float high, uint32_t* seed);
|
|
|
|
// Array helpers
|
|
float array_sum(float* array, int length);
|
|
void array_cumsum(float* array_to_sum, float* array_cumsummed, int length);
|
|
|
|
// Mixture function
|
|
float mixture(float (*samplers[])(uint32_t*), float* weights, int n_dists, uint32_t* seed);
|
|
|
|
#endif
|