squiggle_more.h (1111B)
1 #ifndef SQUIGGLE_C_EXTRA 2 #define SQUIGGLE_C_EXTRA 3 4 /* Parallel sampling */ 5 void sampler_parallel(double (*sampler)(uint64_t* seed), double* results, int n_threads, int n_samples); 6 7 /* Stats */ 8 double array_get_median(double xs[], int n); 9 typedef struct ci_t { 10 double low; 11 double high; 12 } ci; 13 ci array_get_ci(ci interval, double* xs, int n); 14 ci array_get_90_ci(double xs[], int n); 15 16 void array_print_stats(double xs[], int n); 17 void array_print_histogram(double* xs, int n_samples, int n_bins); 18 void array_print_90_ci_histogram(double* xs, int n, int n_bins); 19 20 /* Algebra manipulations */ 21 22 typedef struct normal_params_t { 23 double mean; 24 double std; 25 } normal_params; 26 normal_params algebra_sum_normals(normal_params a, normal_params b); 27 28 typedef struct lognormal_params_t { 29 double logmean; 30 double logstd; 31 } lognormal_params; 32 lognormal_params algebra_product_lognormals(lognormal_params a, lognormal_params b); 33 34 lognormal_params convert_ci_to_lognormal_params(ci x); 35 ci convert_lognormal_params_to_ci(lognormal_params y); 36 37 /* Utilities */ 38 39 #define THOUSAND 1000 40 #define MILLION 1000000 41 42 #endif