fix README

This commit is contained in:
NunoSempere 2023-07-23 21:21:54 +02:00
parent 7694124fec
commit 1133d7819c
3 changed files with 13 additions and 4 deletions

View File

@ -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. 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 ## 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 only one sample
- [x] Add example for many samples - [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] Use gcc extension to define functions nested inside main.
- [x] Chain various sample_mixture functions - [x] Chain various sample_mixture functions
- [x] Add beta distribution - [x] Add beta distribution
- See <https://stats.stackexchange.com/questions/502146/how-does-numpy-generate-samples-from-a-beta-distribution> for a faster method. - 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] Add function to get sample when given a cdf
- [x] Don't have a single header file. - [x] Don't have a single header file.
- [x] Structure project a bit better - [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 - [x] Add sampling from a gamma distribution
- https://dl.acm.org/doi/pdf/10.1145/358407.358414 - https://dl.acm.org/doi/pdf/10.1145/358407.358414
- [x] Explain correlated samples - [x] Explain correlated samples
- [-] ~~Add tests in Stan?~~ - [ ] ~~Add tests in Stan?~~
- [x] Test summary statistics for each of the distributions. - [x] Test summary statistics for each of the distributions.
- [x] For uniform - [x] For uniform
- [x] For normal - [x] For normal

BIN
test/test

Binary file not shown.

View File

@ -303,6 +303,8 @@ int main()
test_to(low, high, seed); test_to(low, high, seed);
} }
} }
// Bonus example
test_to(10, 10 * 1000, seed);
printf("Testing beta distribution\n"); printf("Testing beta distribution\n");
for (int i = 0; i < 100; i++) { for (int i = 0; i < 100; i++) {