From 1133d7819c1c21b8674578aa89948c2e64ad80a9 Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Sun, 23 Jul 2023 21:21:54 +0200 Subject: [PATCH] fix README --- README.md | 15 +++++++++++---- test/test | Bin 26768 -> 26768 bytes test/test.c | 2 ++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7e45ce6..be25b2d 100644 --- 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 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 index af5c341a5c9b63447cc72d4b3905a61e28353c8c..997dac559550c351a828b6b62a4b9fab32828658 100755 GIT binary patch delta 3739 zcmaJ^3se(l7M?#6B?u%yLP!D$j|mV!!$U04V4;E}5UcW#fbSkrJlcm{T6ODITeQd2 zvW4F6u6o)%*0#ISt=%GRmug$FTFdd#728#+wStd2Rx4Edz^?A>H#5%|)Z3$u5s3|g+{f1tT zw6n={IMTwh=u%`UyGYqlcGbrb)EjBGwU6Ss=8NpnjqaAhnz0UTbAG|<2*uB85eXvI;fEG_D7HFM&9*bO{P3^g&)qx?6 z57#`ecd>pd)W@-pXolXx{z%L8x$I%u21z9yfFzmD>vL6{j;w}QcAD-sSlGK%Ybda- z*UE0aWB#w(2k0$>rEWl@gx`+%Ze(yAT!+Oe1LT=VA$AKp!NUA1K@cALwLU{54>uX$`uEcP+U_Qe*dK^z&&{}63fpCV?iQ*r#J|=s*STAAlfaUVcBwEBov=rks}Ps)F<|L=klv+LCNs;SO{RouM{*#% zOxSJWQ}Mf!j}d7z25b|Ht}Xp;sZwBXt-FRx)YLX2UCrVkQs6x+Q#` zG;u9WFgsWcHJY{rSa%Kvk8shi_J3SAOI=& z6TsVpKS5h!i�GiFLBqDJsrY@&E?Q)wvb?H%Y%5{EJs5Zzz=4zeG;RMV=^bLevb% z(IU6S<)O22PS#F(t1D*-w6Yr=ezEeAq;rXqpW8BojNO)`P1J173HcPkT+#aW3X`eZ zYG&DV!fMq}tP59M#ejbwMJ=lFkTaWmK#V{akX;-!NeTrCGLb6gP+(%R54J@7-;^SEgJsodn z^XQFuGn+)8#3x22DZW9+z$2JKTsvI{b1uat#mO)NH=y5rQeH8FDZBbQ}wp}desA15AR zAJB#*JNpxTnDh|lGM48<3ci&Xb!wH3PNkZnf|fm|)Krq4wqmELp>_O13>@Msn2B8W zm)PTU+@2Kj+(l(zZJaca;*=EZ^kH_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B4qbG_xU_)XEj$Ucs)BLigrUb>nR)$MQxSyRUy^ r!jZmgAg#NS5e^LDp&Mft~ diff --git a/test/test.c b/test/test.c index cd16c62..cb9fab3 100644 --- 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++) {