squiggle.c

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

commit 1133d7819c1c21b8674578aa89948c2e64ad80a9
parent 7694124fec1d44709c80ec7f69f5ea0a2fc1d8ff
Author: NunoSempere <nuno.sempere@protonmail.com>
Date:   Sun, 23 Jul 2023 21:21:54 +0200

fix README

Diffstat:
MREADME.md | 15+++++++++++----
Mtest/test | 0
Mtest/test.c | 2++
3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/README.md b/README.md @@ -234,7 +234,14 @@ delta: -18537322405.459286, relative delta: -463.707799 What is happening in this case is that you are taking a normal, like `normal(-0.195240, 4.883106)`, and you are exponentiating it to arrive at a lognormal. But `normal(-0.195240, 4.883106)` is going to have some noninsignificant weight on, say, 18. But `exp(18) = 39976300`, and points like it are going to end up a nontrivial amount to the analytical mean and standard deviation, even though they have little probability mass. -Fortunately, the reader can also check that for more plausible real-world values, like the +The reader can also check that for more plausible real-world values, like those fitting a lognormal to a really wide 90% confidence interval from 10 to 10k, errors aren't eggregious: + +``` +[x] Mean test for to(10.000000, 10000.000000) PASSED +[-] Std test for to(10.000000, 10000.000000) NOT passed. +Std of to(10.000000, 10000.000000): 23578.091775, vs expected std: 25836.381819 +delta: -2258.290043, relative delta: -0.095779 +``` ## Related projects @@ -256,12 +263,12 @@ Fortunately, the reader can also check that for more plausible real-world values - [x] Add example for only one sample - [x] Add example for many samples -- ~~[ ] Add a custom preprocessor to allow simple nested functions that don't rely on local scope?~~ +- [ ] ~~Add a custom preprocessor to allow simple nested functions that don't rely on local scope?~~ - [x] Use gcc extension to define functions nested inside main. - [x] Chain various sample_mixture functions - [x] Add beta distribution - See <https://stats.stackexchange.com/questions/502146/how-does-numpy-generate-samples-from-a-beta-distribution> for a faster method. -- ~~[-] Use OpenMP for acceleration~~ +- [ ] ~~Use OpenMP for acceleration~~ - [x] Add function to get sample when given a cdf - [x] Don't have a single header file. - [x] Structure project a bit better @@ -278,7 +285,7 @@ Fortunately, the reader can also check that for more plausible real-world values - [x] Add sampling from a gamma distribution - https://dl.acm.org/doi/pdf/10.1145/358407.358414 - [x] Explain correlated samples -- [-] ~~Add tests in Stan?~~ +- [ ] ~~Add tests in Stan?~~ - [x] Test summary statistics for each of the distributions. - [x] For uniform - [x] For normal diff --git a/test/test b/test/test Binary files differ. diff --git a/test/test.c b/test/test.c @@ -303,6 +303,8 @@ int main() test_to(low, high, seed); } } + // Bonus example + test_to(10, 10 * 1000, seed); printf("Testing beta distribution\n"); for (int i = 0; i < 100; i++) {