time-to-botec/squiggle.c/squiggle_c/squiggle_more.h

43 lines
1.1 KiB
C
Raw Normal View History

#ifndef SQUIGGLE_C_EXTRA
2023-11-30 00:02:02 +00:00
#define SQUIGGLE_C_EXTRA
2023-11-30 00:02:02 +00:00
/* Parallel sampling */
void sampler_parallel(double (*sampler)(uint64_t* seed), double* results, int n_threads, int n_samples);
2024-02-11 18:43:28 +00:00
/* Stats */
double array_get_median(double xs[], int n);
typedef struct ci_t {
2023-11-30 00:02:02 +00:00
double low;
double high;
} ci;
2023-11-30 00:02:02 +00:00
ci array_get_ci(ci interval, double* xs, int n);
ci array_get_90_ci(double xs[], int n);
2024-02-11 18:43:28 +00:00
void array_print_stats(double xs[], int n);
void array_print_histogram(double* xs, int n_samples, int n_bins);
void array_print_90_ci_histogram(double* xs, int n, int n_bins);
2023-11-30 00:02:02 +00:00
/* Algebra manipulations */
typedef struct normal_params_t {
double mean;
double std;
} normal_params;
normal_params algebra_sum_normals(normal_params a, normal_params b);
typedef struct lognormal_params_t {
double logmean;
double logstd;
} lognormal_params;
lognormal_params algebra_product_lognormals(lognormal_params a, lognormal_params b);
lognormal_params convert_ci_to_lognormal_params(ci x);
2023-11-30 00:02:02 +00:00
ci convert_lognormal_params_to_ci(lognormal_params y);
2024-02-11 18:43:28 +00:00
/* Utilities */
#define THOUSAND 1000
#define MILLION 1000000
#endif