diff --git a/README.md b/README.md index d800382..2d77667 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Squiggle.c -A self-contained C99 library that provides a subset of [Squiggle](https://www.squiggle-language.com/)'s functionality in C. +A self-contained C99 library that provides a subset of [Squiggle](https://www.squiggle-language.com/)'s functionality in C. It should be fast, but at the margin, simplicity of implementation wins over speed. ## Why C? @@ -79,6 +79,8 @@ Behaviour on error can be toggled by the `EXIT_ON_ERROR` variable. This library ## To do list +- [ ] Explain correlated samples +- [ ] Add tests in Stan? - [ ] Have some more complicated & realistic example - [ ] Add summarization functions: 90% ci (or all c.i.?) - [ ] Systematize references diff --git a/examples/01_one_sample/example b/examples/01_one_sample/example index bc04f21..ce80991 100755 Binary files a/examples/01_one_sample/example and b/examples/01_one_sample/example differ diff --git a/examples/01_one_sample/example.c b/examples/01_one_sample/example.c index 337b9ce..4badc5e 100644 --- a/examples/01_one_sample/example.c +++ b/examples/01_one_sample/example.c @@ -39,6 +39,7 @@ int main(){ float result_one = sample_mixture(samplers, weights, n_dists, seed); printf("result_one: %f\n", result_one); + free(seed); } /* diff --git a/examples/02_many_samples/example b/examples/02_many_samples/example index 423e787..6bc060e 100755 Binary files a/examples/02_many_samples/example and b/examples/02_many_samples/example differ diff --git a/examples/02_many_samples/example.c b/examples/02_many_samples/example.c index 7d44ab3..c77a17c 100644 --- a/examples/02_many_samples/example.c +++ b/examples/02_many_samples/example.c @@ -48,6 +48,7 @@ int main(){ printf("%.2f, ", result_many[i]); } printf("]\n"); + free(seed); } /* diff --git a/examples/03_gcc_nested_function/example b/examples/03_gcc_nested_function/example index 84e2593..ef1f7ac 100755 Binary files a/examples/03_gcc_nested_function/example and b/examples/03_gcc_nested_function/example differ diff --git a/examples/03_gcc_nested_function/example.c b/examples/03_gcc_nested_function/example.c index 354d8f9..7d1a0b5 100644 --- a/examples/03_gcc_nested_function/example.c +++ b/examples/03_gcc_nested_function/example.c @@ -33,5 +33,6 @@ int main(){ printf("%.2f, ", result_many[i]); } printf("]\n"); + free(seed); } diff --git a/examples/04_sample_from_cdf_simple/example b/examples/04_sample_from_cdf_simple/example index 61fd198..97dc565 100755 Binary files a/examples/04_sample_from_cdf_simple/example and b/examples/04_sample_from_cdf_simple/example differ diff --git a/examples/05_sample_from_cdf_beta/example b/examples/05_sample_from_cdf_beta/example index 4bc0554..7f3c14e 100755 Binary files a/examples/05_sample_from_cdf_beta/example and b/examples/05_sample_from_cdf_beta/example differ diff --git a/squiggle.h b/squiggle.h index 84d95eb..31eb537 100644 --- a/squiggle.h +++ b/squiggle.h @@ -17,6 +17,9 @@ float sample_normal(float mean, float sigma, uint32_t* seed); float sample_lognormal(float logmean, float logsigma, uint32_t* seed); float sample_to(float low, float high, uint32_t* seed); +float sample_gamma(float alpha, uint32_t* seed); +float sample_beta(float a, float b, uint32_t* seed); + // Array helpers float array_sum(float* array, int length); void array_cumsum(float* array_to_sum, float* array_cumsummed, int length);