commit ea80c930e617c66b2bea71695dbb6df80cfd3d5e
parent f5af776eb360503e038df733a00a400703e33ae5
Author: NunoSempere <nuno.sempere@protonmail.com>
Date: Sun, 16 Jul 2023 21:52:24 +0200
reduce num samples, start README
Diffstat:
8 files changed, 42 insertions(+), 19 deletions(-)
diff --git a/README.md b/README.md
@@ -0,0 +1,38 @@
+# Squiggle.c
+
+
+
+## Why C?
+
+- Because it is fast
+- Because it can be made faster if need be, e.g., with a multi-threading library like OpenMP
+- Because if you can implement something in C, you can implement it anywhere else
+- Because it will last long
+- Because the language is honest
+- Because I enjoy it
+
+## To do list
+
+- [ ] Have some more complicated & realistic example
+- [ ] Add summarization functions, like mean, std, 90% ci (or all c.i.?)
+- [ ] Add README
+ - Schema: a function which takes a sample and manipulates it,
+ - and at the end, an array of samples.
+ - Explain boxes
+ - Explain individual examples
+ - Explain nested functions
+- [ ] Publish online
+
+## Done
+
+- [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?~~
+- [x] Use gcc extension to define functions nested inside main.
+- [x] Chain various 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~~
+- [x] Add function to get sample when given a cdf
+- [x] Don't have a single header file.
+- [x] Structure project a bit better
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/04_sample_from_cdf_simple/example.c b/examples/04_sample_from_cdf_simple/example.c
@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <time.h>
-#define NUM_SAMPLES 1000000
+#define NUM_SAMPLES 10000
// Example cdf
float cdf_uniform_0_1(float x)
diff --git a/examples/05_sample_from_cdf_beta/example b/examples/05_sample_from_cdf_beta/example
Binary files differ.
diff --git a/examples/05_sample_from_cdf_beta/example.c b/examples/05_sample_from_cdf_beta/example.c
@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <time.h>
-#define NUM_SAMPLES 1000000
+#define NUM_SAMPLES 10000
#define STOP_BETA 1.0e-8
#define TINY_BETA 1.0e-30
diff --git a/examples/05_sample_from_cdf_beta/makefile b/examples/05_sample_from_cdf_beta/makefile
@@ -5,7 +5,7 @@
# make run
# Compiler
-CC=gcc # required for nested functions
+# CC=gcc # required for nested functions
# CC=tcc # <= faster compilation
# Main file
diff --git a/squiggle.c b/squiggle.c
@@ -5,6 +5,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
+
#define EXIT_ON_ERROR 0
#define MAX_ERROR_LENGTH 500
#define PROCESS_ERROR(...) \
diff --git a/to-do.md b/to-do.md
@@ -1,16 +0,0 @@
-
-- [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?~~
-- [x] Use gcc extension to define functions nested inside main.
-- [x] Chain various mixture functions
-- [ ] Have some more complicated & realistic example
-- [ ] Add summarization functions, like mean, std, 90% ci (or all c.i.?)
-- [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
-- [x] Add function to get sample when given a cdf
-- [ ] Don't have a single header file.
-- [ ] Structure project a bit better
-- [ ] Add README
-- [ ] Publish