squiggle.c/squiggle.h

27 lines
806 B
C
Raw Normal View History

#ifndef SQUIGGLEC
#define SQUIGGLEC
2023-06-26 17:44:41 +00:00
// uint32_t header
#include <stdint.h>
2023-06-26 17:44:41 +00:00
// Pseudo Random number generator
uint32_t xorshift32(uint32_t* seed);
2023-06-26 17:44:41 +00:00
// 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);
2023-06-26 17:44:41 +00:00
// Array helpers
float array_sum(float* array, int length);
void array_cumsum(float* array_to_sum, float* array_cumsummed, int length);
2023-06-26 17:44:41 +00:00
// Mixture function
float mixture(float (*samplers[])(uint32_t*), float* weights, int n_dists, uint32_t* seed);
2023-06-26 17:44:41 +00:00
#endif