squiggle.c

Self-contained Monte Carlo estimation in C99
Log | Files | Refs | README

commit 21315240178c0fa0017a36e6fefc7b80380ea438
parent 08eb790a6de911bb6d5287fe7cc71359de776566
Author: NunoSempere <nuno.sempere@protonmail.com>
Date:   Sun, 23 Jul 2023 10:09:34 +0200

README tweaks, free seed in examples

Diffstat:
MREADME.md | 4+++-
Mexamples/01_one_sample/example | 0
Mexamples/01_one_sample/example.c | 1+
Mexamples/02_many_samples/example | 0
Mexamples/02_many_samples/example.c | 1+
Mexamples/03_gcc_nested_function/example | 0
Mexamples/03_gcc_nested_function/example.c | 1+
Mexamples/04_sample_from_cdf_simple/example | 0
Mexamples/05_sample_from_cdf_beta/example | 0
Msquiggle.h | 3+++
10 files changed, 9 insertions(+), 1 deletion(-)

diff --git 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 Binary files differ. diff --git 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 Binary files differ. diff --git 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 Binary files differ. diff --git 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 Binary files differ. diff --git a/examples/05_sample_from_cdf_beta/example b/examples/05_sample_from_cdf_beta/example Binary files differ. diff --git 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);